From 4621abe17c37045f852002fc7dd400848df240b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sun, 30 Mar 2014 18:34:26 +0200 Subject: [PATCH] more error resistant --- sensors2osc/sensors2osc/common.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sensors2osc/sensors2osc/common.py b/sensors2osc/sensors2osc/common.py index 004b911..79dce84 100644 --- a/sensors2osc/sensors2osc/common.py +++ b/sensors2osc/sensors2osc/common.py @@ -24,6 +24,7 @@ import atexit import os.path import serial import socket +import time from chaosc.argparser_groups import create_arg_parser, finalize_arg_parser, add_chaosc_group @@ -46,11 +47,16 @@ class Platform(object): def connect(self): print "connect serial" 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: try: - self.serial_sock = serial.Serial(self.args.device, 115200, timeout=1) - except serial.serialutil.SerialException, e: + self.serial_sock.open() + except (serial.serialutil.SerialException, os.error), e: print "serial error", e + time.sleep(0.5) pass else: break