pySerial: write in a blocking mode

Alejandro alejandro.weinstein at
Tue Mar 28 22:45:47 CEST 2006


I'm using pySerial to talk to a RS232 to RS485 converter. In order to
control the converter, I need to control the DTR line to enable/disable
de RS485 driver. In particular, I need to :

write a character to the serial port
set the DTR line to level 1 _after_ the last bit of the character is

So I tried this (ser is the serial port object):


The problem with this is that the ser.write function returns before the
character is send, and thus, the DTR line is set too soon. (I checked
this behaivour with an osciloscope).

I thought that seting the writeTimeout parameter could help, but then I
realized that the write function wait "up to this time", so it doesn't

Then I tried waiting some time with time.sleep() after ser.write, but
the shortest time for time.sleep is to big, and non deterministic, so I
think this is not an option.

Does anybody know how to do a ser.write() in a blocking way?


More information about the Python-list mailing list