Python Forum

Full Version: Understanding Raspberry PI RTS/CTS flow control
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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-...w-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-...w-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
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
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