Skip to content

Commit 1ccd1f8

Browse files
committed
fix get_basic_input() and get_digital_input()
1 parent 21afccc commit 1ccd1f8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pymycobot/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,17 @@ def _process_received(self, data, genre):
145145
break
146146
else:
147147
return []
148-
148+
unique_data = [ProtocolCode.GET_BASIC_INPUT,
149+
ProtocolCode.GET_DIGITAL_INPUT]
149150
# compare send header and received header
150151
cmd_id = data[idx + 3]
151152
if cmd_id != genre:
152153
return []
153-
data_pos = idx + 4
154+
if cmd_id in unique_data:
155+
data_pos = idx + 5
156+
data_len -= 1
157+
else:
158+
data_pos = idx + 4
154159
valid_data = data[data_pos: data_pos + data_len]
155160

156161
# process valid data

0 commit comments

Comments
 (0)