On Wed, May 4, 2022 at 11:31 PM Richard Weinberger <richard.weinber...@gmail.com> wrote: > > On Thu, May 5, 2022 at 7:47 AM C Smith via Xenomai <xenomai@xenomai.org> > wrote: > > > > In my serial_config which I pass to the ioctl() that sets up my > > 16550A.ko serial port > > I have set .rx_timeout = 500000 > > and I am doing non-blocking reads. > > > > This indeed results in a 500us delay when reading a serial port with > > no incoming bytes, which I can measure precisely on an oscilloscope (I > > have a DIO port pulse depicting the duration of the read()). > > > > This is wasted time in my (RT userspace) app during the read() when > > there is no serial traffic on a particular port, and I have many > > serial ports. But why must I decide how long to stall the RT process > > with a timeout? Can't read() return immediately if there is no data in > > the device ? > > > > Must I use an ioctl with RTSER_RTIOC_GET_STATUS to inspect the UART > > LSR for data available? > > > > (This is a RT userspace app on Xeno 3.1.2, kernel 4.19.229, intel I5, > > 16550 compat UART) > > IIRC as soon you configure a timeout, reads are blocking. Configuring -1 > as timeout will cause read to return immediately with -EAGAIN if no > data is available.
Indeed you were right. I set .rx_timeout = -1 and now the read() is nonblocking. errno gets set to EAGAIN, and it takes only 54us to read 6 inactive ports. thanks -C Smith