# hdc\_std Usage Guidelines
- [Preparations](#section05992022154916)
- [Important Notes](#section19543134915210)
- [Global Options](#section618522925119)
- [Querying the Device List](#section174891132104218)
- [Service Process Commands](#section680531510497)
- [Network Commands](#section71176123212)
- [File Commands](#section173133523013)
- [App Commands](#section2072647133819)
- [Debugging Commands](#section112861250195015)
hdc\_std \(OpenHarmony Device Connector\) is a command line tool provided by OpenHarmony for debugging. With hdc, you can interact with real devices or simulators from a Windows or Linux OS.
This section describes how to build the hdc\_std environment, its common commands, and how to use the commands.
## Preparations
**hdc\_std obtaining method:**
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 specified directory on the disk.
## Important Notes
1. If an exception occurs when you are using hdc\_std, you can 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.
2. 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.
## Global Options
The following options are globally available:
- **-h/help -v/version**
Obtains the hdc help and version information.
**Table 1** Command description
Parameter
|
Description
|
-h/help -v/version
|
None
|
Return Value
|
Description
|
Required information
|
hdc help or version information
|
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
Parameter
|
Description
|
key
|
Key that identifies the device. The value is in the IP address:Port number format or is a USB serial number.
|
Return Value
|
Description
|
1. error: device '***' not found
②Nothing to do...
|
1. The device does not exist.
2. The command does not exist.
|
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 \(for obtaining device information\)
hdc\_std -t _key_ shell \(replace _key_ with the obtained device information\)
> **NOTE:**
>You can connect to multiple devices from the device you use for development. Each device has a unique key, which is _IP address:Port number_ for a device that can be connected through a network and the serial number for a device that can be connected through USB.
## Querying the Device List
The following command is available:
**list targets\[-v\]**
Queries all the connected devices.
**Table 3** Command description
Parameter
|
Description
|
-v
|
Prints detailed device information.
|
Return Value
|
Description
|
1. Device information
②[Empty]
|
1. A list of connected devices
1. No device information is found.
|
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
Parameter
|
Description
|
None
|
None
|
Return Value
|
Description
|
①Mount finish
2. Returned information
|
1. Information returned when the operation is successful.
2. Information returned when the operation fails.
|
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
Parameter
|
Description
|
-r
|
Triggers the service restart.
|
Return Value
|
Description
|
①Kill server finish
1. Error information
|
1. Information returned when the operation is successful.
1. The operation fails.
|
Example:
hdc\_std kill
- **start \[-r\]**
Starts the service process.
**Table 6** Command description
Parameter
|
Description
|
-r
|
Restarts the service process if it has started.
|
Return Value
|
Description
|
None
|
None
|
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
Parameter
|
Description
|
host[:port]
|
IP address and port number of the device to be connected
|
-remove
|
Disconnects from the specified device.
|
Return Value
|
Description
|
1. Error information
2. None
|
1. The operation fails.
2. The operation is successful.
|
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
Parameter
|
Description
|
None
|
None
|
Return Value
|
Description
|
1. Error information
2. None
|
1. The operation fails.
2. The operation is successful.
|
Example:
hdc\_std tmode usb
- **tmode port _port-number_**
Restarts the daemon process and connects to the device over TCP.
**Table 9** Command description
Parameter
|
Description
|
port-number
|
Port number used to connect to the device
|
Return Value
|
Description
|
1. Error information
2. None
|
1. The operation fails.
2. The operation is successful.
|
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
Parameter
|
Description
|
local
|
Path of the file to send
|
remote
|
Destination path on the remote device
|
Return Value
|
Description
|
1. Error information
2. File transfer result
|
1. The operation fails.
2. The operation is successful.
|
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
Parameter
|
Description
|
-a
|
File retention timestamp mode
|
local
|
Path on the local device to receive the file
|
remote
|
File path on the remote device
|
Return Value
|
Description
|
1. Error information
2. None
|
1. The operation fails.
2. The operation is successful.
|
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
Parameter
|
Description
|
package
|
OpenHarmony application installation package
|
-r
|
Replaces an existing application.
|
-d
|
Allows downgraded installation.
|
-g
|
Dynamic permission granting
|
Return Value
|
Description
|
1. Error information
2. None
|
1. The operation fails.
2. The operation is successful.
|
Examples:
hdc\_std install _hwadmin.hap_
- **uninstall \[-k\] _package_**
Uninstalls the OpenHarmony application.
**Table 13** Command description
Parameter
|
Description
|
package
|
OpenHarmony application installation package
|
-k
|
Retains /data/cache.
|
Return Value
|
Description
|
1. Error information
2. None
|
1. The operation fails.
2. The operation is successful.
|
Example:
hdc\_std uninstall _package_
## Debugging Commands
The following commands are available:
- **hilog**
Obtains logs for debugging.
**Table 14** Command description
Parameter
|
Description
|
None
|
None
|
Return Value
|
Description
|
Returned information
|
Obtained logs
|
Example:
hdc\_std hilog
- **shell \[_command_\]**
Executes a command remotely or enters an interactive command environment.
**Table 15** Command description
Parameter
|
Description
|
command
|
Command to be executed
|
Return Value
|
Description
|
Returned information
|
Execution result of the command
|
Examples:
hdc\_std shell