nonblocking reads in windows?

Joe Connellan joec at
Tue Aug 27 09:40:52 EDT 2002

I ran that code without error and it seemed to write ok, but when I then read from it
I get nothing - the device I'm reading from replies to the input (even just a prompt
if something fails). If I run the code to do the write, then I connect to the device
through hyperterminal I get the response, so it seems the write is working ok. I have
now written what I need in c++, so it's not desperately important, just very strange.
I'll try to track down another pc or terminal so I can test it out further, at the
moment I don't have much to test with.

Thanks for the help


Jirka 'Eagle' Novak wrote:

> Joe Connellan wrote:
> > I'm on WinXP, there is no problem opening the com port, no errors, etc. But if I
> > try to write or read from it nothing happens - I know my com port works and the
> > config is correct as I can use it with, etc.
> This code work for me. Are you *absolutely* sure you read data from the
> port correctly?
> import serial
> import serial.serialutil
> SEND_STR = "Hello, this is just a test.\n\r"
> try:
>      comm = serial.Serial("COM1")
>      comm.setRTS(0)
>      raw_input("Press Enter to send data")
>      comm.write(SEND_STR)
>      raw_input("Press Enter to set RTS high.")
>      comm.setRTS(1)
>      raw_input("Press Enter to close port.")
>      comm.close()
> except serial.serialutil.SerialException:
>      print ">>> Exception: could not open communication port"
> --
> Jirka 'Eagle' Novak
> registered linux user #173581
> E-Mail:   eagle at
> ICQ:      46044619
> HomePage:

More information about the Python-list mailing list