mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-24 01:25:41 +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'
|
\nnote: model name is optional'
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
ser = serial.Serial(sys.argv[2], 9600, timeout=5)
|
try:
|
||||||
if not ser:
|
ser = serial.Serial(sys.argv[2], 9600, timeout=5)
|
||||||
print 'could not open device'
|
except serial.serialutil.SerialException:
|
||||||
|
print 'could not open serial device ' + sys.argv[2]
|
||||||
exit(1)
|
exit(1)
|
||||||
if not ser.is_open:
|
if not ser.is_open:
|
||||||
ser.open()
|
ser.open()
|
||||||
|
|||||||
Reference in New Issue
Block a user