From a777e0710ebb3f4ca4ef5ee64279138e471d17ef Mon Sep 17 00:00:00 2001 From: garindae Date: Tue, 24 Mar 2020 13:47:35 -0400 Subject: [PATCH 1/2] Fixed Binary translation for Protobuf response (as well as other messages) --- openxc/sources/usb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openxc/sources/usb.py b/openxc/sources/usb.py index ca4754b1..4e85680b 100644 --- a/openxc/sources/usb.py +++ b/openxc/sources/usb.py @@ -85,8 +85,8 @@ def _read(self, endpoint_address, timeout=None, read_size=DEFAULT_READ_REQUEST_SIZE): timeout = timeout or self.DEFAULT_READ_TIMEOUT try: - return str(self.device.read(0x80 + endpoint_address, - read_size, self.DEFAULT_INTERFACE_NUMBER, timeout), 'ISO-8859-1') + temp = self.device.read(0x80 + endpoint_address,read_size, self.DEFAULT_INTERFACE_NUMBER, timeout) + return str(temp, 'utf-8', 'ignore') # Formerly - Causes byte tranlation str(temp, 'ISO-8859-1') except (usb.core.USBError, AttributeError) as e: if e.backend_error_code in [self.LIBUSB0_TIMEOUT_CODE, self.LIBUSB1_TIMEOUT_CODE, self.OPENUSB_TIMEOUT_CODE]: # Timeout, it may just not be sending From 079c580e7292f8e76004963e32cf92bcd2322bbf Mon Sep 17 00:00:00 2001 From: garindae Date: Tue, 24 Mar 2020 14:20:43 -0400 Subject: [PATCH 2/2] renamed temp variable to something more appropriate --- openxc/sources/usb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openxc/sources/usb.py b/openxc/sources/usb.py index 4e85680b..aed7aac4 100644 --- a/openxc/sources/usb.py +++ b/openxc/sources/usb.py @@ -85,8 +85,8 @@ def _read(self, endpoint_address, timeout=None, read_size=DEFAULT_READ_REQUEST_SIZE): timeout = timeout or self.DEFAULT_READ_TIMEOUT try: - temp = self.device.read(0x80 + endpoint_address,read_size, self.DEFAULT_INTERFACE_NUMBER, timeout) - return str(temp, 'utf-8', 'ignore') # Formerly - Causes byte tranlation str(temp, 'ISO-8859-1') + raw_binary = self.device.read(0x80 + endpoint_address,read_size, self.DEFAULT_INTERFACE_NUMBER, timeout) + return str(raw_binary, 'utf-8', 'ignore') # Formerly - Causes byte tranlation str(temp, 'ISO-8859-1') except (usb.core.USBError, AttributeError) as e: if e.backend_error_code in [self.LIBUSB0_TIMEOUT_CODE, self.LIBUSB1_TIMEOUT_CODE, self.OPENUSB_TIMEOUT_CODE]: # Timeout, it may just not be sending