Skip to content

Commit 220229c

Browse files
BaldwinBaldwin
authored andcommitted
Minor bug fixes
1 parent f89ea30 commit 220229c

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

openxc/controllers/usb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ def write_bytes(self, data):
2727
self.out_endpoint)
2828
return 0
2929
else:
30-
ret = self.out_endpoint.write(data)
31-
return ret
30+
return self.out_endpoint.write(data)
3231

3332
def _send_complex_request(self, request):
3433
"""Send a request via the USB control request endpoint, rather than as a

openxc/sources/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def run(self):
143143
message from the buffer of bytes. When a message is parsed, passes it
144144
off to the callback if one is set.
145145
"""
146-
message_buffer = b""
146+
message_buffer = ""
147147
while self.running:
148148
try:
149-
message_buffer += self.source.read_logs().encode('utf-8')
149+
message_buffer += self.source.read_logs()
150150
except DataSourceError as e:
151151
if self.running:
152152
LOG.warn("Can't read logs from data source -- stopping: %s", e)
@@ -156,7 +156,7 @@ def run(self):
156156
break
157157

158158
while True:
159-
if b"\x00" not in message_buffer:
159+
if "\x00" not in message_buffer:
160160
break
161161
record, _, remainder = message_buffer.partition(b"\x00")
162162
self.record(record)
@@ -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 = ""
195195
try:
196196
payload = self.read()
197197
except DataSourceError as e:

openxc/sources/usb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _read(self, endpoint_address, timeout=None,
8686
timeout = timeout or self.DEFAULT_READ_TIMEOUT
8787
try:
8888
return str(self.device.read(0x80 + endpoint_address,
89-
read_size, self.DEFAULT_INTERFACE_NUMBER, timeout))
89+
read_size, self.DEFAULT_INTERFACE_NUMBER, timeout), 'ISO-8859-1')
9090
except (usb.core.USBError, AttributeError) as e:
9191
if e.backend_error_code in [self.LIBUSB0_TIMEOUT_CODE, self.LIBUSB1_TIMEOUT_CODE, self.OPENUSB_TIMEOUT_CODE]:
9292
# Timeout, it may just not be sending

0 commit comments

Comments
 (0)