mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2026-04-04 14:07:36 +00:00
Add error handling to opening of serial device
This commit is contained in:
parent
4f94ed375c
commit
b85d702224
1 changed files with 4 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue