From cc72abb370b0aa47ddb82dfe83e86d67673615aa Mon Sep 17 00:00:00 2001 From: Faisal Shah <37458679+faisal-shah@users.noreply.github.com> Date: Tue, 5 Dec 2023 02:40:07 -0600 Subject: [PATCH] Fix socketcand erroneously discarding frames (#1700) 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. --- can/interfaces/socketcand/socketcand.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/can/interfaces/socketcand/socketcand.py b/can/interfaces/socketcand/socketcand.py index 8b55eef3a..5a1f2570d 100644 --- a/can/interfaces/socketcand/socketcand.py +++ b/can/interfaces/socketcand/socketcand.py @@ -191,9 +191,7 @@ def _recv_internal(self, timeout): self.__message_buffer.append(parsed_can_message) buffer_view = buffer_view[end + 1 :] - self.__receive_buffer = self.__receive_buffer[ - chars_processed_successfully + 1 : - ] + self.__receive_buffer = self.__receive_buffer[chars_processed_successfully:] can_message = ( None if len(self.__message_buffer) == 0