Skip to content

Commit f89ea30

Browse files
BaldwinBaldwin
authored andcommitted
Minor tweaks to accomodate C5 platform
1 parent 099b266 commit f89ea30

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

openxc/sources/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def run(self):
146146
message_buffer = b""
147147
while self.running:
148148
try:
149-
message_buffer += self.source.read_logs()
149+
message_buffer += self.source.read_logs().encode('utf-8')
150150
except DataSourceError as e:
151151
if self.running:
152152
LOG.warn("Can't read logs from data source -- stopping: %s", e)
@@ -191,7 +191,7 @@ def run(self):
191191
off to the callback if one is set.
192192
"""
193193
while self.running:
194-
payload = b""
194+
#payload = b""
195195
try:
196196
payload = self.read()
197197
except DataSourceError as e:
@@ -224,7 +224,7 @@ def run(self):
224224
self._receive_command_response(message)
225225

226226
def _receive_command_response(self, message):
227-
# TODO the controller/source are getting a litlte mixed up since the
227+
# TODO the controller/source are getting a little mixed up since the
228228
# controller now needs to receive responses from the soruce side, maybe
229229
# just mix them again. the only exception to being both is a trace
230230
# source, and we can just leave the controller methods on that

openxc/sources/usb.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class UsbDataSource(BytestreamDataSource):
2222
# throughput if the READ_REQUEST_SIZE is higher, but this delay has to be
2323
# low enough that a single request isn't held back too long.
2424
DEFAULT_READ_TIMEOUT = 200
25+
LIBUSB0_TIMEOUT_CODE = -116
26+
LIBUSB1_TIMEOUT_CODE = -7
27+
OPENUSB_TIMEOUT_CODE = -62
2528

2629
DEFAULT_INTERFACE_NUMBER = 0
2730
VEHICLE_DATA_IN_ENDPOINT = 2
@@ -83,14 +86,9 @@ def _read(self, endpoint_address, timeout=None,
8386
timeout = timeout or self.DEFAULT_READ_TIMEOUT
8487
try:
8588
return str(self.device.read(0x80 + endpoint_address,
86-
read_size, self.DEFAULT_INTERFACE_NUMBER, timeout
87-
),'utf-8')
89+
read_size, self.DEFAULT_INTERFACE_NUMBER, timeout))
8890
except (usb.core.USBError, AttributeError) as e:
89-
# timeout error codes:
90-
# libusb0: -116
91-
# libusb1: -7
92-
# openusb: -62
93-
if e.backend_error_code in [-116, -7, -62]:
91+
if e.backend_error_code in [self.LIBUSB0_TIMEOUT_CODE, self.LIBUSB1_TIMEOUT_CODE, self.OPENUSB_TIMEOUT_CODE]:
9492
# Timeout, it may just not be sending
95-
return b""
93+
return ""
9694
raise DataSourceError("USB device couldn't be read", e)

0 commit comments

Comments
 (0)