我曾经碰到过一个节目制定一个USB转RS422转换器模块的接口应用时,在停止问题。
我需要检索数据帧,溢出,奇偶校验的UART错误计数器和中断错误。 但总是IOCTL调用返回-1,并从检索结构的计数器值被跳转到非常大的数字。
我使用检索计数器代码如下:
struct serial_icounter_struct counters;
int ret = ioctl(portDescriptor, TIOCGICOUNT, &counters);
要设置我使用的是类似的代码到portDescriptor:
int portDescriptor = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);
struct termios new_port_settings;
//clear the new struct
memset(&new_port_settings, 0, sizeof(new_port_settings));
//set port settings
new_port_settings.c_cflag = B57600 | CS8 | CLOCAL | CREAD;
new_port_settings.c_oflag = 0;
new_port_settings.c_lflag = 0;
new_port_settings.c_cc[VMIN] = 0;
new_port_settings.c_cc[VTIME] = 0;
int error = tcsetattr(portDescriptor, TCSANOW, &new_port_settings)
有时我们也需要配置流量控制或奇偶如
new_port_settings.c_cflag = new_port_settings.c_cflag | CRTSCTS;
我试图在Ubuntu的11.10和32位在SLES11 SP1 64位码,都与该FTDI_SIO内核模块。
是任何人知道任何关于TIOCGICOUNT的使用还是我做错了什么样的问题呢?
预先感谢您的帮助! 爱德华