1 Star 0 Fork 5.1K

youguilin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
hdc_std-usage-guidelines.md 37.97 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-06-02 01:00 . update OpenHarmony 2.0 Canary

hdc_std Usage Guidelines

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

  • 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 /tmp/fileb ./

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

1
https://gitee.com/yougl/docs.git
git@gitee.com:yougl/docs.git
yougl
docs
docs
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891