Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openxc/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ResponseReceiver(object):
of ResponseReceivers as they arrive.
"""

COMMAND_RESPONSE_TIMEOUT_S = .5
COMMAND_RESPONSE_TIMEOUT_S = 0.5

def __init__(self, queue, request, quit_after_first=True):
"""Construct a new ResponseReceiver.
Expand Down
7 changes: 4 additions & 3 deletions openxc/sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def run(self):
message from the buffer of bytes. When a message is parsed, passes it
off to the callback if one is set.
"""
message_buffer = b""
message_buffer = ""
while self.running:
try:
message_buffer += self.source.read_logs()
Expand All @@ -158,7 +158,7 @@ def run(self):
while True:
if "\x00" not in message_buffer:
break
record, _, remainder = message_buffer.partition(b"\x00")
record, _, remainder = message_buffer.partition("\x00")
self.record(record)
message_buffer = remainder

Expand Down Expand Up @@ -191,6 +191,7 @@ def run(self):
off to the callback if one is set.
"""
while self.running:
payload = ""
try:
payload = self.read()
except DataSourceError as e:
Expand Down Expand Up @@ -223,7 +224,7 @@ def run(self):
self._receive_command_response(message)

def _receive_command_response(self, message):
# TODO the controller/source are getting a litlte mixed up since the
# TODO the controller/source are getting a little mixed up since the
# controller now needs to receive responses from the soruce side, maybe
# just mix them again. the only exception to being both is a trace
# source, and we can just leave the controller methods on that
Expand Down
8 changes: 5 additions & 3 deletions openxc/sources/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class UsbDataSource(BytestreamDataSource):
# throughput if the READ_REQUEST_SIZE is higher, but this delay has to be
# low enough that a single request isn't held back too long.
DEFAULT_READ_TIMEOUT = 200
LIBUSB0_TIMEOUT_CODE = -116
LIBUSB1_TIMEOUT_CODE = -7
OPENUSB_TIMEOUT_CODE = -62

DEFAULT_INTERFACE_NUMBER = 0
VEHICLE_DATA_IN_ENDPOINT = 2
Expand Down Expand Up @@ -83,10 +86,9 @@ def _read(self, endpoint_address, timeout=None,
timeout = timeout or self.DEFAULT_READ_TIMEOUT
try:
return str(self.device.read(0x80 + endpoint_address,
read_size, self.DEFAULT_INTERFACE_NUMBER, timeout
),'utf-8')
read_size, self.DEFAULT_INTERFACE_NUMBER, timeout), 'ISO-8859-1')
except (usb.core.USBError, AttributeError) as e:
if e.errno == 110:
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
return ""
raise DataSourceError("USB device couldn't be read", e)
3 changes: 2 additions & 1 deletion openxc/tools/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def parse_options():
dest="host")
parser.add_argument("--port", action="store", default=80,
dest="port")
parser.set_defaults(format="json")
return parser.parse_args()


Expand Down Expand Up @@ -182,4 +183,4 @@ def main():
else:
sys.exit("%s requires a signal name, message ID or filename" % arguments.command)
else:
print(("Unrecognized command \"%s\"" % arguments.command))
print(("Unrecognized command \"%s\"" % arguments.command))
1 change: 1 addition & 0 deletions openxc/tools/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def parse_options():
parser.add_argument("--pid", help="Parameter ID (e.g. for Mode 1 request")
parser.add_argument("--payload", help="A byte array as a hex string to send as payload, e.g. 0x123")
parser.add_argument("--frequency", help="Frequency (Hz) to repeat this request. If omitted or 0, it will be a one-time request.")
parser.set_defaults(format="json")

return parser.parse_args()

Expand Down
1 change: 0 additions & 1 deletion openxc/tools/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def main():
arguments = parse_options()

transcoder = GPXTranscoder()

source = TraceDataSource(transcoder.receive, filename=arguments.trace_file,
loop=False, realtime=False)
source.start()
Expand Down