Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Fix bit-mask used for filtering CAN frames in elmbridge
Browse files Browse the repository at this point in the history
  • Loading branch information
sophokles73 authored and erikbosch committed Sep 12, 2023
1 parent 2445faf commit a5a6e29
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dbc2val/dbcfeederlib/elm2canbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,17 @@ def initelm(self, elm, canspeed, ack):
self.executecommand(elm, b'STFAC\r')
for canid in self.whitelist:
if canid < 2048:
cmd = "STFPA {:04x}, 7fff\r".format(canid)
# standard CAN frame IDs are 11 bits long,
# so we can safely ignore the 5 most significant bits
# of the 16-bit integer representing the ID
cmd = "STFPA {:04x}, 07ff\r".format(canid)
else:
cmd = "STFPA {:08x}, 1fffffff\r".format(canid)
# Extended CAN frame IDs are 29 bits long,
# so we can safely ignore the 3 MSBs of the
# 32-bit integer representing the ID.
# We can also ignore the 3 MSBs of the ID which contain
# the priority.
cmd = "STFPA {:08x}, 03ffffff\r".format(canid)
print("Exec "+str(cmd))
self.executecommand(elm, cmd.encode('utf-8'))

Expand Down

0 comments on commit a5a6e29

Please sign in to comment.