Hello,
I got FT232 USB<->RS485 module connected to machine running on FreeBSD 9.1 release.
while trying to fix communication problem, I have found that some of data was not read correctly, for example:
Data Sent:
0x16 0x0f 0x00 0x16 0x16 0x02
Data read from the port:
0x0f 0x00 0x16 0x02
so double 0x16 read as one, single 0x16 does not read at all.... This code works well on Ubuntu.
here is the how I'm configuring the port (speed configuration is not shown)
Thanks in advance
I got FT232 USB<->RS485 module connected to machine running on FreeBSD 9.1 release.
while trying to fix communication problem, I have found that some of data was not read correctly, for example:
Data Sent:
0x16 0x0f 0x00 0x16 0x16 0x02
Data read from the port:
0x0f 0x00 0x16 0x02
so double 0x16 read as one, single 0x16 does not read at all.... This code works well on Ubuntu.
here is the how I'm configuring the port (speed configuration is not shown)
Code:
// opening port that way:
fd = open(port, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC);
int uart_configure(int fd, int stopbits,int parity)
{
struct termios options;
if(stopbits<1 || stopbits>2) return -1;
tcgetattr(fd, &options);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~CRTSCTS; // Disable flow HW control
options.c_cflag &= ~PARENB; // Disable Parity
options.c_iflag &=~(IXON|IXOFF|IXANY|IGNBRK); // Disable XON/XOFF
options.c_lflag &= ~(ICANON | ECHO | ECHOE |ISIG);
options.c_oflag &= ~OPOST;
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 0;
// stopbits
options.c_cflag &= ~CSTOPB; // 1 stop bit
if(stopbits==2)
options.c_cflag |= CSTOPB; // 2 stop bits
options.c_cflag &= ~CSIZE; /* Mask the character size bits */
options.c_cflag |= CS8; /* Select 8 data bits */
options.c_cflag &= ~PARENB;
switch(parity)
{
case 0: // none
// leave empty
break;
case 1: // odd parity
options.c_cflag |= PARENB;
options.c_cflag |= PARODD;
break;
case 2:
options.c_cflag |= PARENB;
options.c_cflag &= ~PARODD;
break;
default:
return -1;
}
tcsetattr(fd, TCSANOW, &options);
return 0;
}
Thanks in advance