From 84eb89453189f30332bbf96df4f992560ce2e884 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sun, 1 Jul 2018 17:52:05 +0200 Subject: Write and read ascii to the serial line --- client/ur_fuzzy_alarm_clock.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ur_fuzzy_alarm_clock.py b/client/ur_fuzzy_alarm_clock.py index d6e5a1b..cb4e509 100755 --- a/client/ur_fuzzy_alarm_clock.py +++ b/client/ur_fuzzy_alarm_clock.py @@ -33,15 +33,15 @@ class FuzzyAlarmClock: self.mock = False def set_time_to_now(self): - now = 's'+datetime.datetime.now().strftime("%y%m%d%u%H%M%S") + now = b's'+datetime.datetime.now().strftime("%y%m%d%u%H%M%S").encode('ascii') self.serial.write(now) def read_alarms(self, n): data = [] self.serial.flushInput() - self.serial.write('p') + self.serial.write(b'p') for i in range(n): - data.append(self.serial.readline()) + data.append(self.serial.readline().decode('ascii')) for i in range(n): data[i] = data[i].split(' ')[2:-1] days = [] @@ -59,7 +59,7 @@ class FuzzyAlarmClock: s += "%02x" % (b0) for val in values[8:]: s += "%02x" % (val) - self.serial.write(s) + self.serial.write(s.encode('ascii')) class ModEdit(urwid.IntEdit): -- cgit v1.2.3