Skip to content

Commit d6f7662

Browse files
committed
fix bug
1 parent f6a1a0a commit d6f7662

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

pymycobot/mercury.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,28 @@ def _mesg(self, genre, *args, **kwargs):
143143
elif genre in [ProtocolCode.COBOTX_GET_ANGLE, ProtocolCode.COBOTX_GET_SOLUTION_ANGLES]:
144144
return self._int2angle(res[0])
145145
elif genre == ProtocolCode.MERCURY_ROBOT_STATUS:
146-
i = 9
147-
for i in range(9, len(res)):
148-
if res[i] != 0:
149-
data = bin(res[i])[2:]
150-
res[i] = []
151-
while len(data) != 16:
152-
data = "0"+data
153-
for j in range(16):
154-
if data[j] != "0":
155-
res[i].append(15-j)
156-
return res
146+
if self._serial_port.port == "/dev/ttyTHS0":
147+
i = 9
148+
for i in range(9, len(res)):
149+
if res[i] != 0:
150+
data = bin(res[i])[2:]
151+
res[i] = []
152+
while len(data) != 16:
153+
data = "0"+data
154+
for j in range(16):
155+
if data[j] != "0":
156+
res[i].append(15-j)
157+
return res
158+
else:
159+
for i in range(10, len(res)):
160+
if res[i] != 0:
161+
data = bin(res[i])[2:]
162+
res[i] = []
163+
while len(data) != 16:
164+
data = "0"+data
165+
for j in range(16):
166+
if data[j] != "0":
167+
res[i].append(15-j)
157168
else:
158169
return res
159170
return None

0 commit comments

Comments
 (0)