Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing multi-part (TP DT) messages can cause data corruption #72

Open
pmoosman opened this issue Jan 31, 2024 · 0 comments
Open

Missing multi-part (TP DT) messages can cause data corruption #72

pmoosman opened this issue Jan 31, 2024 · 0 comments

Comments

@pmoosman
Copy link

In j1939_21.py the method _process_tp_dt() accepts out-of-sequence packets.

We had a case where the last X packets of a multi-part message were lost and the first Y packets of the next multi-part message were lost. The j1939_21.py code combined those to multi-part messages creating corrupt output.

Example, consider a multi-part message that is made up of 6 packets.

<packet #1 of 6 received of message A>
<packet #2 of 6 received of message A>

<lost packets 3-6 of message A>

<lost packet 1 of message B>

<packet #2 of 6 of message B received> - _process_tp_dt() appends this packet message A
<packet #3 of 6 of message B received> - _process_tp_dt() appends this packet message A
<packet #4 of 6 of message B received> - _process_tp_dt() appends this packet message A

At this point _process_tp_dt() has received 6 packets and outputs a corrupt result.

I propose we add code to j1939_21.py to check the packet sequence number. If _process_tp_dt() receives any out-of-order packet sequence numbers, it should reject them and reset the _rcv_buffer.

pmoosman added a commit to pmoosman/python-can-j1939 that referenced this issue Jan 31, 2024
…nH87#72).

Added a check to j1939_21 for out-of-sequence packets. If an
out-of-sequence packet is received, the packet and the current
buffer is discarded.
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

No branches or pull requests

1 participant