From e0ce29097871dab7b25d37b42e4a0e6ca69b8f8e Mon Sep 17 00:00:00 2001 From: Tawn Kramer Date: Mon, 24 Aug 2020 19:41:41 -0700 Subject: [PATCH 1/3] recover last good part of partial packet --- gym_donkeycar/core/client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gym_donkeycar/core/client.py b/gym_donkeycar/core/client.py index 43e8d2ffb..9169444ab 100755 --- a/gym_donkeycar/core/client.py +++ b/gym_donkeycar/core/client.py @@ -134,6 +134,13 @@ def proc_msg(self, sock): if partial[0][0] == "{": assembled_packet = "".join(partial) assembled_packet = replace_float_notation(assembled_packet) + second_open = assembled_packet.find('{', 1) + if second_open != -1: + # hmm what to do? We have a partial packet. Trimming just + # the good part and discarding the rest. + logger.warn("got partial packet:" + assembled_packet[:10]) + assembled_packet = assembled_packet[second_open:] + try: j = json.loads(assembled_packet) self.on_msg_recv(j) From ad5f3c4c85cda2f5195a1b466b175197da846884 Mon Sep 17 00:00:00 2001 From: Tawn Kramer Date: Mon, 24 Aug 2020 19:51:29 -0700 Subject: [PATCH 2/3] little more of the partial packet --- gym_donkeycar/core/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gym_donkeycar/core/client.py b/gym_donkeycar/core/client.py index 9169444ab..caecf2c7d 100755 --- a/gym_donkeycar/core/client.py +++ b/gym_donkeycar/core/client.py @@ -138,7 +138,7 @@ def proc_msg(self, sock): if second_open != -1: # hmm what to do? We have a partial packet. Trimming just # the good part and discarding the rest. - logger.warn("got partial packet:" + assembled_packet[:10]) + logger.warn("got partial packet:" + assembled_packet[:20]) assembled_packet = assembled_packet[second_open:] try: From 34cdce006bd0efaf78cb69d18ebebec6608b4f78 Mon Sep 17 00:00:00 2001 From: Tawn Kramer Date: Mon, 24 Aug 2020 20:19:58 -0700 Subject: [PATCH 3/3] better recovery --- gym_donkeycar/core/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gym_donkeycar/core/client.py b/gym_donkeycar/core/client.py index caecf2c7d..da08ae91b 100755 --- a/gym_donkeycar/core/client.py +++ b/gym_donkeycar/core/client.py @@ -134,7 +134,7 @@ def proc_msg(self, sock): if partial[0][0] == "{": assembled_packet = "".join(partial) assembled_packet = replace_float_notation(assembled_packet) - second_open = assembled_packet.find('{', 1) + second_open = assembled_packet.find('{"msg', 1) if second_open != -1: # hmm what to do? We have a partial packet. Trimming just # the good part and discarding the rest.