Read USB Device Information Demo
1 Demo overview
This demo tests the USB interface's read function by reading information about devices connected to the external USB ports.
2 Preparation
Before starting the test, complete the following steps:
2.1 Install dependency libraries
On the board, update the package index and install the libusb-1.0 library. This operation requires the board to be connected to a network.
# 更新软件包索引
sudo apt update
# 安装libusb-1.0 库
sudo apt install libusb-1.0-0 libusb-1.0-0-dev3 Procedure
Open a terminal and copy the executable smdt_usb_r_demo from this demo's bin directory (05-Development Materials\Software Development Materials\linux_demo\smdt_usb_r_demo\bin) to the board's filesystem (the source code is available under the src path).
Optional: Because the board has a wireless network card, if the terminal keeps printing log messages generated by the wireless driver, you can change the Linux kernel log level with the following command.
#修改 Linux 内核日志的显示级别,内核的日志级别被设置为只显示紧急或更高级别的消息
echo 1 4 1 7 > /proc/sys/kernel/printkIn the terminal, run the following commands to switch to the directory containing the smdt_usb_r_demo executable.
#切换到 smdt_usb_r_demo 可执行程序所在目录
cd ‘可执行文件所在目录’
#查看 smdt_usb_r_demo 是否在该目录下
lsIf the executable smdt_usb_r_demo is in the current directory, change its permissions.
#修改文件权限
chmod 777 smdt_usb_r_demo
#查询是否修改成功
ls -ld smdt_usb_r_demoAfter confirming the permission change succeeded, run ./smdt_usb_r_demo -h to view the program's help information.
#查看帮助信息
./smdt_usb_r_demo -hThe result is shown below:

Run ./smdt_usb_r_demo -l to read the USB external device information and continuously detect device connect/disconnect events. Press "Ctrl+C" to exit the test.
#检查外部 USB 连接设备信息
./smdt_usb_r_demo -l4 Test result
Running ./smdt_usb_r_demo -l lists the board's currently connected external USB devices (Linux kernel virtual USB devices are not shown). The result is shown below:

It continuously detects whether any USB device is connected or disconnected, with a detection interval of 5s.
When a device is connected, the terminal prints:

When a device is disconnected, the terminal prints:
Press "Ctrl+C" to exit the test:
