hdc_std Usage Guidelines
hdc_std (OpenHarmony Device Connector) is a command line tool provided by OpenHarmony for debugging. With this tool, you can interact with real devices or simulators from a Windows or Linux OS.
This section describes how to set up the hdc_std environment and use its common commands.
Preparations
Obtaining hdc_std:
Obtain hdc_std from the developtools_hdc_standard repository in the prebuilt directory.
Example:
To obtain hdc_std on Windows, obtain the executable file hdc_std.exe from prebuilt/windows and place it in a directory on the disk.
Important Notes
- If an exception occurs when you are using hdc_std, run the hdc_std kill command to kill the hdc_std service or run the hdc_std start -r command to restart the service process.
- If no device information is obtained after hdc_std list targets is executed, use the task manager to check whether the hdc.exe process exists. If it exists, kill the process.
Option-related Commands
The following commands are available:
-h/help -v/version
Obtains hdc help and version information.
Table 1 Command description
Examples:
hdc_std -h / hdc_std help
hdc_std -v / hdc_std version
-t key
Connects to a device with a specified key.
Table 2 Command description
Key that identifies the device. The value is in the IP address:Port number format or is a USB serial number. |
|
Examples:
This option must be used together with a specific operation command. The following uses the shell command as an example:
hdc_std list targets (obtain device information)
hdc_std -t key shell (replace key with the device information obtained)
NOTE: You can connect to multiple devices from the device you use for development. Each device has a unique key. The key can be IP address:Port number for a device connected through a network or the serial number for a device connected through USB.
Querying the Device List
The following command is used to query the device list:
list targets[-v]
Displays all the connected devices.
Table 3 Command description
Examples:
hdc_std list targets
hdc_std list targets -v
Service Process Commands
The following commands are available:
target mount
Mounts a partition, such as /system, with the read and write permissions.
Table 4 Command description
Example:
hdc_std target mount
smode [off]
Grants the root permission to a background service process. The off option is used to revoke the granted permission.
Examples:
hdc_std smode
hdc_std smode off
kill [-r]
Stops a service process.
Table 5 Command description
Example:
hdc_std kill
start [-r]
Starts a service process.
Table 6 Command description
Examples:
hdc_std start
Network Commands
The following commands are available:
tconn host[:port][-remove]
Connects to a device with a specified IP address and port number.
Table 7 Command description
Example:
hdc_std tconn 192.168.0.100:8710
tmode usb
Restarts the daemon process and connects to the device using USB.
Table 8 Command description
Example:
hdc_std tmode usb
tmode port port-number
Restarts the daemon process and connects to the device over TCP.
Table 9 Command description
Example:
hdc_std tmode port 8710
NOTE: After this command is executed, the remote daemon process exits and restarts, and the TCP connection is enabled by default. If you do not include port-number in this command, a random port will be used to connect to the device.
File Commands
The following commands are available:
file send local remote
Sends a file to a remote device.
Table 10 Command description
Example:
hdc_std file send E:\a.txt /data/local/tmp/a.txt
file recv [-a] remote local
Receives a file from a remote device.
Table 11 Command description
Example:
hdc_std file recv /data/local/tmp/a.txt ./a.txt
App Commands
The following commands are available:
install [-r/-d/-g] package
Installs the OpenHarmony application.
Table 12 Command description
Example:
hdc_std install hwadmin.hap
uninstall [-k] package
Uninstalls the OpenHarmony application.
Table 13 Command description
Example:
hdc_std uninstall package
Debugging Commands
The following commands are available:
hilog
Obtains logs for debugging.
Table 14 Command description
Example:
hdc_std hilog
shell [command]
Executes a command remotely or enters an interactive command environment.
Table 15 Command description
Examples:
hdc_std shell
Troubleshooting
hdc_std Fails to Connect to a Device
-
Symptom
[Empty] is displayed in the output after the hdc_std list targets command is executed.
-
Solutions
-
The device cannot be identified.
Check whether HDC Device exists in the universal serial bus device of the device manager. If HDC Device does not exist, the device cannot be connected. In this case, remove and then insert the device or burn the latest image for the device.
-
hdc_std works improperly.
Run the hdc kill or hdc start -r command to kill or restart the hdc service. Then, run the hdc list targets command to check whether device information can be obtained.
-
hdc_std does not match the device.
If the latest image is burnt on the device, the latest hdc_std version must be used. As hdc_std is updated continuously, obtain hdc_std of the latest version from the developtools_hdc_standard repository in the prebuilt directory.
-
hdc_std Fails to Run
-
Symptom
The hdc_std.exe file does not run after being clicked.
-
Solutions
hdc_std.exe requires no installation. It can be directly used on a disk or added to environment variables. Open the cmd window and run the hdc_std command to use hdc_std.exe.