From 2e6f71249e208abfca5585019f21c51d7d29ecc8 Mon Sep 17 00:00:00 2001 From: Peter Stewart Date: Sat, 28 Sep 2024 01:24:06 +0000 Subject: [PATCH 1/2] Fix Frequent overflow issues #68 on LabelManager 280 --- src/labelle/lib/devices/dymo_labeler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/labelle/lib/devices/dymo_labeler.py b/src/labelle/lib/devices/dymo_labeler.py index 066309f6..7df1ef5c 100755 --- a/src/labelle/lib/devices/dymo_labeler.py +++ b/src/labelle/lib/devices/dymo_labeler.py @@ -98,7 +98,10 @@ def _send_command(self): # Send a status request cmdBin = array.array("B", [ESC, ord("A")]) cmdBin.tofile(self._devout) - rspBin = self._devin.read(8) + # Increase buffer size to 16 bytes to prevent overflow + # on LabelManager 280 + # https://libusb.sourceforge.io/api-1.0/libusb_packetoverflow.html + rspBin = self._devin.read(16) _ = array.array("B", rspBin).tolist() # Ok, we got a response. Now we can send a chunk of data @@ -129,7 +132,7 @@ def _send_command(self): if not self._response: return None self._response = False - responseBin = self._devin.read(8) + responseBin = self._devin.read(16) response = array.array("B", responseBin).tolist() return response From d952897579e4a6b782055918e944ae1e82928bac Mon Sep 17 00:00:00 2001 From: Peter Stewart Date: Sun, 29 Sep 2024 01:35:45 +0000 Subject: [PATCH 2/2] Increase read buffer to 512 as suggested by @maresb --- src/labelle/lib/devices/dymo_labeler.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/labelle/lib/devices/dymo_labeler.py b/src/labelle/lib/devices/dymo_labeler.py index 7df1ef5c..e57bcb18 100755 --- a/src/labelle/lib/devices/dymo_labeler.py +++ b/src/labelle/lib/devices/dymo_labeler.py @@ -98,10 +98,7 @@ def _send_command(self): # Send a status request cmdBin = array.array("B", [ESC, ord("A")]) cmdBin.tofile(self._devout) - # Increase buffer size to 16 bytes to prevent overflow - # on LabelManager 280 - # https://libusb.sourceforge.io/api-1.0/libusb_packetoverflow.html - rspBin = self._devin.read(16) + rspBin = self._devin.read(512) _ = array.array("B", rspBin).tolist() # Ok, we got a response. Now we can send a chunk of data @@ -132,7 +129,7 @@ def _send_command(self): if not self._response: return None self._response = False - responseBin = self._devin.read(16) + responseBin = self._devin.read(512) response = array.array("B", responseBin).tolist() return response