Skip to content

Commit d7e8c08

Browse files
committed
fix bug
1 parent ce75531 commit d7e8c08

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pymycobot/myagv.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _read(self, command):
6363
elif len(datas) >= 2:
6464
data_len = struct.unpack("b", data)[0]
6565
# print("``````:",datas, command, k, data_len)
66-
if data_len == command[k-1] or command[k-1] == 29:
66+
if data_len == command[k-1] or command[-1] == 29:
6767
datas += data
6868
else:
6969
datas = b''
@@ -255,22 +255,30 @@ def stop(self):
255255
"""
256256
self._mesg(128, 128, 128)
257257

258-
def get_muc_info(self):
258+
def get_mcu_info(self):
259259
""""""
260260
datas = self._read([0xfe, 0xfe, 29])
261261
res = []
262-
for index in range(2, len(datas)):
262+
index = 2
263+
while index < len(datas) - 2:
263264
if index < 5:
264265
res.append(datas[index])
266+
index+=1
265267
elif index < 17 or index >= 20:
266268
res.append(self._decode_int16(datas[index:index+2]))
269+
index+=2
270+
267271
elif index == 17:
268-
byte_1 = bin(datas[index])
272+
byte_1 = bin(datas[index])[2:]
269273
while len(byte_1) != 6:
270274
byte_1 = "0"+byte_1
271275
res.append(byte_1)
276+
index+=1
277+
272278
elif index < 20:
273279
res.append(self._int2coord(datas[index]))
280+
index+=1
281+
274282
return res
275283

276284
def restore(self):

0 commit comments

Comments
 (0)