All of lore.kernel.org
 help / color / mirror / Atom feed
* serial 16550A rx_timeout
@ 2022-05-05  5:47 C Smith
  2022-05-05  6:31 ` Richard Weinberger
  0 siblings, 1 reply; 3+ messages in thread
From: C Smith @ 2022-05-05  5:47 UTC (permalink / raw)
  To: Xenomai List

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)
thanks,   -C Smith


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: serial 16550A rx_timeout
  2022-05-05  5:47 serial 16550A rx_timeout C Smith
@ 2022-05-05  6:31 ` Richard Weinberger
  2022-05-05 20:16   ` C Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2022-05-05  6:31 UTC (permalink / raw)
  To: C Smith; +Cc: Xenomai List

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.

-- 
Thanks,
//richard


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: serial 16550A rx_timeout
  2022-05-05  6:31 ` Richard Weinberger
@ 2022-05-05 20:16   ` C Smith
  0 siblings, 0 replies; 3+ messages in thread
From: C Smith @ 2022-05-05 20:16 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: Xenomai List

On Wed, May 4, 2022 at 11:31 PM Richard Weinberger
<richard.weinberger@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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-05 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05  5:47 serial 16550A rx_timeout C Smith
2022-05-05  6:31 ` Richard Weinberger
2022-05-05 20:16   ` C Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.