From d7c8ec211ee60c666893c4fe2d41b560c2173c02 Mon Sep 17 00:00:00 2001 From: Bryce Bixler Date: Mon, 19 Aug 2024 20:09:35 +0000 Subject: [PATCH] Added additional logic to process strange read strings --- socs/agents/hwp_pid/drivers/pid_controller.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/socs/agents/hwp_pid/drivers/pid_controller.py b/socs/agents/hwp_pid/drivers/pid_controller.py index 8e82ff31d..c814e8a2f 100644 --- a/socs/agents/hwp_pid/drivers/pid_controller.py +++ b/socs/agents/hwp_pid/drivers/pid_controller.py @@ -524,7 +524,12 @@ def _decode_read(string): """ end_string = string.split('\r')[-1] - read_type = end_string[1:3] + if len(end_string) == 9: + read_type = end_string[1:3] + elif len(end_string) == 8: + read_type = '0' + end_string[1:2] + else: + return DecodedResponse(msg_type='error', msg='Unrecognized Read Length') # Decode target if read_type == '01': target = float(int(end_string[4:], 16) / 1000.) @@ -536,7 +541,7 @@ def _decode_read(string): else: return DecodedResponse(msg_type='read', msg='Direction = Forward', measure=0) else: - return DecodedResponse(msg_type='error', msg='Unrecognized Read') + return DecodedResponse(msg_type='error', msg='Unrecognized Read Type') @staticmethod def _decode_write(string):