From 8a3e2ad91e4ae48476408c889e649db0426818a5 Mon Sep 17 00:00:00 2001 From: Gadi Rotenberg Date: Wed, 16 Jun 2021 12:33:38 +0300 Subject: [PATCH] Fixed buffer allocation --- apps/nametags/nameservice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/nametags/nameservice.py b/apps/nametags/nameservice.py index eb35085..4a46aa4 100644 --- a/apps/nametags/nameservice.py +++ b/apps/nametags/nameservice.py @@ -19,7 +19,6 @@ class NameService(Service): uuid = StandardUUID(0xfeef) - _disp_rx = StreamIn(uuid=StandardUUID(0xfeee), timeout=1.0, buffer_size=8192) def __init__(self): super().__init__() @@ -30,8 +29,12 @@ def __init__(self): self._offset = 0 self._bufsize = 0 self._ledstate = False + self._disp_rx = None def update(self): + if self._disp_rx is None: + self._disp_rx = StreamIn(uuid=StandardUUID(0xfeee), timeout=1.0, buffer_size=8192) + while self._disp_rx.in_waiting > 0: if self._bufsize == 0: value = int.from_bytes(self._disp_rx.read(1), 'little')