The stupid baudrate set by ATI
the ATI specified that baudrate is 1250000 default.
while the F/T sensor start streaming, we must read with no error.
#include <stropts.h> /* Custom Baud Rate Settings */
#include <asm/termios.h>
We should use asm/termios.h but not the termios.h
struct termios2 SerialPortSettings;
int fd;
if ((fd = open("/dev/ttyUSB0",O_RDWR|O_NOCTTY)) == -1)
{
printf("Error opening PTS\n");
return -1;
}
if (ioctl(fd, TCGETS2, &SerialPortSettings) < 0)
{
printf("Failed to get\n");
return -1;
}
SerialPortSettings.c_cflag &= ~CBAUD;
SerialPortSettings.c_cflag |= BOTHER;
SerialPortSettings.c_ispeed = 1250000;
SerialPortSettings.c_ospeed = 1250000;
SerialPortSettings.c_cflag |= PARENB;
SerialPortSettings.c_cflag &= ~ PARODD; //EVEN
SerialPortSettings.c_cflag &= ~CSTOPB; //Stop bits = 1
SerialPortSettings.c_cflag &= ~CSIZE;
SerialPortSettings.c_cflag |= CS8;
SerialPortSettings.c_cflag |= CREAD | CLOCAL;
SerialPortSettings.c_cc[VMIN] = 13; //读取字符的最小数量
SerialPortSettings.c_cc[VTIME] = 0; //读取第一个字符的等待时间
if (ioctl(fd, TCSETS2, &SerialPortSettings) < 0)
{
printf("Failed to set\n");
return -1;
}
printf("Successfully baudrate Set\n");
uint8_t read_buffer[100];
Use the --bytes_read = read(fd,&read_buffer,13);-- to read
in a while(1) loop, we printf the array out as below:
