From 879ba00137010ab038a2918cec2e0db8187c3606 Mon Sep 17 00:00:00 2001 From: dj2ls Date: Fri, 18 Feb 2022 10:04:00 +0100 Subject: [PATCH] search for chunk from end according to the last commit we are now searching for data chunks from the end of the existing data. If a data chunk exists twice or more in our already received data, only the last one will be replaced --- tnc/data_handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tnc/data_handler.py b/tnc/data_handler.py index 93beeac0..e372aca3 100644 --- a/tnc/data_handler.py +++ b/tnc/data_handler.py @@ -342,8 +342,9 @@ class DATA(): search_position = len(static.RX_FRAME_BUFFER)-search_area - # fin dposition of data. returns -1 if nothing found in area else >= 0 - get_position = static.RX_FRAME_BUFFER[search_position:].find(temp_burst_buffer) + # find position of data. returns -1 if nothing found in area else >= 0 + # we are beginning from the end, so if data exists twice or more, only the last one should be replaced + get_position = static.RX_FRAME_BUFFER[search_position:].rfind(temp_burst_buffer) # if we find data, replace it at this position with the new data and strip it if get_position >= 0: static.RX_FRAME_BUFFER = static.RX_FRAME_BUFFER[:search_position + get_position]