July 30th, 2004, 03:47 PM
Help! My serial IO exception handler not working
I am trying to use the following code to enable me to catch when another program is using the serial port, and pop-up a standard error window:
The part showing a succesfully opened COM port works like I want it to (the "else" portion). Anyone have any ideas as to what I'm doing wrong?
ser = serial.Serial()
tkMessageBox.showerror("Serial Port Error", "Could not get serial port")
ser.baudrate = 9600
ser.port = 'COM1'
tkMessageBox.showinfo("Serial Port Status","COM on %s [%s, %s%s%s%s%s]" % (
ser.rtscts and ' RTS/CTS' or '',
ser.xonxoff and ' Xon/Xoff' or '',
I am using Python 2.3 and Pyserial 2.1
August 9th, 2004, 04:57 AM
You will only get an exception when you try to open/read/write the port.
Until you attempt to grab the port with the open method the serial module cannot know which port you will be communicationg with.