1 Star 0 Fork 4.9K

戈英祯 / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
oem_subsys_toolchain_hdc_guide.md 40.10 KB
一键复制 编辑 原始数据 按行查看 历史
duangavin123 提交于 2021-07-20 22:06 . update 导入OpenHarmony工程

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

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 appended to -t key 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 (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

Parameter

Description

-v

Prints detailed device information.

Return Value

Description

1. Device information

②[Empty]

1. A list of connected devices

2. 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

2. Error information

1. Information returned when the operation is successful.

2. The operation fails.

Example:

hdc_std kill

start [-r]

Starts a 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

Grants permission dynamically

Return Value

Description

1. Error information

2. None

1. The operation fails.

2. The operation is successful.

Example:

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

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

    1. 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.

    2. 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.

    3. 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.

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

搜索帮助