Getting error counters through TIOCGICOUNT always returns an error (-1)

I encountered the problem of stopping the show when developing an interface application for the USB-RS422 converter module.

I need to get UART error counters for cropping, overflow, parity and interrupt errors. But the ioctl call always returns -1, and the counter values ​​from the extracted structure jump to very large numbers.

The code I use to retrieve the counters is as follows:

struct serial_icounter_struct counters; int ret = ioctl(portDescriptor, TIOCGICOUNT, &counters); 

To install portDescriptor, I use similar code for:

 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) 

Sometimes we also need to enable flow control or parity, for example.

 new_port_settings.c_cflag = new_port_settings.c_cflag | CRTSCTS; 

I tried the code on Ubuntu 11.10 32bit and on SLIS11 SP1 64bit, as with the FTDI_SIO kernel module.

Does anyone know of any problem using TIOCGICOUNT, or am I doing something wrong?

Thank you in advance for your help! Edward

+4
source share

All Articles