@@ -265,18 +265,18 @@ def _flatten(self, lst):
265265 flat_list .extend (self ._flatten (item ))
266266 return flat_list
267267
268- def _process_data_command (self , genre , args ):
268+ def _process_data_command (self , genre , _class , args ):
269269 if not args :
270270 return []
271271
272272 processed_args = []
273273 for index in range (len (args )):
274274 if isinstance (args [index ], list ):
275- if genre == ProtocolCode .SET_ENCODERS_DRAG and index == 0 and __class__ . __name__ == "CobotX" :
275+ if genre == ProtocolCode .SET_ENCODERS_DRAG and index == 0 and _class == "CobotX" :
276276 for data in args [index ]:
277277 byte_value = data .to_bytes (4 , byteorder = 'big' , signed = True )
278278 res = []
279- for i in range (4 ):
279+ for i in range (len ( byte_value ) ):
280280 res .append (byte_value [i ])
281281 processed_args .extend (res )
282282 else :
@@ -285,7 +285,14 @@ def _process_data_command(self, genre, args):
285285 if isinstance (args [index ], str ):
286286 processed_args .append (ord (args [index ]))
287287 else :
288- processed_args .append (args [index ])
288+ if genre == ProtocolCode .SET_SERVO_DATA and _class == "CobotX" and index == 2 :
289+ byte_value = args [index ].to_bytes (2 , byteorder = 'big' , signed = True )
290+ res = []
291+ for i in range (len (byte_value )):
292+ res .append (byte_value [i ])
293+ processed_args .extend (res )
294+ else :
295+ processed_args .append (args [index ])
289296
290297 return processed_args
291298
@@ -411,6 +418,7 @@ def write(self, command, method=None):
411418
412419 else :
413420 self ._serial_port .reset_input_buffer ()
421+ print (command )
414422 self .log .debug ("_write: {}" .format ([hex (i ) for i in command ]))
415423 self ._serial_port .write (command )
416424 self ._serial_port .flush ()
0 commit comments