Temia Eszteri schreef:
Actually, I believe someone in an earlier thread in the newsgroup or
elsewhere pointed out that serial ports automatically open under
Windows. I'd have to look it back up when I have the time, which I
don't have at the moment, unfortunately.
That doesn't have anything to do with Windows, but with how pySerial
works. See the documentation for __init__():
"The port is immediately opened on object creation, when a port is
given. It is not opened when port is None and a successive call to
open() will be needed."
So if your script does something like
prt = serial.Serial('COM4')
then pySerial automatically opens the port, and you shouldn't call
prt.open() anymore.
If, on the contrary, you do something like
prt = serial.Serial()
prt.port = 'COM4'
then pySerial doesn't open the port, and you have to call prt.open() to
do it.
PySerial has this same behavior on both Windows and Linux. The
difference might be that on Linux it is possible to open serial ports
more than once, while that doesn't work on Windows.
Best regards,
Roel
--
http://mail.python.org/mailman/listinfo/python-list