Hi everybody.
I’m having problems reading the first 32 characters of the ASCII table through the serial port and with the log file generation of them.
I’ve tried to use the commands read(), read_cond() and modem_read().
I’ve seen that it gets only the 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 and 24 character.
I also did a test with HyperTerminal to Qtalk. It receives only the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 and 31.
This is my code:
Class to configure the port:
[code]int ASerialPortConfig::Configuration(int fd, int speed) {
int ret = 0;
struct termios tp;
/* Getting the current terminal control settings. */
ret = tcgetattr(fd, &tp);
if (ret == -1){
perror("Error getting the termios attribute");
return -1;
}
/* Setting the input baud rate in a termios structure. */
ret = cfsetispeed(&tp, speed);
if (ret == -1){
perror("Error editing termios input speed");
return -1;
}
/* Setting the output baud rate in a termios structure. */
ret = cfsetospeed(&tp, speed);
if (ret == -1){
perror("Error editing termios output speed");
return -1;
}
/* Disable ECHO. */
tp.c_lflag &= ~ECHO;
/* QNX extensions to POSIX are enabled. */
tp.c_lflag |= IEXTEN;
/* Enable signals. */
tp.c_lflag |= ISIG;
/* Disable hardware input/output flow control. */
tp.c_cflag &= ~IHFLOW;
tp.c_cflag &= ~OHFLOW;
/* Disable software input/output flow control. */
tp.c_iflag &= ~IXOFF;
tp.c_iflag &= ~IXON;
/* Changing the terminal control settings for a device. */
ret = tcsetattr(fd, TCSANOW, &tp);
if (ret == -1){
perror("Error setting termios options");
return -1;
}
else
return ret;
}[/code]
Openning the port:
open("/dev/ser1", NULL)
Capturing the serial port content:
[code]
unsigned char itsBuffer;
ofstream tempFile;
tempFile.open("/home/juliano/QNXSerialReceiver.txt");
while (read(this->getFileDescriptor(), &itsBuffer, sizeof(itsBuffer)) > 0) {
tempFile << itsBuffer;
tempFile.flush();
}[/code]
Regards.