From 44a1fe738117c39780b0c84c4b99f5ae2483ff53 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 23 Jul 2020 00:54:00 +0200 Subject: [PATCH] fix serial --- raspberry/roberto/Serial.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/raspberry/roberto/Serial.py b/raspberry/roberto/Serial.py index 979c532..9114455 100644 --- a/raspberry/roberto/Serial.py +++ b/raspberry/roberto/Serial.py @@ -10,13 +10,13 @@ class Serial(object): try: self.serialport = serial.Serial(devicename, baudrate, timeout=3.0) self.serialport.flushInput() - self.serialport.write("\n") + self.serialport.write(b'\n') self.alive = True print("Arduino connection established..") except serial.SerialException as e: print('could not open port {!r}: {}\n'.format(devicename, e)) - except: - print("Failed to open serial device: " + self.serialport.name) +# except: +# print("Failed to open serial device: " + self.serialport.name) self.receiver_thread = threading.Thread(target=self.reader, name='rx') self.receiver_thread.daemon = True @@ -34,7 +34,8 @@ class Serial(object): if isinstance(buf, str): buf = bytes(buf, "utf8") self.serialport.flushInput() - self.serialport.write(buf+"\n") # or "\r\n" ? + self.serialport.write(buf) + #self.serialport.write(b'\n') # or "\r\n" ? print("sent " + str(buf)) except: print("Error writing to: " + self.serialport.name + " Data: " + str(buf)) @@ -46,5 +47,6 @@ class Serial(object): if data: print(data) except serial.SerialException: - self.alive = False - raise + pass + #self.alive = False + #raise