@@ -229,16 +229,18 @@ class ProtocolCode(object):
229229 GET_ATOM_LED_COLOR = 0x6a
230230 SET_ATOM_PIN_STATUS = 0x61
231231 GET_ATOM_PIN_STATUS = 0x62
232- SET_MASTER_PIN_STATUS = 0x61
233- GET_MASTER_PIN_STATUS = 0x62
234- SET_AUXILIARY_PIN_STATUS = 0x63
235- GET_AUXILIARY_PIN_STATUS = 0x64
232+ SET_MASTER_PIN_STATUS = 0x65
233+ GET_MASTER_PIN_STATUS = 0x66
234+ SET_AUXILIARY_PIN_STATUS = 0xa0
235+ GET_AUXILIARY_PIN_STATUS = 0xa1
236236 SET_SERVO_MOTOR_CLOCKWISE = 0x73
237237 GET_SERVO_MOTOR_CLOCKWISE = 0Xea
238238 SET_SERVO_MOTOR_COUNTER_CLOCKWISE = 0x74
239239 GET_SERVO_MOTOR_COUNTER_CLOCKWISE = 0xeb
240240 SET_SERVO_MOTOR_CONFIG = 0x52
241241 GET_SERVO_MOTOR_CONFIG = 0x53
242+ CLEAR_RECV_QUEUE = 0x19
243+ GET_RECV_QUEUE_LENGTH = 0x08
242244 GET_BASE_COORDS = 0xF0
243245 BASE_TO_SINGLE_COORDS = 0xF1
244246 COLLISION = 0xF2
@@ -249,6 +251,9 @@ class ProtocolCode(object):
249251 JOG_INC_COORD = 0xF7
250252 COLLISION_SWITCH = 0xF8
251253 IS_COLLISION_ON = 0xF9
254+ CLEAR_ROBOT_ERROR = 0x16
255+ GET_RECV_QUEUE_SIZE = 0x17
256+ SET_RECV_QUEUE_SIZE = 0x18
252257
253258 # IIC
254259 # SET_IIC_STATE = 0xA4
@@ -300,7 +305,6 @@ def _mesg(self, genre, *args, **kwargs):
300305 has_reply: Whether there is a return value to accept.
301306 """
302307 command_data = self ._process_data_command (genre , self .__class__ .__name__ , args )
303-
304308 if genre == 178 :
305309 # 修改wifi端口
306310 command_data = self ._encode_int16 (command_data )
@@ -328,7 +332,7 @@ def _mesg(self, genre, *args, **kwargs):
328332 real_command = self ._flatten (command )
329333 has_reply = kwargs .get ("has_reply" , False )
330334 return real_command , has_reply
331-
335+
332336 # Functional approach
333337 def _encode_int8 (self , data ):
334338 return struct .pack ("b" , data )
@@ -410,7 +414,7 @@ def _process_data_command(self, genre, _class, args):
410414 byte_value = data .to_bytes (4 , byteorder = 'big' , signed = True )
411415 res = []
412416 for i in range (len (byte_value )):
413- res .append (byte_value [i ])
417+ res .append (byte_value [i ])
414418 processed_args .extend (res )
415419 else :
416420 processed_args .extend (self ._encode_int16 (args [index ]))
@@ -422,7 +426,7 @@ def _process_data_command(self, genre, _class, args):
422426 byte_value = args [index ].to_bytes (2 , byteorder = 'big' , signed = True )
423427 res = []
424428 for i in range (len (byte_value )):
425- res .append (byte_value [i ])
429+ res .append (byte_value [i ])
426430 processed_args .extend (res )
427431 else :
428432 processed_args .append (args [index ])
@@ -446,7 +450,7 @@ def _process_received(self, data, genre, arm=6):
446450 header_i , header_j = 0 , 1
447451 while header_j < data_len - 4 :
448452 if self ._is_frame_header (data , header_i , header_j ):
449- if arm in [6 , 7 , 14 ]:
453+ if arm in [6 , 7 , 14 , 8 ]:
450454 cmd_id = data [header_i + 3 ]
451455 elif arm == 12 :
452456 cmd_id = data [header_i + 4 ]
@@ -457,7 +461,7 @@ def _process_received(self, data, genre, arm=6):
457461 header_j += 1
458462 else :
459463 return []
460- if arm in [6 , 7 ]:
464+ if arm in [6 , 7 , 8 ]:
461465 data_len = data [header_i + 2 ] - 2
462466 elif arm == 12 :
463467 data_len = data [header_i + 3 ] - 2
@@ -474,7 +478,7 @@ def _process_received(self, data, genre, arm=6):
474478 data_pos = header_i + 5
475479 data_len -= 1
476480 else :
477- if arm in [6 , 7 , 14 ]:
481+ if arm in [6 , 7 , 14 , 8 ]:
478482 data_pos = header_i + 4
479483 elif arm == 12 :
480484 data_pos = header_i + 5
@@ -487,7 +491,17 @@ def _process_received(self, data, genre, arm=6):
487491 # res.append(i)
488492 # return res
489493 if data_len in [6 , 8 , 12 , 14 , 16 , 24 , 26 , 60 ]:
490- if data_len == 8 and arm == 14 and cmd_id == ProtocolCode .IS_INIT_CALIBRATION :
494+ ignor_t = (
495+ ProtocolCode .GET_SERVO_CURRENTS ,
496+ ProtocolCode .GET_SERVO_TEMPS ,
497+ ProtocolCode .GET_SERVO_VOLTAGES ,
498+ ProtocolCode .GET_SERVO_STATUS ,
499+ ProtocolCode .IS_ALL_SERVO_ENABLE
500+ )
501+ if data_len == 8 and (
502+ (arm == 14 and cmd_id == ProtocolCode .IS_INIT_CALIBRATION ) or
503+ (arm == 8 and cmd_id in ignor_t )
504+ ):
491505 for v in valid_data :
492506 res .append (v )
493507 return res
@@ -650,7 +664,8 @@ def read(self, genre, method=None, command=None, _class=None, timeout=None):
650664 if _class in ["Mercury" , "MercurySocket" ]:
651665 if genre == ProtocolCode .POWER_ON :
652666 wait_time = 8
653- elif genre in [ProtocolCode .POWER_OFF , ProtocolCode .RELEASE_ALL_SERVOS , ProtocolCode .FOCUS_ALL_SERVOS , ProtocolCode .RELEASE_SERVO , ProtocolCode .FOCUS_SERVO , ProtocolCode .STOP ]:
667+ elif genre in [ProtocolCode .POWER_OFF , ProtocolCode .RELEASE_ALL_SERVOS , ProtocolCode .FOCUS_ALL_SERVOS ,
668+ ProtocolCode .RELEASE_SERVO , ProtocolCode .FOCUS_SERVO , ProtocolCode .STOP ]:
654669 wait_time = 3
655670 if method is not None :
656671 if genre == 177 :
0 commit comments