Skip to content

Commit

Permalink
Updated a missing element of the 18-bit PGN work. The PGN
Browse files Browse the repository at this point in the history
for a D400 (Security) PGN was not being truncated to 18 bits which
would cause the protocol engine to not recognize it as a security
challenge.
  • Loading branch information
Miller Lowe committed Jul 12, 2022
1 parent 2de1391 commit d76df50
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions j1939/pgn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ def is_pdu2(self):
@property
def is_destination_specific(self):
result = self.is_pdu1
logger.debug("PGN is_destination_specific {:04x}: {}".format(self.value, result))
logger.debug(f"PGN is_destination_specific {self.value:04x}: {result}")
return result

@property
def value(self):
_pgn_flags_byte = ((self.reserved_flag << 1) + self.data_page_flag)
return int("%.2x%.2x%.2x" % (_pgn_flags_byte, self.pdu_format, self.pdu_specific), 16)
#
# Be sure to truncate the PGN at 18 bits
#
result = int("%.2x%.2x%.2x" % (_pgn_flags_byte & 0x03, self.pdu_format, self.pdu_specific), 16)
logger.debug(f"value-result = {result:06x}")
return result

@value.setter
def value(self, value):
Expand Down

0 comments on commit d76df50

Please sign in to comment.