You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
A TypeError occurs in the
_send_frame
function of theTxWorker
class inside theslcan.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
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.
The text was updated successfully, but these errors were encountered: