diff --git a/platypush/plugins/serial/__init__.py b/platypush/plugins/serial/__init__.py index 9e3a34e3..99804111 100644 --- a/platypush/plugins/serial/__init__.py +++ b/platypush/plugins/serial/__init__.py @@ -36,8 +36,7 @@ class SerialPlugin(SensorPlugin): self.serial_lock = threading.Lock() self.last_measurement = None - @staticmethod - def _read_json(serial_port): + def _read_json(self, serial_port): n_brackets = 0 is_escaped_ch = False parse_start = False @@ -48,6 +47,12 @@ class SerialPlugin(SensorPlugin): if not ch: break + try: + ch = ch.decode() + except Exception as e: + self.logger.warning('Could not decode character: {}'.format(str(e))) + output = bytes() + if ch.decode() == '{' and not is_escaped_ch: parse_start = True n_brackets += 1