OpenHarmony Device Connector (hdc_std) is a command-line tool used for debugging. You can use it on a Windows, Linux, or macOS system to interact with real devices or simulators.
OpenHarmony Device Connector (hdc) is a command-line tool used for debugging. You can use it on a Windows, Linux, or macOS system to interact with real devices or simulators.
The following describes how to obtain and use hdc_std.
The following describes how to obtain and use hdc.
## How to Obtain
## How to Obtain
Obtain hdc_std from the **toolchains** directory of the OpenHarmony SDK.
**Obtaining hdc**
Obtain hdc from the **toolchains** directory of the OpenHarmony SDK.
**Example**
**Example**
If you use hdc_std on Windows, obtain the SDK for Windows and copy **hdc_std.exe** from **toolchains** to a directory on the disk.
The following uses the Windows operating system as an example:
Obtain the SDK for Windows, and copy **hdc.exe** from **toolchains** to a directory on the disk.
## NOTICE
## NOTICE
- If an exception occurs when you are using hdc_std, run the **hdc_std kill** command to terminate the hdc_std service or run the **hdc_std start -r** command to restart the service process.
- If an exception occurs when you are using hdc, run the **hdc kill** command to terminate the hdc service or run the **hdc start -r** command to restart the service process.
- If no device information is obtained after **hdc_std list targets** is executed, check whether the hdc_std process exists in the **Task Manager**. If yes, terminate it.
- If no device information is obtained after **hdc list targets** is executed, check whether the hdc process exists in the **Task Manager**. If yes, terminate the process.
## Option-related Commands
## Option-related Commands
...
@@ -29,30 +33,29 @@ The following commands are available:
...
@@ -29,30 +33,29 @@ The following commands are available:
-**-h/help -v/version**
-**-h/help -v/version**
Displays hdc help or version information.
Displays hdc_std help or version information.
**Table 1** Command description
**Table 1** Command description
| **Return Value**| **Description**|
| Return Value| Description|
| -------- | -------- |
| -------- | -------- |
| Required information| hdc_std help or version information.|
| Required information| hdc help or version information.|
Example:
Example:
```
```
hdc_std -h / hdc_std help
hdc -h / hdc help
```
```
```
```
hdc_std -v / hdc_std version
hdc -v / hdc version
```
```
-**-l 0-5**
-**-l 0-5**
Sets the levels of the logs generated during the running of the tool. The default value is **LOG_INFO**.
Sets the levels of the logs generated during the running of the tool. The default value is **LOG_INFO**.
**Table 2** Command description
**Table 2** Command description
| Parameter| Description|
| Parameter| Description|
...
@@ -65,38 +68,36 @@ The following commands are available:
...
@@ -65,38 +68,36 @@ The following commands are available:
| 5 | LOG_ALL |
| 5 | LOG_ALL |
Example:
Example:
```
```
hdc_std -l5 start
hdc -l5 start
```
```
-**-t key**
-**-t key**
Connects to a device based on the specified key.
Connects to a device based on the specified key.
**Table 3** Command description
**Table 3** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| key | Key that identifies the device to connect. The value can be in the *IP address:port number* format or be a USB serial number.|
| key | Key that identifies the device to connect. The value can be in the *IP address:port number* format or be a USB serial number.|
| **Return Value** | **Description**|
| Return Value| Description|
| 1. error: device '\*\*\*' not found<br>2. Nothing to do ..| 1. The device does not exist.<br>2. The command appended to **-t key** does not exist.|
| 1. error: device '\*\*\*' not found<br>2. Nothing to do ...| 1. The device does not exist.<br>2. The command appended to **-t key** does not exist.|
Example:
Example:
**-t key** must be used with a command. The following uses **shell** as an example:
**-t key** must be used with a command. The following uses **shell** as an example:
**hdc_std list targets** (obtain device information)
**hdc list targets** (Obtain device information.)
**hdc_std -t *key* shell** (replace *key* with the device identifier obtained)
**hdc -t *key* shell** (Replace *key* with the device identifier obtained)
> **NOTE**<br>
> **NOTE**<br>
> 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 to be connected over the network or the serial number for a device to be connected through USB. A specific command must be used with this command.
> 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 to be connected over the network or the serial number for a device to be connected through USB. A specific command must be used with this command.
-**checkserver**
-**checkserver**
Obtains the client and server version information.
Obtains the client and server version information.
**Table 4** Command description
**Table 4** Command description
| Return Value| Description|
| Return Value| Description|
...
@@ -106,7 +107,7 @@ The following commands are available:
...
@@ -106,7 +107,7 @@ The following commands are available:
Example:
Example:
```
```
hdc_std checkserver
hdc checkserver
```
```
...
@@ -124,18 +125,22 @@ list targets[-v]
...
@@ -124,18 +125,22 @@ list targets[-v]
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| -v | Displays detailed device information.|
| -v | Displays detailed device information.|
| **Return Value**| **Description**|
| Return Value| **Description**|
| 1. Device information<br>2. [Empty]| 1. A list of connected devices.<br>2. No device information is found.|
| 1. Device information<br>2. [Empty]| 1. A list of connected devices.<br>2. No device information is found.|
Example:
Example:
```
```
hdc_std list targets
hdc list targets
```
```
```
```
hdc_std list targets -v
hdc list targets -v
```
```
...
@@ -143,8 +148,8 @@ hdc_std list targets -v
...
@@ -143,8 +148,8 @@ hdc_std list targets -v
The following commands are available:
The following commands are available:
-**target mount**
-**target mount**
Mounts the **/system** partition in read/write mode.
Mounts the **/system** partition in read/write mode.
**Table 6** Command description
**Table 6** Command description
...
@@ -152,92 +157,82 @@ The following commands are available:
...
@@ -152,92 +157,82 @@ The following commands are available:
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| –| –|
| –| –|
| **Return Value**| **Description**|
| Return Value| **Description**|
| 1. Mount finish<br>2. Error information| 1. The operation is successful.<br>2. The operation fails.|
| 1. Mount finish<br>2. Error information| 1. The operation is successful.<br>2. The operation fails.|
Example:
Example:
```
```
hdc_std target mount
hdc target mount
```
```
-**target boot**
-**target boot**
Boots the device.
Boots the device.
Example:
Example:
```
```
hdc_std target boot
hdc target boot
```
```
-**smode [-r]**
-**smode [-r]**
Grants the **root** permission to the background hdc service. Use **off** to revoke the granted permissions.
Grants the **root** permission to the background hdc service. Use **off** to revoke the granted permissions.
Example:
Example:
```
```
hdc_std smode
hdc smode
```
```
```
```
hdc_std smode -r
hdc smode -r
```
```
-**kill [-r]**
-**kill [-r]**
Terminates the hdc process.
Terminates the hdc process.
**Table 7** Command description
**Table 7** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| -r | Restarts the hdc process.|
| -r | Restarts the hdc process.|
| **Return Value**| **Description**|
| Return Value| **Description**|
| 1. Kill server finish<br>2. Error information| 1. The operation is successful.<br>2. The operation fails.|
| 1. Kill server finish<br>2. Error information| 1. The operation is successful.<br>2. The operation fails.|
Example:
Example:
```
```
hdc_std kill
hdc kill
```
```
-**start [-r]**
-**start [-r]**
Starts the hdc process.
Starts the hdc process.
**Table 8** Command description
**Table 8** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| -r | Restarts the hdc process if it has started.|
| -r | Restarts the hdc process if it has started.|
| **Return Value**| **Description**|
| Return Value| Description|
| –| –|
| –| –|
Example:
Example:
```
```
hdc_std start
hdc start
```
```
## Network Commands
## Network Commands
The following commands are available:
The following commands are available:
-**tconn host[:port][-remove]**
-**tconn host[:port][-remove]**
Connects to a device with the specified IP address and port number.
Connects to a device with the specified IP address and port number.
**Table 9** Command description
**Table 9** Command description
...
@@ -246,19 +241,17 @@ The following commands are available:
...
@@ -246,19 +241,17 @@ The following commands are available:
| -------- | -------- |
| -------- | -------- |
| host[:port] | IP address and port number for the device to connect.|
| host[:port] | IP address and port number for the device to connect.|
| -remove | Disconnects from the specified device.|
| -remove | Disconnects from the specified device.|
| **Return Value**| **Description**|
| Return Value| Description|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
Example:
Example:
```
```
hdc_std tconn 192.168.0.100:8710
hdc tconn 192.168.0.100:8710
```
```
-**tmode usb**
-**tmode usb**
Restarts the daemon process and connects to the device using USB preferentially.
Restarts the daemon process and connects to the device using USB preferentially.
**Table 10** Command description
**Table 10** Command description
...
@@ -266,96 +259,85 @@ The following commands are available:
...
@@ -266,96 +259,85 @@ The following commands are available:
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| –| –|
| –| –|
| **Return Value**| **Description**|
| Return Value| Description|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
Example:
Example:
```
```
hdc_std tmode usb
hdc tmode usb
```
```
-**tmode port port-number**
-**tmode port port-number**
Restarts the daemon process and connects to the device over TCP preferentially. If the TCP connection fails, a USB connection will be initiated.
Restarts the daemon process and connects to the device over TCP preferentially. If the TCP connection fails, a USB connection will be initiated.
**Table 11** Command description
**Table 11** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| port-number | Port used to connect to the device.|
| port-number | Port used to connect to the device.|
| **Return Value**| **Description**|
| Return Value| Description|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
Example:
Example:
```
```
hdc_std tmode port 8710
hdc tmode port 8710
```
```
> **NOTE**<br>
> **NOTE**<br>
> After this command is executed, the remote daemon process exits and restarts, and a TCP connection is set up by default. If the port number is not specified in the command, a random port will be used to connect to the device.
> After this command is executed, the remote daemon process exits and restarts, and a TCP connection is set up by default. If the port number is not specified in the command, a random port will be used to connect to the device.
-**fport localnode remotenode**
-**fport localnode remotenode**
Forwards data from a host port to a device port.
Forwards data from a host port to a device port.
Example:
Example:
```
```
hdc_std fport tcp:1234 tcp:1080
hdc fport tcp:1234 tcp:1080
```
```
-**rport remotenode localnode**
-**rport remotenode localnode**
Forwards data from a device port to a host port.
Forwards data from a device port to a host port.
Example:
Example:
```
```
hdc_std rport tcp:2080 tcp:2345
hdc rport tcp:2080 tcp:2345
```
```
-**fport ls**
-**fport ls**
Lists all port forwarding tasks.
Lists all port forwarding tasks.
**Table 12** Command description
**Table 12** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| –| –|
| –| –|
| **Return Value**| **Description**|
| Return Value| **Description**|
| 'tcp:1234 tcp:1080' [Forward] | Forward port forwarding task.|
| 'tcp:1234 tcp:1080' [Forward] | Forward port forwarding task.|
| 'tcp:2080 tcp:2345' [Reverse] | Reverse port forwarding task.|
| 'tcp:2080 tcp:2345' [Reverse] | Reverse port forwarding task.|
Example:
Example:
```
```
hdc_std fport ls
hdc fport ls
```
```
-**fport rm**
-**fport rm**
Deletes a port forwarding task.
Deletes a port forwarding task.
Example:
Example:
```
```
hdc_std fport rm tcp:1234 tcp:1080
hdc fport rm tcp:1234 tcp:1080
```
```
## File Commands
## File Commands
...
@@ -364,30 +346,27 @@ The following commands are available:
...
@@ -364,30 +346,27 @@ The following commands are available:
-**file send local remote**
-**file send local remote**
Sends a file to a remote device.
Sends a file to a remote device.
**Table 13** Command description
**Table 13** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| local | Path of the file to send.|
| local | Path of the file to send.|
| remote | Destination path on the remote device.|
| remote | Destination path on the remote device.|
| **Return Value**| **Description**|
| Return Value| Description|
| 1. Error information<br>2. File transfer result| 1. The operation fails.<br>2. The operation is successful.|
| 1. Error information<br>2. File transfer result| 1. The operation fails.<br>2. The operation is successful.|
Example:
Example:
```
```
hdc_std file send E:\a.txt /data/local/tmp/a.txt
hdc file send E:\a.txt /data/local/tmp/a.txt
```
```
-**file recv [-a] remote local**
-**file recv [-a] remote local**
Receives a file from a remote device.
Receives a file from a remote device.
**Table 14** Command description
**Table 14** Command description
| Parameter| Description|
| Parameter| Description|
...
@@ -395,16 +374,15 @@ The following commands are available:
...
@@ -395,16 +374,15 @@ The following commands are available:
| -a | Retains the file timestamp.|
| -a | Retains the file timestamp.|
| local | Destination path on the local device.|
| local | Destination path on the local device.|
| remote | File path on the remote device.|
| remote | File path on the remote device.|
| **Return Value**| **Description**|
| Return Value| Description|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
Example:
Example:
```
```
hdc_std file recv /data/local/tmp/a.txt ./a.txt
hdc file recv /data/local/tmp/a.txt ./a.txt
```
```
## App Commands
## App Commands
...
@@ -412,48 +390,45 @@ The following commands are available:
...
@@ -412,48 +390,45 @@ The following commands are available:
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
| 1. Error information<br>2. –| 1. The operation fails.<br>2. The operation is successful.|
Example:
Example:
```
```
hdc_std uninstall package
hdc uninstall package
```
```
## Debugging Commands
## Debugging Commands
...
@@ -462,120 +437,104 @@ The following commands are available:
...
@@ -462,120 +437,104 @@ The following commands are available:
-**hilog**
-**hilog**
Obtains logs for debugging.
Obtains logs for debugging.
**Table 17** Command description
**Table 17** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| –| –|
| –| –|
| **Return Value**| **Description**|
| Return Value| **Description**|
| Log obtained| Log information obtained.|
| Log obtained| Log information obtained.|
Example: Obtain log information.
Example: Obtain log information.
```
```
hdc_std hilog
hdc hilog
```
```
Clear the cached logs.
Clear the cached logs.
```
```
hdc_std shell "hilog -r"
hdc shell "hilog -r"
```
```
-**shell** [*command*]
-**shell [_command_]**
Executes a command remotely or enters an interactive command environment.
Executes a command remotely or enters an interactive command environment.
**Table 18** Command description
**Table 18** Command description
| Parameter| Description|
| Parameter| Description|
| -------- | -------- |
| -------- | -------- |
| command | Command to execute.|
| command | Command to execute.|
| **Return Value**| **Description**|
| Return Value| **Description**|
| Returned information| Command execution result.|
| Returned information| Command execution result.|
Example:
Example:
```
```
hdc_std shell
hdc shell
```
```
-**jpid**
-**jpid**
Obtains the list of processes that can be debugged.
Obtains the list of processes that can be debugged.
Example:
Example:
```
```
hdc_std jpid
hdc jpid
```
```
## FAQs
## FAQs
### Failed to Connect to a Device from hdc_std
### Failed to Connect the Target Device
-**Symptom**
-**Symptom**
After the **hdc list targets** command is executed, **[Empty]** is displayed.
After the **hdc_std list targets** command is executed, **[Empty]** is displayed.
-**Solution**
-**Solution**
- The device cannot be identified.
- The device cannot be identified.
Check whether **HDC Device** exists under the **Universal Serial Bus controllers** in the **Device Manager**. If **HDC Device** does not exist, the device cannot be connected. In this case, disconnect and then reconnect the USB connection between the test PC and the OpenHarmony device, or burn the latest image.
Check whether **HDC Device** exists under the **Universal Serial Bus controllers** in the **Device Manager**. If **HDC Device** does not exist, the device cannot be connected. In this case, disconnect and then reconnect the USB connection between the test PC and the OpenHarmony device, or burn the latest image.
- hdc works improperly.
Run the **hdc kill** command to terminate the hdc process or run the **hdc start -r** command to restart the hdc service. Then, run the **hdc list targets** command to check whether device information can be obtained.
- hdc_std works improperly.
- The hdc version does not match the device.
If the latest image is burnt on the device, the latest hdc version must be used.
Run the **hdc kill** command to terminate the hdc_std process or run the **hdc start -r** command to 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.
### hdc_std Fails to Run
### Failed to Run hdc
-**Symptom**
-**Symptom**
The **hdc.exe** file cannot be executed.
After you click **hdc_std.exe**, the file fails to execute.
-**Solution**
**hdc_std.exe** requires no installation. You can use it after placing it to a local directory or adding the tool path to environment variables. Run the **cmd** command and then run the **hdc_std** command to start the tool.
-**Solution**
1. Check the running environment.
### Accessing a Server from the Client
Ubuntu 18.04 64-bit or later is recommended for Linux.<br>If **libc++.so** is incorrectly referenced, run the **ldd** or **readelf** command to check the referenced library. <br>Windows 10 64-bit is recommended for Windows. If the Windows winusb library of an earlier version is missing, use Zadig to update the library. For composite devices, use Zadig tool to install the libusb-win32 driver.
2. Run **hdc.exe**.
1. Run the **kill** command to stop the local server.
**hdc.exe** requires no installation. You can use it after placing it to a local directory or adding the tool path to environment variables. Run **cmd** and then the **hdc** command to start the tool.
2. Run the **-s [ip:]port -m** command to start the remote server.
### Accessing a hdc Server from the hdc Client
Example:
-**Scenario**
```
hdc_std -s severIP:8710 -m
Use hdc to connect to a remote server from the local client.
```
-**Procedure**
1. Shut down the local hdc server.
```
3. Run **-s [ip:]port***command* to execute a command on the remote server.
hdc kill
```
Example:
2. Run **-s [ip:]port -m** to start the remote server.
```
```
hdc -s severIP:8710 -m
hdc_std -s severIP:8710 list targets
```
```
3. Run **-s [ip:]port***command* to execute a command on the remote server.