Results 1 to 1 of 1
Hello,
I am trying to connect to a sensor via the serial port. However I get parity errors it seems.
I need to have: 1 start bit, 8 data bits, ...
- 08-03-2008 #1Just Joined!
- Join Date
- Aug 2008
- Posts
- 17
serial sensor
Hello,
I am trying to connect to a sensor via the serial port. However I get parity errors it seems.
I need to have: 1 start bit, 8 data bits, 1 parity(even) and 1 stop bit.
I tried a few things but can't seem to get it straight.
here's what I have:
struct termios options;
// Get the current options for the port...
tcgetattr(fd, &options);
// Set the baud rates to 19200...
cfsetispeed(&options, B19200);
cfsetospeed(&options, B19200);
// Enable the receiver and set local mode...
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag |= PARENB;
options.c_cflag |= CSTOPB;
options.c_cflag |= IXOFF;
options.c_cflag |= CS8;
options.c_lflag = ICANON; // no echo etc
options.c_cc[VMIN] = 1; // blocking read until 1 character arrives
tcflush(fd, TCIFLUSH);
// Set the new options for the port...
tcsetattr(fd, TCSANOW, &options);
any suggestions ?
tia.


Reply With Quote