I have an RPi (Yes, I know, maybe someone thinks this belongs to the RPi site, but I think that it is related to Linux as a whole, so StackOverflow is the right place) and I talk between some Arduinos over MAX485 using Python3 and pySerial . This works more or less, because I found that I need to make some kind of weird workaround so that everything works "correctly."
If I send data using:
GPIO.output(23, 1)
comport.write("Some data".encode())
comport.flush()
GPIO.output(23, 0)
Arduino receives the data and responds immediately, but since pySerial is somehow not ready yet, it does not return anything and we have a lost packet.
However, if I try like this:
GPIO.output(23, 1)
comport.write("Some data".encode())
time.sleep(.001) # Add some delay of only 1ms
comport.flush()
GPIO.output(23, 0)
. : flush? :
GPIO.output(23, 1)
comport.write("Some data".encode())
time.sleep(.001) # Add some delay
# -- No flush --
GPIO.output(23, 0)
, . , "" flush.
pySerial ? , , sleep () , ( 500 ), .
, , TTL USB, flush ing ( , ), , Linux, .
- , flush , , , ( ), , , .