Skip to content

Commit

Permalink
Merge branch 'hotfix' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
cwichel committed Dec 30, 2021
2 parents ccd40f4 + c13f932 commit 1d63833
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
3 changes: 2 additions & 1 deletion embutils/utils/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def join(self) -> None:
"""
Wait until service is fully terminated.
"""
self._ended.wait()
while not self._ended.is_set():
time.sleep(self.TASK_DELAY_S)

def _service(self) -> None:
"""
Expand Down
21 changes: 4 additions & 17 deletions examples/stream_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,12 @@ def decode_stream(self, device: Device) -> Optional[AbstractSerialized]:
Defines how to the serial device will be read to decode the desired
serialized object.
"""
# Read a single byte and check...
recv = device.read(size=1)
# Read until COBS end (0x00)
recv = device.read_until(expected=b"\x00")
if recv is None:
raise ConnectionError(f"Connection error while reading from {device}")
if len(recv) == 0:
return None

# Are we reading contents?
byte = ord(recv)
if byte != 0x00:
# Yes -> Byte is not stuff... frame incoming
data = bytearray(recv)
recv = device.read_until(expected=b"\x00")
if recv is None:
raise ConnectionError(f"Connection error while reading from {device}")

# Process
data.extend(recv)
return SimplePacket.deserialize(data=COBS.decode(data=data))

# No -> Nothing to process
return None
# Process
return self._dtype.deserialize(data=COBS.decode(data=bytearray(recv)))

0 comments on commit 1d63833

Please sign in to comment.