Serial 8O1 Problem
Hello All,
I'm working on a program that should read serial data from GPS receiver (Trimble ACEIII card). The receiver features 16C550 UART set to 9600 8O1 no flow control. The problem is that the most significant bit in every received byte is always set to 0 ('dead' bit #7).
As recommended in the 'Serial Programming Guide for POSIX Operating Systems', the serial port is set as follows:
/***********************************************/
struct termios options;
int fd;
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
ret = fcntl(fd, F_SETFL, 0);
tcgetattr(fd, &options); // Get current options
cfsetispeed(&options, B9600); // Set input speed
cfsetospeed(&options, B9600); // Set output speed
options.c_cflag |= (CLOCAL | CREAD); // Set local mode
options.c_cflag |= PARENB; // Enable parity
options.c_cflag |= PARODD; // Set ODD parity
options.c_cflag &= ~CSTOPB; // Set 1 stop bit
options.c_cflag &= ~CSIZE; // Data size
options.c_cflag |= CS8; // Set 8 data bits
options.c_cflag &= ~CRTSCTS; // Disable hw flow ctrl
// Disable canonical input
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG | IEXTEN);
// Disable sw flow control
options.c_iflag &= ~(IXON | IXOFF | IXANY);
// Enable parity, strip parity bit
options.c_iflag |= (INPCK | ISTRIP );
options.c_oflag &= ~OPOST;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &options); // Set new options now
/**********************************************/
The problem ('masked' bit #7) occurs only for the data RECEIVED from the serial port. The data SENT to the serial port is delivered correctly...
Anything you may suggest will be greatly appreciated!
Thanks,
VV
|