FUDforum
My FUDforum

Home »  » DeviceMaster RTS, Pro and Serial Hub » Advanced Setup : Low Latency Small FIFO (What are the optimal settings for low latency devices that need logs of servicing?)
Advanced Setup : Low Latency Small FIFO [message #1357] Tue, 04 May 2021 03:29 Go to next message
imissmyrocket is currently offline  imissmyrocket
Messages: 17
Registered: January 2021
Location: Austin
Member
I've got a 3rd party application that needs to service his UART (well now its an ethernet) IRQ every other jiffie it seems. I think it is so old it thinks I have one of those old UARTs with a 8 byte FIFO or something.

Anyhow we've tried a gazillion things, but occasionally we miss or are late to service an IRQ, and then we see the data get corrupted or out of order. We are only reading data here (no write) with no flow control at a max speed of 38 Kbaud. So I've got 3 knobs and buttons, maybe 4 I can push, which are outlined in the man page:
LATENCY -- READ DATA
       By  default,  serial data received by the DeviceMaster is sent to the NS-Link driver once every 10ms. This can introduce a delay of up to 10ms in the
       recieve data path.  In the DeviceMaster, this latency can be reduced in two ways:

       Inter-character timeout
              It is possible to configure an inter-character timeout that causes the DeviceMaster to send queued receive data when a gap is detected in the receive 
              serial data stream. An  intercharacter timeout may be configured either in the nslink.conf(5)file, by using the setseral(8) utility (see below) or 
              with the underlying TIOCSSERIAL and TIOCGSERIAL ioctl() calls.

       Scan period
              It  is also possible to change the DeviceMaster's scan period from the default 10ms to a lower value. This also decreases latency, but increases CPU 
              and network usage.  Configuring an inter-character timeout is generally a better way to reduce latency in receive data. The scan period is configured 
              in the nslink.conf(5) file. A value of 0 causes the DeviceMaster to use its default scan period (10ms).


I left out the "retransmit timer" because I'm only receiving data...there is no transmit, and no sync :facepalm:

I downloaded and compiled the latest setserial with my 5.3 kernel. It did no recognize the IO ctl flags, but that is OK... i can do the nslink.conf method. Problem is here it isn't necessarily up on the PC that that the problem resides right? How do I control how fast the device master itself fills up whatever buffer the firmware has downstream? Then I want to size it such that if I am a little late servicing an IRQ it isn't a crisis.

Is it just that scan period? Not sure what the devicemaster's scan period would have to do with CPU usage on the controlling PC except maybe to service network a little more often? I would hope the ethernet buffers (currently 1024 * 16 KBytes per eth port) would accomodate that for a pretty large relative time period.

What about UDP? I'm set up to do this comm from device master to host using TCP, would UDP be better, or would I just lose more data?

How can I set it up so I have the the device master quickly read and buffer data, and the kernel can service the nslink driver on a looser schedule? He's running at a high priority, we have ~4000 IRQs/sec though across 32 CPUs, evenly divided. So, sometimes it is delayed a tiny bit....i mean like milliseconds. seems if there were x2 reads of 12 bytes (guessing) from the 3rd party software in the interim it gets corrupted.
Re: Advanced Setup : Low Latency Small FIFO [message #1359 is a reply to message #1357] Thu, 06 May 2021 09:41 Go to previous messageGo to next message
Kurt is currently offline  Kurt
Messages: 290
Registered: July 2016
Location: Minnesota
Power User
Hi,

Have you tried the below?


On the port mode line after the inter-character timeout value. If you want to use an option flag without enabling the inter-character timeout, you can specify a value of 0. The description of the low_latency flag is a bit off and needs to be tweaked: it's ignored by the kernel, but it does have some effect on the driver itself. Here's the section from the nslink.conf man page:

port-num interface-type [inter-char-timeout [option-flags]]
Specifies the type of electrical interface, the inter-character timeout value, and optionally sets one or more option flags. for port number port-num of the DeviceMaster most recently specified using either the Ethernet or IP address configuration commands described above. port-num is a 1-based value (1-2 for 2-port models, 1-4 for 4-ports, 1-8 for 8 ports). interface-type is specified as one of 232, 422, 485, 485_2-wire, 485_4-wire_master, or 485_4-wire_slave to specify RS-232, RS-422, RS-485 Half Duplex, RS485 2-wire (Half Duplex), RS485 4-wire Master (Full Duplex Master), or RS485 4-wire Slave (Full Duplex Slave) interfaces, respectively.

NOTE: RS485 2-wire, RS485 4-wire Master and RS485 4-wire Slave modes are only available on LT16 and 2 Port models of the DevicMaster. RS485 2-wire and standard RS485 mode are identical. RS485 4-wire Master and RS422 are identical.
The optional option-flags field is a set of comma-separated flag names. The available flags are describe below.

low_latency
Historically, this flag enabled low-latency operation for received data: rather than buffering receive data and transferring it to the line-discipline layer once every 10ms, receive data would be transferred immediately upon arrival. However, the Linux kernel's tty layer was re-written so that it no longer imposes that buffering latency and it is not affected by the low_latency flag. This flag is still allowed for backwards compatibility

rx_fifo_disable
Disable the use of the UART's receive FIFO. This is currently eted for the 1-port models. When the 1-port models have the receive FIFO enabled, data bytes received with invalid parity bits may be discarded. Disabling the receive FIFO on the 1-port models will cause bytes received with invalid parity to be passed to the line discipline layer. Not recommended at baud rates above 19200.

term_res_tx_en
Enable the termination resistor between the RS422 TX+ and TX- signals (in RS422 mode) or across the 2-wire RS485 signals (when in RS485 mode). This option is only available for certain models (at time of writing, only the LT16).

term_res_rx_en
Enable the termination resistor between the RS422 RX+ and RX- signals (when in RS422 mode). This option is only available for certain models (at time of writing, only the LT16).
Examples:
1 232
2 422 5
3 232 5 low_latency
4 232

Also, you can try:
To set the low_latency flag: setserial /dev/ttySI low_latency


Kurt Rees
www.comtrol.com
http://forum.comtrol.com/

Comtrol Corporation
100 Fifth Ave NW
Minneapolis, MN. 55112
Direct +1 763.957.6000 | +1 Fax (763) 957-6001
connect. communicate. control
Re: Advanced Setup : Low Latency Small FIFO [message #1360 is a reply to message #1359] Wed, 19 May 2021 22:21 Go to previous messageGo to next message
imissmyrocket is currently offline  imissmyrocket
Messages: 17
Registered: January 2021
Location: Austin
Member
OK that is confusing...

low_latency
Historically, this flag enabled low-latency operation for received data: rather than buffering receive data and transferring it to the line-discipline layer once every 10ms, receive data would be transferred immediately upon arrival. However, the Linux kernel's tty layer was re-written so that it no longer imposes that buffering latency and it is not affected by the low_latency flag. This flag is still allowed for backwards compatibility

You made it sound like it still does something in the driver on the controlling PC side? What should I expect it to do?

I did try it, if it is doing anything I can not tell. The other line seems to be the one that has effect, the line with the IP address on it....currently I've got "<devmaster ip> 16 0 5 80". Changing the 5 to 10 has an effect it seems, still have issues though.

What would be the ideal low latency settings, ignoring load on CPU and IRQs?

Would it be:

<devmaster ip> 16 0 1 40

with mode line:

1 RS232 0 low_latency



Re: Advanced Setup : Low Latency Small FIFO [message #1362 is a reply to message #1359] Mon, 24 May 2021 14:43 Go to previous messageGo to next message
imissmyrocket is currently offline  imissmyrocket
Messages: 17
Registered: January 2021
Location: Austin
Member
Just figured out this problem only occurs on newer socketservers. The last one I have where it does NOT occur is 11.23. The 11.23 has other issues, causing high load on the machine, (it looks like it gets too many requests to flush the serial buffer) but it isn't a problem so much. It just reports high load because workqueue stacks up.

Can I get the 11.23 socketserver firmware?
Re: Advanced Setup : Low Latency Small FIFO [message #1363 is a reply to message #1362] Mon, 24 May 2021 14:58 Go to previous message
Kurt is currently offline  Kurt
Messages: 290
Registered: July 2016
Location: Minnesota
Power User
Sent me an email at krees[at]us.pepperl-fuchs.com and I will send it to you.

Kurt


Kurt Rees
www.comtrol.com
http://forum.comtrol.com/

Comtrol Corporation
100 Fifth Ave NW
Minneapolis, MN. 55112
Direct +1 763.957.6000 | +1 Fax (763) 957-6001
connect. communicate. control
Previous Topic: Advanced Setup Questions Scan period and Interchar Timeout
Next Topic: Delete an Unknown or Forgotten Password from the DeviceMaster
Goto Forum:
  


Current Time: Mon Jun 14 00:28:40 CDT 2021

Total time taken to generate the page: 0.00598 seconds