Alejandro wrote:
> 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. 

This seems a little odd to me.  We've used several RS232-RS485 
converters without needing to do that.  Maybe a more sophisticated 
device would eliminate this need?

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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/flushfilebuffers.asp

(If that link is broken, it's the docs for the FlushFileBuffers routine. 
  This doesn't appear to be exposed in Pyserial, but you could probably 
subclass serial.Serial and add it yourself pretty easily.  The Pyserial 
source is quite accessible.)

Disclaimer: I haven't tried using that routine myself, but the docs 
imply it is supposed to do what you want.  Unfortunately, I doubt 
there's any particular guarantee about whether the data has only left 
the Windows buffers, or whether it has also left the transmit buffer of 
the UART *and* that the stop bit itself has even been transmitted.  What 
you're trying to do is a hard realtime operation, and unless it's 
directly supported you could be up against an impossible task using 
Windows.  (But it seems you already knew that. :-)

-Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to