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

Fix socketcand erroneously discarding frames #1700

Conversation

faisal-shah
Copy link
Contributor

@faisal-shah faisal-shah commented Nov 30, 2023

The __receive_buffer is always truncated by [chars_processed_successfully + 1:]. When a partial socketcand frame is received, chars_processed_successfully is 0, and this results in 1 character being discarded. This will be the '<' character, and thus when the rest of the frame is received, it will be treated as a bad frame, and discarded.

I double checked wireshark to make sure the bytestream wasn't corrupted, or there wasn't some weird latency related issue (which shouldn't make a difference anyways..). It was all good.

I also instrumented the code a bit to catch it in the act in the while loop progressively processing the buffer_view buffer. Below is a log which shows it happening (scroll to the bottom):

DEBUG:can.interfaces.socketcand.socketcand:Received Ascii Message: < frame 0B0B0003 1701324984.734563 0000000000000000 >< frame 0B0B0004 1701324984.734655 0000000000000000 >< frame 0B0B0009 1701324984.734657 0000000000000000 >< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0003 1701324984.734563 0000000000000000 >< frame 0B0B0004 1701324984.734655 0000000000000000 >< frame 0B0B0009 1701324984.734657 0000000000000000 >< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0003 1701324984.734563 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B0004 1701324984.734655 0000000000000000 >< frame 0B0B0009 1701324984.734657 0000000000000000 >< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0004 1701324984.734655 0000000000000000 >< frame 0B0B0009 1701324984.734657 0000000000000000 >< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0004 1701324984.734655 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B0009 1701324984.734657 0000000000000000 >< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0009 1701324984.734657 0000000000000000 >< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0009 1701324984.734657 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0066 1701324984.734661 0000000000000000 >< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0066 1701324984.734661 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0067 1701324984.734664 0000000000000000 >< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0067 1701324984.734664 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0072 1701324984.734665 0000000000000000 >< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0072 1701324984.734665 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B0073 1701324984.734666 0000000000000000 >< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B0073 1701324984.734666 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00C8 1701324984.734669 0000000000000000 >< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00C8 1701324984.734669 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00C9 1701324984.734672 0000000000000000 >< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00C9 1701324984.734672 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00CA 1701324984.734674 0000000002330000 >< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00CA 1701324984.734674 0000000002330000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00CB 1701324984.734676 0000000000000000 >< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00CB 1701324984.734676 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00CC 1701324984.734677 0333044400000000 >< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00CC 1701324984.734677 0333044400000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00CD 1701324984.734678 024402350135022B >< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00CD 1701324984.734678 024402350135022B >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00CE 1701324984.734681 0000000000000000 >< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00CE 1701324984.734681 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00CF 1701324984.734683 0000000000000000 >< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00CF 1701324984.734683 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00D0 1701324984.734685 0000000000000000 >< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00D0 1701324984.734685 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00D1 1701324984.734688 0000000000000000 >< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00D1 1701324984.734688 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00D2 1701324984.734690 0000000000000000 >< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00D2 1701324984.734690 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00D3 1701324984.734694 0000000000000000 >< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:single_message=< frame 0B0B00D3 1701324984.734694 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:after trunc buffer_view=< frame 0B0B00D4
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view=< frame 0B0B00D4
WARNING:can.interfaces.socketcand.socketcand:Got incomplete message => waiting for more data
DEBUG:can.interfaces.socketcand.socketcand:Received Ascii Message: 1701324984.734696 0000000000000000 >
DEBUG:can.interfaces.socketcand.socketcand:start buffer_view= frame 0B0B00D4 1701324984.734696 0000000000000000 >
WARNING:can.interfaces.socketcand.socketcand:Bad data: No opening < found => discarding entire buffer ' frame 0B0B00D4 1701324984.734696 0000000000000000 >'

The __receive_buffer is always truncated by
[chars_processed_successfully + 1:].  When a partial socketcand frame is
received, chars_processed_successfully is 0, and this results in 1
character being discarded. This will be the '<' character, and thus when
the rest of the frame is received, it will be treated as a bad frame,
and discarded.
@faisal-shah faisal-shah force-pushed the fix/partial-frame-discarded-erroneously branch from 97883f5 to 9a8dbd6 Compare November 30, 2023 13:15
Copy link
Collaborator

@lumagi lumagi left a comment

Choose a reason for hiding this comment

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

Yes certainly, that's a good catch! Too bad the class doesn't have any tests. This probably would have been caught. I will try to write some at the next opportunity.

@zariiii9003 zariiii9003 merged commit cc72abb into hardbyte:main Dec 5, 2023
30 checks 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.

None yet

3 participants