ich möchte ein Exception auslösen wenn beim readline() timeout vorkommt. Kann mir Jemand dabei helfen oder eine Alternative anbieten?
(Python 2.7; PySerial; timeout = 1)
Habe flolgendes probiert:
Code: Alles auswählen
try:
print "1"
self.ser.write('%s\n' %str)
print "2"
self.postBox = self.ser.readline()
print "3"
except serial.SerialException:
print "Exception"
print self.postBox
#oder
except serial.SerialTimeoutException:
print "Exception"
print self.postBox
1
2
#wartet 1 Sekunde
3