Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_rx for receive_own_messages for Kvaser #1908

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions can/interfaces/kvaser/canlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,15 @@ def __init__(
1,
)

# enable canMSG_LOCAL_TXACK flag in received messages

canIoCtlInit(
self._read_handle,
canstat.canIOCTL_SET_LOCAL_TXACK,
ctypes.byref(ctypes.c_byte(local_echo)),
1,
)

if self.single_handle:
log.debug("We don't require separate handles to the bus")
self._write_handle = self._read_handle
Expand Down Expand Up @@ -671,6 +680,7 @@ def _recv_internal(self, timeout=None):
is_remote_frame = bool(flags & canstat.canMSG_RTR)
is_error_frame = bool(flags & canstat.canMSG_ERROR_FRAME)
is_fd = bool(flags & canstat.canFDMSG_FDF)
is_rx = not bool(flags & canstat.canMSG_LOCAL_TXACK)
bitrate_switch = bool(flags & canstat.canFDMSG_BRS)
error_state_indicator = bool(flags & canstat.canFDMSG_ESI)
msg_timestamp = timestamp.value * TIMESTAMP_FACTOR
Expand All @@ -682,6 +692,7 @@ def _recv_internal(self, timeout=None):
is_error_frame=is_error_frame,
is_remote_frame=is_remote_frame,
is_fd=is_fd,
is_rx=is_rx,
bitrate_switch=bitrate_switch,
error_state_indicator=error_state_indicator,
channel=self.channel,
Expand Down
2 changes: 2 additions & 0 deletions can/interfaces/kvaser/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def CANSTATUS_SUCCESS(status):
canMSG_ERROR_FRAME = 0x0020
canMSG_TXACK = 0x0040
canMSG_TXRQ = 0x0080
canMSG_LOCAL_TXACK = 0x1000_0000

canFDMSG_FDF = 0x010000
canFDMSG_BRS = 0x020000
Expand Down Expand Up @@ -195,6 +196,7 @@ def CANSTATUS_SUCCESS(status):
canIOCTL_GET_USB_THROTTLE = 29
canIOCTL_SET_BUSON_TIME_AUTO_RESET = 30
canIOCTL_SET_LOCAL_TXECHO = 32
canIOCTL_SET_LOCAL_TXACK = 46
canIOCTL_PREFER_EXT = 1
canIOCTL_PREFER_STD = 2
canIOCTL_CLEAR_ERROR_COUNTERS = 5
Expand Down
Loading