Skip to content

Commit

Permalink
Merge pull request #1 from skinnynerd/can-fixtypes
Browse files Browse the repository at this point in the history
Fix mismatched types with API for CAN protocol functions
  • Loading branch information
mariusgreuel committed Oct 19, 2023
2 parents f0ca077 + a91008f commit 2921b96
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dwfpy/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,20 +749,20 @@ def setup(
self.rate = rate
if inverted is not None:
self.inverted = inverted
api.dwf_digital_can_rx(self._device.handle, 0, None)
api.dwf_digital_can_rx(self._device.handle, ctypes.c_ubyte(0), 0)
api.dwf_digital_can_tx(self._device.handle, -1, 0, 0, 0, None)

def read(self) -> Tuple[bytes, int, int, int, int]:
"""Returns the received CAN frames since the last call."""
rx_buffer8 = (ctypes.c_char * 8)()
rx_buffer8 = (ctypes.c_ubyte * 8)()
frame_id, extended, remote, dlc, status = api.dwf_digital_can_rx(
self._device.handle, rx_buffer8, len(rx_buffer8)
)
return bytes(rx_buffer8)[:dlc], frame_id, extended, remote, status

def write(self, frame_id: int, extended: int, remote: int, buffer: bytes) -> None:
"""Performs a CAN transmission."""
tx_buffer8 = (ctypes.c_char * len(buffer)).from_buffer_copy(buffer)
tx_buffer8 = (ctypes.c_ubyte * len(buffer)).from_buffer_copy(buffer)
api.dwf_digital_can_tx(
self._device.handle, frame_id, extended, remote, len(tx_buffer8), tx_buffer8
)
Expand Down

0 comments on commit 2921b96

Please sign in to comment.