I have created a program to communicate with another device using serial communication via RS485 and run it on the RevPi.
Summary of the program
The program is written in C and uses a select function to repeatedly detect and read incoming messages from another device.
Please let me know if there is a solution to the following problem.
・It takes about 20ms for a received message from another device to be updated in the device file, which is a larger delay than expected.
・It takes about 20 ms before the select function detects the reception.
・When reading immediately after reception is detected, all data (100 bytes) sent from another device is in the device file, and the message written from the device driver to the device file at one time is larger than expected.
・Is the received data buffered in the device driver?
Environment
・RevPiConnectSE (RevPi Buster Lite (01/2023) (ID: 6568))
・Port used: RS485 (dev/ttyUSB0)
・Baud rate: 562500
Inquiry about delay when received from RS485 port
Re: Inquiry about delay when received from RS485 port
Dear Hydro,
Not sure it is the same for you, but we have solved a similar issue reading from load cells via serial. We found we had to set /sys/bus/usb-serial/devices/ttyUSB0/latency_timer to 1 for better performance.
This gets overwritten on boot, so you need some way to make that setting survive reboots. We use docker-compose to set it for us.
This is not a Revolution Pi issue, I would think. Better look on the general Raspberry Pi forums for this type of question.
Hope this helps.
Kees Jan
Not sure it is the same for you, but we have solved a similar issue reading from load cells via serial. We found we had to set /sys/bus/usb-serial/devices/ttyUSB0/latency_timer to 1 for better performance.
This gets overwritten on boot, so you need some way to make that setting survive reboots. We use docker-compose to set it for us.
This is not a Revolution Pi issue, I would think. Better look on the general Raspberry Pi forums for this type of question.
Hope this helps.
Kees Jan
Re: Inquiry about delay when received from RS485 port
Thanks for the Hint, Kees. In order to make this setting permanent I'd use a udev rule:
Make sure to reboot the Connect afterwards.
Nicolai
Code: Select all
cat <<EOX | sudo tee /etc/udev/rules.d/90-ftdi-latency-timer.rules
ACTION=="add", SUBSYSTEM=="usb-serial", DRIVER=="ftdi_sio", ATTR{latency_timer}="1"
EOX
Nicolai
Re: Inquiry about delay when received from RS485 port
Dear Nicolai,
Great idea. You'd only need a way to make this setting survive full reset, for example if you move the code to another Revolution Pi instance.
We actually have a check in the code that throws an error on startup when latency_timer has not been set to 1. Not ideal, but at least the system does not slow down inexplicably after an RMA.
Kees Jan
Great idea. You'd only need a way to make this setting survive full reset, for example if you move the code to another Revolution Pi instance.
We actually have a check in the code that throws an error on startup when latency_timer has not been set to 1. Not ideal, but at least the system does not slow down inexplicably after an RMA.
Kees Jan