Skip to content

Commit

Permalink
single addr was better
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjhogan committed Nov 14, 2019
1 parent d063a18 commit f239b99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/uds.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ class InvalidSubFunctioneError(Exception):
}

class CanClient():
def __init__(self, can_send: Callable[[Tuple[int, bytes, int]], None], can_recv: Callable[[], List[Tuple[int, int, bytes, int]]], tx_addr: int, rx_addrs: int, bus: int, debug: bool=False):
def __init__(self, can_send: Callable[[Tuple[int, bytes, int]], None], can_recv: Callable[[], List[Tuple[int, int, bytes, int]]], tx_addr: int, rx_addr: int, bus: int, debug: bool=False):
self.tx = can_send
self.rx = can_recv
self.tx_addr = tx_addr
self.rx_addrs = rx_addrs
self.rx_addr = rx_addr
self.bus = bus
self.debug = debug

Expand All @@ -284,7 +284,7 @@ def recv(self, drain=False) -> List[bytes]:
if self.debug: print("CAN-RX: drain - {}".format(len(msgs)))
else:
for rx_addr, rx_ts, rx_data, rx_bus in msgs or []:
if rx_bus == self.bus and rx_addr in self.rx_addrs and len(rx_data) > 0:
if rx_bus == self.bus and rx_addr == self.rx_addr and len(rx_data) > 0:
rx_data = bytes(rx_data) # convert bytearray to bytes
if self.debug: print(f"CAN-RX: {hex(rx_addr)} - 0x{bytes.hex(rx_data)}")
msg_array.append(rx_data)
Expand Down Expand Up @@ -430,7 +430,7 @@ def __init__(self, panda, tx_addr: int, rx_addr: int=None, bus: int=0, timeout:
raise ValueError("invalid tx_addr: {}".format(tx_addr))
self.timeout = timeout
self.debug = debug
self._can_client = CanClient(panda.can_send, panda.can_recv, self.tx_addr, [self.rx_addr], self.bus, debug=self.debug)
self._can_client = CanClient(panda.can_send, panda.can_recv, self.tx_addr, self.rx_addr, self.bus, debug=self.debug)

# generic uds request
def _uds_request(self, service_type: SERVICE_TYPE, subfunction: int=None, data: bytes=None) -> bytes:
Expand Down

0 comments on commit f239b99

Please sign in to comment.