mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-23 00:35:53 +08:00
Add error handling to opening of serial device
This commit is contained in:
@@ -105,9 +105,10 @@ if __name__ == "__main__":
|
||||
\nnote: model name is optional'
|
||||
exit(1)
|
||||
|
||||
ser = serial.Serial(sys.argv[2], 9600, timeout=5)
|
||||
if not ser:
|
||||
print 'could not open device'
|
||||
try:
|
||||
ser = serial.Serial(sys.argv[2], 9600, timeout=5)
|
||||
except serial.serialutil.SerialException:
|
||||
print 'could not open serial device ' + sys.argv[2]
|
||||
exit(1)
|
||||
if not ser.is_open:
|
||||
ser.open()
|
||||
|
||||
Reference in New Issue
Block a user