Hello. I am writing data to my modbus DRIVER and learning about modbus in general. I am using logic analyzer to check my signals.
I have noticed a very strange behaviour of my DIR pin. Before I send data to RS485 driver, I toggle DIR pin HIGH and keep it HIGH until the data transfer is finished.
The code:
https://ibb.co/xsJR28b
As you can see from the image above, the DIR pin does not want for the serial write to finish
I have tried to add :
sendSerial.flush() after the writing but it looks even more strange:
https://ibb.co/qy0CDXv
Now its holding DIR pin for way too long.
Can someone help me understand this strange behaviour and how to fix it?
I have noticed a very strange behaviour of my DIR pin. Before I send data to RS485 driver, I toggle DIR pin HIGH and keep it HIGH until the data transfer is finished.
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(16, GPIO.OUT) # Set pin 10 to be an input pie to be pulled low (off) GPIO.output(16,1) sendSerial.write (str.encode("hello")) GPIO.output(16,0) print("done") sendSerial.close()And the signal analzyer shows:
https://ibb.co/xsJR28b
As you can see from the image above, the DIR pin does not want for the serial write to finish
I have tried to add :
sendSerial.flush() after the writing but it looks even more strange:
https://ibb.co/qy0CDXv
Now its holding DIR pin for way too long.
Can someone help me understand this strange behaviour and how to fix it?