Symptom
1. No output is displayed or "Connect server failed." is displayed after a command is executed in hdc?
2. Check the hdc.log and an error message "USB mod ctxUSB is nullptr, recompile please." is displayed.
Possible Causes
1. The Docker does not map the external USB device to the container. As a result, the /dev/bus/usb node is empty.
2. The hdc version is outdated. Using the hdc tool of version 3.1.0e (API15 SDK) or later will support starting the service process (hdc server) without a USB device node.
Solution
1. Map the external USB device to the Docker so that the corresponding device is displayed in /dev/bus/usb. The following two methods are available:
Method 1: Use the device parameter (recommended and secure).
# Map the USB serial port device, for example, /dev/ttyUSB0. docker run -it --device=/dev/ttyUSB0:/dev/ttyUSB0 image_name # Map the common USB device, for example, /dev/bus/usb/001. docker run -it --device=/dev/bus/usb/001 image_name
Method 2: Use the privileged parameter (This method is simple. The container can access all USB devices on the host, with high security risks.)
docker run -it --privileged image_name
2. Update the hdc tool to API15 (3.1.0e) or later by referring to hdc Version Mappings.