How to detect buffer for serial port run in Linux using C ++

I have a big problem. I am currently accessing the serial port through the following interceptors:

fd = open( "/dev/ttyS1", O_RDWR | O_NOCTTY )

then I read it using the following code snippet

i = select( fd + 1, &rfds, NULL, NULL, &tv )
...
iLen = read( fd, buf, MAX_PACKET_LEN )

The problem is that before I read, I need to determine if there were any buffer overflows. Both at the serial port level and on internal tty-flip buffers.

We tried cat /proc/tty/driver/serial, but the overspending does not seem to be listed (see output below)

1: uart:16550A port:000002F8 irq:3 tx:70774 rx:862484 fe:44443 pe:270023 brk:30301 RTS|CTS|DTR
+3
source share
2 answers

, TIOCGICOUNT ioctl. ioctl , <linux/serial.h>:

/*
 * Serial input interrupt line counters -- external structure
 * Four lines can interrupt: CTS, DSR, RI, DCD
 */
struct serial_icounter_struct {
        int cts, dsr, rng, dcd;
        int rx, tx;
        int frame, overrun, parity, brk;
        int buf_overrun;
        int reserved[9];
};

, .

+2

Templer,

icount.frame/overrun.

struct uart_port serial_core.h struct uart_icount, .

0

Source: https://habr.com/ru/post/1752577/


All Articles