how to detect a buffer over run on serial port in linux using c++

后端 未结 2 516
夕颜
夕颜 2021-01-03 06:34

I have a big problem. At present I am accessing a serial port via the following hooks:

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

then

相关标签:
2条回答
  • 2021-01-03 07:11

    According to the kernel sources, you should use the TIOCGICOUNT ioctl. The third ioctl argument should be a pointer to the following struct, defined in <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];
    };
    

    I don't know if every driver detect all conditions however.

    0 讨论(0)
  • 2021-01-03 07:18

    Dark Templer,

    Your serial driver should update the icount.frame/overrun errors.

    struct uart_port in serial_core.h has member struct uart_icount, which should be updated in platform serial device driver as per interrupts received.

    0 讨论(0)
提交回复
热议问题