Skip to content

Commit

Permalink
fix get_basic_input() and get_digital_input()
Browse files Browse the repository at this point in the history
  • Loading branch information
anla-xu committed Nov 15, 2021
1 parent 21afccc commit 1ccd1f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pymycobot/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,17 @@ def _process_received(self, data, genre):
break
else:
return []

unique_data = [ProtocolCode.GET_BASIC_INPUT,
ProtocolCode.GET_DIGITAL_INPUT]
# compare send header and received header
cmd_id = data[idx + 3]
if cmd_id != genre:
return []
data_pos = idx + 4
if cmd_id in unique_data:
data_pos = idx + 5
data_len -= 1
else:
data_pos = idx + 4
valid_data = data[data_pos: data_pos + data_len]

# process valid data
Expand Down

0 comments on commit 1ccd1f8

Please sign in to comment.