-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
A TypeError occurs in the _send_frame function of the TxWorker class inside the slcan.py driver when attempting to format standard (non-extended) CAN frames (frame.extended == False). The issue arises because the format string %03X incorrectly attempts to process both the marker (string) and frame.id (integer), but %X expects only an integer.
Code Snippet
def _send_frame(self, frame):
marker = 'D' if frame.canfd else 'T'
dlc_len = CANFrame.datalength_to_dlc(len(frame.data))
line = '%s%X%s\r' % (('%c%08X' if frame.extended else 't%03X') % (marker, frame.id),
dlc_len,
binascii.b2a_hex(frame.data).decode('ascii'))
self._conn.write(line.encode('ascii'))
self._conn.flush()
Error Traceback
TypeError: %X format: an integer is required, not str
Proposed Fix
Adjust the formatting logic to separate the marker and frame.id when frame.extended == False, ensuring that only frame.id is passed to %03X.
Metadata
Metadata
Assignees
Labels
No labels