Tool/software:
Test environment: LP AM261X + cdc_echo_am261x-lp_r5fss0-0_nortos_ti-arm-clang in mcu_plus_sdk_am261x_10_02_00_15.
After I downloaded the .out file to the LP AM261X board and ran the program, I used a bat file to execute the Python script in a loop 200 times. However, when it ran to more than 100 times, the USB device could no longer be found.
The USB_test.py is:
import serial
import serial.tools.list_ports
# List all serial port devices
ports = serial.tools.list_ports.comports()
usb_port = None
# Enumerate all serial port devices
for port in sorted(ports):
if "USB" in port.description:
print(f"Found USB device on port: {port.device}")
usb_port = port.device
break # Exit the loop after finding the first USB device
# Exit directly if no USB device is found
if usb_port is None:
print("Error: No USB device found. Exiting...")
exit()
baudrate = 19200 # Baud rate, modify according to actual requirements
timeout = 2 # Timeout period (seconds)
# Define the data to be sent
data_to_send = [0xF8, 0x03, 0x01, 0x02, 0x00, 0x02, 0x70, 0x5E]
data_to_send_hex = ' '.join(f'{byte:02X}' for byte in data_to_send)
print(f"USB Sent data: {data_to_send_hex}")
try:
# Open the serial port
ser = serial.Serial(usb_port, baudrate, timeout=timeout)
# Send data
ser.write(data_to_send)
# Read the received data
received_data = ser.read(20)
# Close the serial port
ser.close()
# Print the received data
received_data_hex = ' '.join(f'{byte:02X}' for byte in received_data)
print(f"USB Received data: {received_data_hex}")
except serial.SerialException as e:
print(f"Serial communication error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
The bat file is:
@echo off
set /a count=0
:loop
set /a count+=1
echo The test times: %count%
python USB_test.py
timeout /t 2 /nobreak >nul
if %count% lss 200 goto loop
Test Result:

I tried it and it didn't work. Have you passed the tests? If you pass the test, you can send me the .out file and I will test it.


