Skip to content

Conversation

@yannpoupon
Copy link
Contributor

Fix a case where the function could be stuck in an infinite loop.
The case can be checked with the following code

from uds.uds_communications.TransportProtocols.Can.CanTp import CanTp, Config, CanTpAddressingTypes

Config.load_isotp_config(
    {
        "req_id": 0x7DF,
        "res_id": 0x7E8,
        "addressing_type": "NORMAL",
        "n_sa": 0x01,
        "n_ta": 0x02,
        "n_ae": 0x03,
        "m_type": "DIAGNOSTICS",
        "discard_neg_resp": True,
    }
)
can_tp = CanTp()
b = bytes([0x20])  # N_PCI = 2 when (0x20 & 0xF0) >> 4 = 2

can_tp .decode_isotp(received_data=b, use_external_snd_rcv_functions=True)

@yannpoupon yannpoupon force-pushed the fix/decode-isotp-stuck-in-infinite-loop branch from 01d6414 to 1f76f79 Compare August 6, 2025 07:30
@yannpoupon yannpoupon force-pushed the fix/decode-isotp-stuck-in-infinite-loop branch from 1f76f79 to 488552c Compare August 6, 2025 07:30
payloadLength = ((rxPdu[FIRST_FRAME_DL_INDEX_HIGH] & 0x0F) << 8) + rxPdu[FIRST_FRAME_DL_INDEX_LOW]
payloadPtr = self._max_pdu_length - 1
state = CanTpState.SEND_FLOW_CONTROL
elif N_PCI == CanTpMessageType.CONSECUTIVE_FRAME:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the two lines that have been added.

@yannpoupon yannpoupon requested a review from Pog3k August 6, 2025 07:31
@Pog3k Pog3k merged commit 1614ef2 into eclipse-kiso-testing:master Aug 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants