def port_button(self): self.ser = serial.Serial() self.ser.baudrate = 19200 self.ser.port = port_id self.ser.timeout = 6 self.ser self.ser.open() while True: try: self.ser.write(dummy) break except SerialException: print "error" break self.ser.close() I am trying to write code that If I choose the wrong port for Serial Communication, it will display an error message, instead of the program shutting down. I thought the except SerialException...
Originally asked by Vema Reddy on Stack Exchange (stackoverflow) (CC BY-SA 4.0).