Skip to content

Commit

Permalink
Update frame_fields.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mdabrowski1990 committed Oct 12, 2024
1 parent 9e6b856 commit 1c266a1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions uds/can/frame_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class CanIdHandler:
MAX_EXTENDED_VALUE: int = (1 << 29) - 1
"""Maximum value of Extended (29-bit) CAN ID."""

J1339_ADDRESSING_MASK: int = 0x3ff0000
"""CAN ID mask with bits enforced by SAE J1939 set to 1."""
ADDRESSING_MASK: int = 0x3ff0000
"""CAN ID mask for bits enforced by SAE J1939 (Normal Fixed of Mixed 29bit addressing formats)."""
NORMAL_FIXED_PHYSICAL_ADDRESSING_MASKED_VALUE: int = 0xDA0000
"""Masked value of physically addressed CAN ID in Normal Fixed Addressing format."""
NORMAL_FIXED_FUNCTIONAL_ADDRESSING_MASKED_VALUE: int = 0xDB0000
Expand Down Expand Up @@ -129,7 +129,7 @@ def decode_normal_fixed_addressed_can_id(cls, can_id: int) -> CanIdAIAlias:
raise ValueError("Provided CAN ID value is out of range.")
target_address = (can_id >> 8) & 0xFF
source_address = can_id & 0xFF
can_id_masked_value = can_id & cls.J1339_ADDRESSING_MASK
can_id_masked_value = can_id & cls.ADDRESSING_MASK
if can_id_masked_value == cls.NORMAL_FIXED_PHYSICAL_ADDRESSING_MASKED_VALUE:
return cls.CanIdAIAlias(addressing_type=AddressingType.PHYSICAL,
target_address=target_address,
Expand Down Expand Up @@ -159,7 +159,7 @@ def decode_mixed_addressed_29bit_can_id(cls, can_id: int) -> CanIdAIAlias:
raise ValueError("Provided CAN ID value is out of range.")
target_address = (can_id >> 8) & 0xFF
source_address = can_id & 0xFF
can_id_masked_value = can_id & cls.J1339_ADDRESSING_MASK
can_id_masked_value = can_id & cls.ADDRESSING_MASK
if can_id_masked_value == cls.MIXED_29BIT_PHYSICAL_ADDRESSING_MASKED_VALUE:
return cls.CanIdAIAlias(addressing_type=AddressingType.PHYSICAL,
target_address=target_address,
Expand Down Expand Up @@ -302,7 +302,7 @@ def is_normal_fixed_addressed_can_id(cls,
"""
if addressing_type is not None:
addressing_type = AddressingType.validate_member(addressing_type)
masked_can_id = can_id & cls.J1339_ADDRESSING_MASK
masked_can_id = can_id & cls.ADDRESSING_MASK
if (masked_can_id == cls.NORMAL_FIXED_PHYSICAL_ADDRESSING_MASKED_VALUE
and addressing_type in {None, AddressingType.PHYSICAL}):
return True
Expand Down Expand Up @@ -349,7 +349,7 @@ def is_mixed_29bit_addressed_can_id(cls,
"""
if addressing_type is not None:
addressing_type = AddressingType.validate_member(addressing_type)
masked_can_id = can_id & cls.J1339_ADDRESSING_MASK
masked_can_id = can_id & cls.ADDRESSING_MASK
if (masked_can_id == cls.MIXED_29BIT_PHYSICAL_ADDRESSING_MASKED_VALUE
and addressing_type in {None, AddressingType.PHYSICAL}):
return True
Expand Down

0 comments on commit 1c266a1

Please sign in to comment.