David Ryan
Posts: 6
Joined: Wed May 16, 2018 3:53 pm

Verifying transmission complete on Tx/Rx

Thu Jul 19, 2018 2:21 pm

Hello all,

I have a project that uses the Tx/Rx pins to transmit through an RS-485 chip. I'm using GPIO18 as a flow control. As it stands when I go to transmit the following sequence occurs.

1 - Calculate transmission time(ms) based on baudrate and buffer size x = f(y)
2 - Set to GPIO 18 to transmit
3 - Send the buffer data to be written
4 - Set GPIO 18 to receive after x time has passed.

This process works, but I would feel better about the resilience of the application if I could somehow check Tx/Rx to confirm that the buffer has been written rather than hoping my timeout processes in the correct amount of time.

Application is written in node using GPIO and serialport libraries.

Any advice would be greatly appreciated. As always, thanks guys.

KnarfB
Posts: 187
Joined: Wed Dec 14, 2016 10:47 am
Location: Germany

Re: Verifying transmission complete on Tx/Rx

Thu Jul 19, 2018 4:44 pm

Hi David,

you cannot be sure for a user mode application because of OS activities which may introduce unwanted delays between your function calls, e.g. under heavy load conditions. If you switch the GPIO back too late, the UART may miss an early reply on the RS485 bus.

The overall risk depends on the baud rate, the protocol details (timing, number of bytes to send/recieve) etc..

The following might help:
  • increase the process priority to real-time (use sudo chrt -r 99 ... form the command line to start your prog) reducing the risk of being interrupted by the OS
  • use additional hardware supporting RS485 hardware flow control. I used a STM32 NUCLEO-F042K6 board for a similar purpose with a high baud rate of 2MBaud
hth KnarfB

David Ryan
Posts: 6
Joined: Wed May 16, 2018 3:53 pm

Re: Verifying transmission complete on Tx/Rx

Fri Jul 20, 2018 3:52 pm

Thanks KnarfB!

That was the answer I was afraid of. I haven't tried (really I wasn't aware of) increasing the process priority. I'll give that a shot.

Thanks for the device suggestion. If process priority doesn't check out I'll give that a shot.

mosespi
Posts: 499
Joined: Mon May 12, 2014 3:35 pm
Location: 34,-118
Contact: Website

Re: Verifying transmission complete on Tx/Rx

Fri Jul 20, 2018 6:47 pm

If you control both sides, add some sort of checksum and verify the data received is intact before acting upon it.

Regards,
-Moses
Power problems? MoPower UPS for the Pi
http://www.allspectrum.com/mopower/

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 12 guests