Skip to content

Commit

Permalink
Added additional logic to process strange read strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce Bixler committed Aug 19, 2024
1 parent cf89f1f commit d7c8ec2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions socs/agents/hwp_pid/drivers/pid_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand All @@ -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):
Expand Down

0 comments on commit d7c8ec2

Please sign in to comment.