Skip to content

Commit 57e897d

Browse files
committed
add mercury debug api
1 parent d9f3853 commit 57e897d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

pymycobot/common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ class ProtocolCode(object):
180180
SET_JOINT_CURRENT = 0x90
181181
GET_JOINT_CURRENT = 0x91
182182
SET_CURRENT_STATE = 0x92
183+
GET_POS_OVER = 0x94
184+
CLEAR_ENCODERS_ERROR = 0x95
185+
GET_DOWN_ENCODERS = 0x96
183186

184187
# planning speed
185188
GET_PLAN_SPEED = 0xD0
@@ -424,6 +427,13 @@ def _process_received(self, data, genre, arm=6):
424427
for v in valid_data:
425428
res.append(v)
426429
return res
430+
elif data_len == 8 and arm == 14 and cmd_id == ProtocolCode.GET_DOWN_ENCODERS:
431+
i = 0
432+
while i < data_len:
433+
byte_value = int.from_bytes(valid_data[i:i+4], byteorder='big', signed=True)
434+
i+=4
435+
res.append(byte_value)
436+
return res
427437
for header_i in range(0, len(valid_data), 2):
428438
one = valid_data[header_i : header_i + 2]
429439
res.append(self._decode_int16(one))

pymycobot/mercury_api.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,17 @@ def pause(self, deceleration=False):
469469
if deceleration:
470470
return self._mesg(ProtocolCode.PAUSE, has_reply=True)
471471
else:
472-
return self._mesg(ProtocolCode.PAUSE, 1, has_reply=True)
472+
return self._mesg(ProtocolCode.PAUSE, 1, has_reply=True)
473+
474+
def get_modified_version(self):
475+
return self._mesg(ProtocolCode.ROBOT_VERSION, has_reply=True)
476+
477+
def get_pos_over(self):
478+
return self._mesg(ProtocolCode.GET_POS_OVER, has_reply=True)
479+
480+
def clear_encoders_error(self):
481+
return self._mesg(ProtocolCode.CLEAR_ENCODERS_ERROR)
482+
483+
def get_down_encoders(self):
484+
return self._mesg(ProtocolCode.GET_DOWN_ENCODERS, has_reply=True)
485+

0 commit comments

Comments
 (0)