3838except :
3939 SerialPort = None
4040from ..core .wrapper import UxbusCmdSer , UxbusCmdTcp
41- from ..core .utils .log import logger , pretty_print
41+ from ..core .utils .log import logger , origin_logger
4242from ..core .utils import convert , crc16
4343from ..core .config .x_code import ControllerWarn , ControllerError , ControllerErrorCodeMap , ControllerWarnCodeMap
4444from .utils import compare_time , compare_version , filter_invaild_number
@@ -1053,7 +1053,7 @@ def _core_set_modbus_baudrate(self, baudrate, use_old=False):
10531053 :return [code, ...]
10541054 """
10551055 if not use_old :
1056- ret = self .set_tgpio_modbus_baudrate (baudrate )
1056+ ret = self .set_rs485_baudrate (baudrate )
10571057 return [ret , self .tgpio_modbus_baud ]
10581058 else :
10591059 return self .arm_cmd .set_modbus_baudrate_old (baudrate )
@@ -1085,7 +1085,7 @@ def disconnect(self):
10851085 pass
10861086 self ._report_connect_changed_callback (False , False )
10871087 with self ._pause_cond :
1088- self ._pause_cond .notifyAll ()
1088+ self ._pause_cond .notify_all () if hasattr ( self . _pause_cond , 'notify_all' ) else self . _pause_cond . notifyAll ()
10891089 self ._clean_thread ()
10901090
10911091 def set_timeout (self , timeout ):
@@ -1304,7 +1304,7 @@ def _report_thread_handle(self):
13041304 time .sleep (0.001 )
13051305 if self ._pause_cnts > 0 :
13061306 with self ._pause_cond :
1307- self ._pause_cond .notifyAll ()
1307+ self ._pause_cond .notify_all () if hasattr ( self . _pause_cond , 'notify_all' ) else self . _pause_cond . notifyAll ()
13081308 self .disconnect ()
13091309
13101310 def _handle_report_data (self , data ):
@@ -1324,15 +1324,15 @@ def __handle_report_normal_old(rx_data):
13241324 if error_code != self ._error_code :
13251325 self ._error_code = error_code
13261326 if self ._error_code != 0 :
1327- pretty_print ( 'Error, code : {}' .format (self ._error_code ), color = 'red' )
1327+ origin_logger . error ( 'Errorcode : {}' .format (self ._error_code ))
13281328 else :
1329- pretty_print ('Error had clean' , color = 'blue ' )
1329+ origin_logger . info ('Error had clean' )
13301330 if warn_code != self ._warn_code :
13311331 self ._warn_code = warn_code
13321332 if self ._warn_code != 0 :
1333- pretty_print ('Warn, code: {}' .format (self ._warn_code ), color = 'yellow' )
1333+ origin_logger . warning ('Warn, code: {}' .format (self ._warn_code ))
13341334 else :
1335- pretty_print ('Warnning had clean' , color = 'blue ' )
1335+ origin_logger . info ('Warnning had clean' )
13361336 self ._report_error_warn_changed_callback ()
13371337 logger .info ('OnReport -> err={}, warn={}, state={}, cmdnum={}, mtbrake={}, mtable={}' .format (
13381338 error_code , warn_code , state , cmd_num , mtbrake , mtable
@@ -1361,11 +1361,11 @@ def __handle_report_normal_old(rx_data):
13611361 if not self ._is_first_report :
13621362 if state in [4 , 5 ] or not all ([bool (item [0 ] & item [1 ]) for item in zip (mtbrake , mtable )][:self .axis ]):
13631363 # if self._is_ready:
1364- # pretty_print ('[report], xArm is not ready to move', color='red ')
1364+ # origin_logger.info ('[report], xArm is not ready to move')
13651365 self ._is_ready = False
13661366 else :
13671367 # if not self._is_ready:
1368- # pretty_print ('[report], xArm is ready to move', color='green ')
1368+ # origin_logger.info ('[report], xArm is ready to move')
13691369 self ._is_ready = True
13701370 else :
13711371 self ._is_ready = False
@@ -1417,7 +1417,7 @@ def __handle_report_normal_old(rx_data):
14171417 self ._state = state
14181418 if self .state != 3 and (_state == 3 or self ._pause_cnts > 0 ):
14191419 with self ._pause_cond :
1420- self ._pause_cond .notifyAll ()
1420+ self ._pause_cond .notify_all () if hasattr ( self . _pause_cond , 'notify_all' ) else self . _pause_cond . notifyAll ()
14211421 self ._cmd_num = cmd_num
14221422 self ._arm_motor_brake_states = mtbrake
14231423 self ._arm_motor_enable_states = mtable
@@ -1630,15 +1630,15 @@ def __handle_report_normal(rx_data):
16301630 if error_code != self ._error_code :
16311631 self ._error_code = error_code
16321632 if self ._error_code != 0 :
1633- pretty_print ('ControllerError, code: {}' .format (self ._error_code ), color = 'red' )
1633+ origin_logger . error ('ControllerError, code: {}' .format (self ._error_code ))
16341634 else :
1635- pretty_print ('ControllerError had clean' , color = 'blue ' )
1635+ origin_logger . info ('ControllerError had clean' )
16361636 if warn_code != self ._warn_code :
16371637 self ._warn_code = warn_code
16381638 if self ._warn_code != 0 :
1639- pretty_print ('ControllerWarning, code: {}' .format (self ._warn_code ), color = 'yellow' )
1639+ origin_logger . warning ('ControllerWarning, code: {}' .format (self ._warn_code ))
16401640 else :
1641- pretty_print ('ControllerWarning had clean' , color = 'blue ' )
1641+ origin_logger . info ('ControllerWarning had clean' )
16421642 self ._report_error_warn_changed_callback ()
16431643 logger .info ('OnReport -> err={}, warn={}, state={}, cmdnum={}, mtbrake={}, mtable={}, mode={}' .format (
16441644 error_code , warn_code , state , cmd_num , mtbrake , mtable , mode
@@ -1675,11 +1675,11 @@ def __handle_report_normal(rx_data):
16751675 if not self ._is_first_report :
16761676 if state in [4 , 5 ] or not all ([bool (item [0 ] & item [1 ]) for item in zip (mtbrake , mtable )][:self .axis ]):
16771677 # if self._is_ready:
1678- # pretty_print ('[report], xArm is not ready to move', color='red ')
1678+ # origin_logger.info ('[report], xArm is not ready to move')
16791679 self ._is_ready = False
16801680 else :
16811681 # if not self._is_ready:
1682- # pretty_print ('[report], xArm is ready to move', color='green ')
1682+ # origin_logger.info ('[report], xArm is ready to move')
16831683 self ._is_ready = True
16841684 else :
16851685 self ._is_ready = False
@@ -1694,7 +1694,7 @@ def __handle_report_normal(rx_data):
16941694 self ._state = state
16951695 if self .state != 3 and (_state == 3 or self ._pause_cnts > 0 ):
16961696 with self ._pause_cond :
1697- self ._pause_cond .notifyAll ()
1697+ self ._pause_cond .notify_all () if hasattr ( self . _pause_cond , 'notify_all' ) else self . _pause_cond . notifyAll ()
16981698 self ._mode = mode
16991699 self ._cmd_num = cmd_num
17001700
@@ -1903,19 +1903,19 @@ def _auto_get_report_thread(self):
19031903
19041904 if self .state != 3 and (state == 3 or self ._pause_cnts > 0 ):
19051905 with self ._pause_cond :
1906- self ._pause_cond .notifyAll ()
1906+ self ._pause_cond .notify_all () if hasattr ( self . _pause_cond , 'notify_all' ) else self . _pause_cond . notifyAll ()
19071907 if cmd_num != self ._cmd_num :
19081908 self ._report_cmdnum_changed_callback ()
19091909 if state != self ._state :
19101910 self ._report_state_changed_callback ()
19111911 if state in [4 , 5 ]:
19121912 # if self._is_ready:
1913- # pretty_print ('[report], xArm is not ready to move', color='red ')
1913+ # origin_logger.info ('[report], xArm is not ready to move')
19141914 self ._sleep_finish_time = 0
19151915 self ._is_ready = False
19161916 else :
19171917 # if not self._is_ready:
1918- # pretty_print ('[report], xArm is ready to move', color='green ')
1918+ # origin_logger.info ('[report], xArm is ready to move')
19191919 self ._is_ready = True
19201920 if error_code != self ._error_code or warn_code != self ._warn_code :
19211921 self ._report_error_warn_changed_callback ()
@@ -2219,15 +2219,15 @@ def set_state(self, state=0):
22192219 self ._report_state_changed_callback ()
22202220 if self .state != 3 and (_state == 3 or self ._pause_cnts > 0 ):
22212221 with self ._pause_cond :
2222- self ._pause_cond .notifyAll ()
2222+ self ._pause_cond .notify_all () if hasattr ( self . _pause_cond , 'notify_all' ) else self . _pause_cond . notifyAll ()
22232223 if self ._state in [4 , 5 ]:
22242224 self ._sleep_finish_time = 0
22252225 if self ._is_ready :
2226- pretty_print ('[set_state], xArm is not ready to move' , color = 'red ' )
2226+ origin_logger . info ('[set_state], xArm is not ready to move' )
22272227 self ._is_ready = False
22282228 else :
22292229 if not self ._is_ready :
2230- pretty_print ('[set_state], xArm is ready to move' , color = 'green ' )
2230+ origin_logger . info ('[set_state], xArm is ready to move' )
22312231 self ._is_ready = True
22322232 self .log_api_info ('API -> set_state({}) -> code={}, state={}' .format (state , ret [0 ], self ._state ), code = ret [0 ])
22332233 return ret [0 ]
@@ -2267,25 +2267,23 @@ def get_err_warn_code(self, show=False, lang='en'):
22672267 self ._error_code , self ._warn_code = ret [1 :3 ]
22682268 self ._last_update_err_time = time .monotonic ()
22692269 if show :
2270- pretty_print ('************* {}, {}: {} **************' .format (
2270+ origin_logger . info ('************* {}, {}: {} **************' .format (
22712271 '获取控制器错误警告码' if lang == 'cn' else 'GetErrorWarnCode' ,
22722272 '状态' if lang == 'cn' else 'Status' ,
2273- ret [0 ]), color = 'light_blue' )
2273+ ret [0 ]))
22742274 controller_error = ControllerError (self ._error_code , status = 0 )
22752275 controller_warn = ControllerWarn (self ._warn_code , status = 0 )
2276- pretty_print ('* {}: {}, {}: {}' .format (
2276+ origin_logger . error ('* {}: {}, {}: {}' .format (
22772277 '错误码' if lang == 'cn' else 'ErrorCode' ,
22782278 controller_error .code ,
22792279 '信息' if lang == 'cn' else 'Info' ,
2280- controller_error .title [lang ]),
2281- color = 'red' if self ._error_code != 0 else 'white' )
2282- pretty_print ('* {}: {}, {}: {}' .format (
2280+ controller_error .title [lang ]))
2281+ origin_logger .warning ('* {}: {}, {}: {}' .format (
22832282 '警告码' if lang == 'cn' else 'WarnCode' ,
22842283 controller_warn .code ,
22852284 '信息' if lang == 'cn' else 'Info' ,
2286- controller_warn .title [lang ]),
2287- color = 'yellow' if self ._warn_code != 0 else 'white' )
2288- pretty_print ('*' * 50 , color = 'light_blue' )
2285+ controller_warn .title [lang ]))
2286+ origin_logger .info ('*' * 50 )
22892287 return ret [0 ], ret [1 :3 ] if ret [0 ] == 0 else [self ._error_code , self ._warn_code ]
22902288
22912289 @xarm_is_connected (_type = 'set' )
@@ -2295,11 +2293,11 @@ def clean_error(self):
22952293 if self ._state in [4 , 5 ]:
22962294 self ._sleep_finish_time = 0
22972295 if self ._is_ready :
2298- pretty_print ('[clean_error], xArm is not ready to move' , color = 'red ' )
2296+ origin_logger . info ('[clean_error], xArm is not ready to move' )
22992297 self ._is_ready = False
23002298 else :
23012299 if not self ._is_ready :
2302- pretty_print ('[clean_error], xArm is ready to move' , color = 'green ' )
2300+ origin_logger . info ('[clean_error], xArm is ready to move' )
23032301 self ._is_ready = True
23042302 self .log_api_info ('API -> clean_error -> code={}' .format (ret [0 ]), code = ret [0 ])
23052303 return ret [0 ]
@@ -2325,11 +2323,11 @@ def motion_enable(self, enable=True, servo_id=None):
23252323 if self ._state in [4 , 5 ]:
23262324 self ._sleep_finish_time = 0
23272325 if self ._is_ready :
2328- pretty_print ('[motion_enable], xArm is not ready to move' , color = 'red ' )
2326+ origin_logger . info ('[motion_enable], xArm is not ready to move' )
23292327 self ._is_ready = False
23302328 else :
23312329 if not self ._is_ready :
2332- pretty_print ('[motion_enable], xArm is ready to move' , color = 'green ' )
2330+ origin_logger . info ('[motion_enable], xArm is ready to move' )
23332331 self ._is_ready = True
23342332 self .log_api_info ('API -> motion_enable -> code={}' .format (ret [0 ]), code = ret [0 ])
23352333 return ret [0 ]
0 commit comments