Python Forum
Understanding Raspberry PI RTS/CTS flow control - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Understanding Raspberry PI RTS/CTS flow control (/thread-30659.html)



Understanding Raspberry PI RTS/CTS flow control - zazas321 - Oct-30-2020

Hello. I am trying to get modbus working on my Raspberry PI but I cannot fully understand how to implement flow control. I have found and read these two articles:
https://ethertubes.com/raspberry-pi-rts-cts-flow-control/
https://github.com/mholling/rpirtscts

But still I am confused about RTS/CTS flow control. Does it happen automatically on the raspberry PI? if I set the GPIO 16,17 pin modes to RTS/CTS as per this guide: https://ethertubes.com/raspberry-pi-rts-cts-flow-control/
Would that mean that I enable the automatic flow control? I can now connect RTS pin to direction pin of RS485 IC and that should work? Or I still need to toggle these pins in program.

Could someone help me understand


RE: Understanding Raspberry PI RTS/CTS flow control - zazas321 - Oct-30-2020

I have configured the RTS/CTS pins for hardware flow control as per described guide. Now its acting weird:

import serial
import RPi.GPIO as GPIO
import time
sendSerial = serial.Serial ("/dev/serial0", 9600)

#sendSerial.write (str.encode("hello"))
sendSerial.write (100)

 
print("done")
 
 
sendSerial.close()
I have connected RTS(GPIO17) to DIR pin of my RS485 Driver
and RX/TX accordingly

I am running code above and using logic analyzer to capture what comes out of RS485 chip pin A. I do not tink hardware flow control is working properly as I am always getting some garbage even when I am not trying to serial write anything it still the same result see the image below:
https://ibb.co/jVJkgS9


Hoever, when I add some code to manually toggle direction pin, I can see the message go through properly:
the code:
# \x02 - trigger scanning
# \x03 after scanning is done
import serial
import RPi.GPIO as GPIO
import time
sendSerial = serial.Serial ("/dev/serial0", 9600)
#GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
#GPIO.setup(11, GPIO.OUT) # Set pin 10 to be an input pie to be pulled low (off)
 
#GPIO.output(11,1)
#sendSerial.write (str.encode("hello"))
sendSerial.write (100)
#sendSerial.flush()
#GPIO.output(11,0)
 
print("done")
 
 
sendSerial.close()
Now I can read the data that I am writing :
https://ibb.co/c6S4H3W

But the direction pin is holding for too long because the hardware flow control is not working


RE: Understanding Raspberry PI RTS/CTS flow control - zazas321 - Oct-30-2020

After activating flow control using this guide I have checked the gpio tree and it does not appear to have any affect:
https://ibb.co/6NsKZPT