Hello,
I'm trying to set up a configuration file for my IWRL6432 sensor board using python application.
But it failed due to CLI loss issue.
The configuration file setting function of the Python application was developed with reference to TI's Visualizer.
The environment used for development is as follows.
- Host PC : Window 10
- GUI Language : Python 3.8.4
- Communication : UART Port (USB to UART interface board)
- Base example code(sensor) : motion_and_presence_detection_demo_xwrL64xx-evm_m4fss0-0_freertos_ti-arm-clang
- SDK Version(sensor) : MMWAVE_L_SDK_05_02_00_02
As in the example below, a problem occurs where the sent CLI and the received CLI are different.
This problem occurs even if you directly enter CLI on the console using the TeraTerm.
[Send CLI] chirpTimingCfg 6 21 0 15.11 60
[Recv CLI] chirpTimingCfg 6 21 0 15.1160
Error: Invalid usage of the CLI command
Error -1
Is there any python example code that doesn't have this problem?
Please let me know how I can solve this problem.
Also, please refer to the failed log and Python code as bellow.
Log message :
INFO:root:[send_cli_message] sensorStop 0 INFO:root:[send_cli_message] userconfigErase 0 INFO:root:[send_cli_message] deviceInfo 0xDEADDEAD 0xDEADDEAD 0xDEADDEAD 0x00000001 0 0 0 1 INFO:root:[send_cli_message] frameCfg 2 0 200 64 100 0 INFO:root:[send_cli_message] channelCfg 7 3 0 INFO:root:[send_cli_message] chirpComnCfg 22 0 0 128 4 34 0 CLI> |
Used python code :
def send_config_org(self, config_cli_lines : list):
timeout = 1000 # 1 sec
retry_nack = 0
retry_timout = 0
max_retry_nack = 5
max_retry_timeout = 3
i = 0
""" # -- UART reconnect after diconnect
if self.__num_port == None :
return False
self.connect(self.__num_port, 1250000, self.__timeout) """
self.__com_port.reset_input_buffer()
self.__com_port.reset_output_buffer()
# -- Handle Config Command
num_of_lines = len(config_cli_lines)
while True :
self.send_cli_message(config_cli_lines[i])
send_time = plTime.time()
# -- Wait for response
resp_data = bytes()
while True:
resp = self.__com_port.read(1)
resp_data += resp
if len(resp_data) > len(config_cli_lines[i]):
if CLI_PROMPT in resp_data :
if CLI_ERROR in resp_data :
self.__send_queue.send(MESSAGE_GUI_WRITE_LOG, 0, resp_data[:-len(CLI_PROMPT)])
print('[send_config] failure : ' + resp_data[:-len(CLI_PROMPT)].decode('utf-8'))
# retry_nack += 1
# if retry_nack > max_retry_nack: return
break
elif config_cli_lines[i] in resp_data:
self.__send_queue.send(MESSAGE_GUI_WRITE_LOG, 0, ('1 line config is written(%d)'%i).encode())
print('[send_config] sucess: ' + resp_data[:-len(CLI_PROMPT)].decode('utf-8'))
# retry_nack = 0
# retry_timout = 0
# i += 1
break
curr_time = plTime.time()
if timeout < curr_time - send_time:
print('[send_config] timeout: ' + resp_data.decode('utf-8'))
# retry_timout += 1
# if retry_timout > max_retry_timeout: return
break
i += 1
if num_of_lines <= i :
break
self.__com_port.reset_input_buffer()
self.__com_port.reset_output_buffer()
QtTest.QTest.qWait(1000)
def send_cli_message(self,
msg_data : bytes = bytes()
) :
if self.__is_connect == False :
return 0
try :
msg_len = len(msg_data)
resp = bytes()
if msg_len == 0 :
return 0
cli_msg = msg_data + CR + LF
QtTest.QTest.qWait(10)
self.__com_port.write(cli_msg)
log.info('[send_cli_message] send : %s'%cli_msg.decode('utf-8'))
return len(cli_msg)
except :
return 0
def connect(self,
port_num = None ,
baud_rate :int = 1250000, #921600,#115200,#921600,
timeout :float = 0.3
) :
try :
self.disconnect()
self.__num_port = port_num
self.__baud_rate = baud_rate
self.__timeout = timeout
self.__com_port = serial.Serial(self.__num_port, self.__baud_rate, parity = serialutil.PARITY_NONE, stopbits=serialutil.STOPBITS_ONE, timeout = self.__timeout)
self.__com_port.reset_input_buffer()
self.__com_port.reset_output_buffer()
self.__is_connect = True
except Exception as e:
self.__is_connect = False
|