more error resistant
This commit is contained in:
parent
6c642e867c
commit
4621abe17c
|
@ -24,6 +24,7 @@ import atexit
|
||||||
import os.path
|
import os.path
|
||||||
import serial
|
import serial
|
||||||
import socket
|
import socket
|
||||||
|
import time
|
||||||
|
|
||||||
from chaosc.argparser_groups import create_arg_parser, finalize_arg_parser, add_chaosc_group
|
from chaosc.argparser_groups import create_arg_parser, finalize_arg_parser, add_chaosc_group
|
||||||
|
|
||||||
|
@ -46,11 +47,16 @@ class Platform(object):
|
||||||
def connect(self):
|
def connect(self):
|
||||||
print "connect serial"
|
print "connect serial"
|
||||||
print "waiting for the device %r to come up" % self.args.device
|
print "waiting for the device %r to come up" % self.args.device
|
||||||
|
self.serial_sock = serial.Serial()
|
||||||
|
self.serial_sock.port = self.args.device
|
||||||
|
self.serial_sock.baudrate = 115200
|
||||||
|
self.serial_sock.timeout = 1
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
self.serial_sock = serial.Serial(self.args.device, 115200, timeout=1)
|
self.serial_sock.open()
|
||||||
except serial.serialutil.SerialException, e:
|
except (serial.serialutil.SerialException, os.error), e:
|
||||||
print "serial error", e
|
print "serial error", e
|
||||||
|
time.sleep(0.5)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue