README.md
1# HDC-OpenHarmony Device Connector<a name="EN-US_TOPIC_0000001149090043"></a>
2
3- [HDC-OpenHarmony Device Connector<a name="EN-US_TOPIC_0000001149090043"></a>](#hdc-OpenHarmony-Device-Connector)
4 - [Introduction<a name="section662115419449"></a>](#introduction)
5 - [Architecture<a name="section15908143623714"></a>](#architecture)
6 - [Table of Contents<a name="section161941989596"></a>](#table-of-contents)
7 - [PC-side compilation instructions<a name="section129654513262"></a>](#pc-side-compilation-instructions)
8 - [Getting instructions on pc<a name="section129654513263"></a>](#getting-instructions-on-pc)
9 - [More help and docs<a name="section129654513264"></a>](#more-help-and-docs)
10
11## Introduction<a name="section662115419449"></a>
12
13HDC (OpenHarmony Device Connector) is a command-line tool for developers to connect and debug the device. The PC-side development machine uses the command-line tool hdc (for convenience, collectively referred to as hdc below). This tool needs to support deployment on Windows/Linux /Mac and other systems to connect and debug communication with OpenHarmony devices (or simulators). The PC-side hdc tool needs to release corresponding versions for the above development machine operating system platforms, and the device-side hdc daemon needs to follow the device image release including support for the simulator. The following will introduce the commonly used commands and usage examples of hdc.
14
15## Architecture<a name="section15908143623714"></a>
16
17HDC mainly consists of three parts:
18
191. The hdc client part: the client running on the development machine, the user can request to execute the corresponding hdc command under the command terminal of the development machine (windows cmd/linux shell), running on the development machine, other terminal debugging IDEs also include hdc client .
20
212. The hdc server part: As a background process, it also runs on the development machine. The server manages the communication between the client and the device-side daemon, including the multiplexing of connections, the sending and receiving of data communication packets, and the direct processing of individual local commands.
22
233. The hdc daemon part: the daemon is deployed on the OpenHarmony device running on demand, and is responsible for processing requests from the client side.
24
25## Table of Contents<a name="section161941989596"></a>
26
27```
28/developtools
29├── hdc # hdc code directory
30│ └── src
31│ ├── common # Code directory shared by the device side and the host side
32│ ├── daemon # Code directory on the device side
33│ ├── host # The code directory of the host
34│ └── test # Code directory of test case
35```
36
37### PC-side compilation instructions<a name="section129654513262"></a>
38
39
40Compilation steps of hdc pc executable file:
41
421. Compile command: Please refer to https://gitee.com/openharmony/build/blob/master/README_zh.md to compile the sdk instructions, execute the specified sdk compile command to compile the entire sdk, hdc will be compiled Pack it inside.
43
442. Compile: Run the sdk compilation command adjusted above on the target development machine, and the normal compilation of hdc will be output to the relevant directory of the sdk platform; Note: Only the windows/linux version tools can be compiled in the ubuntu environment, and the mac version needs to be on the macos development machine Compile.
45
46
47### Getting instructions on pc<a name="section129654513263"></a>
48
49[1. Download sdk to obtain (recommended)](#section161941989591)
50```
51Download the dailybuilds or officially released sdk compressed package by visiting the community website, and unzip and extract it according to your platform to the corresponding directory toolchain
52```
53
54[2. Compile by yourself](#section161941989592)
55
56For compilation, please refer to the separate section above. Prebuilt is no longer available in the prebuilt directory of this project warehouse.
57
58
59[3. Support operating environment](#section161941989593)
60
61The linux version is recommended to be 64-bit above ubuntu 16.04, and other similar versions are also available; libc++.so quotes errors, please use ldd/readelf and other commands to check the library. Windows version is recommended. Windows 10 64-bit is recommended. If the lower version of the windows winusb library is missing, please use zadig to update the library. .
62
63## More help and docs<a name="section129654513264"></a>
64
65Please check the Chinese description file ‘README_zh.md’ or raise an issue in the gitgee community.
66
README_zh.md
1# HDC-OpenHarmony设备连接器<a name="ZH-CN_TOPIC_0000001149090043"></a>
2
3- [HDC-OpenHarmony设备连接器<a name="ZH-CN_TOPIC_0000001149090043"></a>](#)
4 - [简介<a name="section662115419449"></a>](#简介)
5 - [架构<a name="section15908143623714"></a>](#架构)
6 - [目录<a name="section161941989596"></a>](#目录)
7 - [pc端编译说明<a name="section129654513262"></a>](#pc端编译说明)
8 - [pc端获取说明<a name="section129654513263"></a>](#pc端获取说明)
9 - [Linux端USB设备权限说明<a name="section129654513264"></a>](#linux端usb设备权限说明)
10 - [命令帮助<a name="section129654513265"></a>](#命令帮助)
11 - [使用问题自查说明<a name="section1371113476307"></a>](#使用问题自查说明)
12 - [FAQ<a name="section1371113476308"></a>](#faq)
13
14## 简介<a name="section662115419449"></a>
15
16HDC(OpenHarmony Device Connector) 是为开发人员提供的用于设备连接调试的命令行工具,pc端开发机使用命令行工具hdc,该工具需支持部署在Windows/Linux/Mac等系统上与OpenHarmony设备(或模拟器)进行连接调试通信。PC端hdc工具需要针对以上开发机操作系统平台分别发布相应的版本,设备端hdc daemon需跟随设备镜像发布包括对模拟器进行支持。下文将介绍hdc的常用命令及使用举例。
17
18## 架构<a name="section15908143623714"></a>
19
20hdc主要有三部分组成:
21
221. hdc client部分:运行于开发机上的客户端,用户可以在开发机命令终端(windows cmd/linux shell)下请求执行相应的hdc命令,运行于开发机器,其它的终端调试IDE也包含hdc client。
23
242. hdc server部分:作为后台进程也运行于开发机器,server管理client和设备端daemon之间通信包括连接的复用、数据通信包的收发,以及个别本地命令的直接处理。
25
263. hdc daemon部分:daemon部署于OpenHarmony设备端作为守护进程来按需运行,负责处理来自client端的请求。
27
28## 目录<a name="section161941989596"></a>
29
30```
31/developtools
32├── hdc # hdc代码目录
33│ └── src
34│ ├── common # 设备端和host端公用的代码目录
35│ ├── daemon # 设备端的代码目录
36│ ├── host # host端的代码目录
37│ └── test # 测试用例的代码目录
38```
39
40### pc端编译说明<a name="section129654513262"></a>
41
42
43hdc pc端可执行文件编译步骤:
44
451. 编译命令:编译sdk命令 请参考https://gitee.com/openharmony/build/blob/master/README_zh.md 仓编译sdk说明, 执行其指定的sdk编译命令来编译整个sdk, hdc会被编译打包到里面。
46
472. 编译:在目标开发机上运行上面调整好的sdk编译命令, 正常编译hdc会输出到sdk平台相关目录下; 注意: ubuntu环境下只能编译windows/linux版本工具,mac版需要在macos开发机上编译。
48
49### pc端获取说明<a name="section129654513263"></a>
50
511.下载sdk获取(建议)
52```
53通过访问本社区网站下载dailybuilds(http://ci.openharmony.cn/dailys/dailybuilds)或正式发布的sdk压缩包,从中根据自己平台到相应的目录toolchain下解压提取
54```
55
562.自行编译
57
58编译请参考上面单独小节,本项目仓prebuilt目录下不再提供预制
59
60
613.支持运行环境
62
63linux版本建议ubuntu 18.04以上 64位,其他相近版本也可;libc++.so引用错误请使用ldd/readelf等命令检查库引用 windows版本建议windows10 64位,如果低版本windows winusb库缺失,请使用zadig更新库。对于复合设备,需要使用zadig工具安装libusb-win32驱动。
64
65
66### Linux端USB设备权限说明<a name="section129654513264"></a>
67
68
69在Linux下在非root权限下使用hdc会出现无法找到设备的情况,此问题原因为用户USB操作权限问题,解决方法如下:
70
711. 开启非root用户USB设备操作权限
72 该操作方法简单易行,但是可能存在潜在安全问题,请根据使用场景自行评估
73 ```
74 sudo chmod -R 777 /dev/bus/usb/
75 ```
762. 永久修改 USB 设备权限
77 1)使用lsusb命令找出USB设备的vendorID和productID
78 2)创建一个新的udev规则
79
80 编辑UDEV加载规则,用设备的"idVendor"和"idProduct"来替换默认值。MODE="0666"表示USB设备的权限
81 GROUP代表用户组,要确保此时登录的系统用户在该用户组中
82 可用 "usermod -a -G username groupname" 将用户添加到用户组中
83 ```
84 sudo vim /etc/udev/rules.d/90-myusb.rules
85 SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="users", MODE="0666"
86 ```
87 重启电脑或重新加载 udev 规则
88 ```
89 sudo udevadm control --reload
90 ```
913. su 切换到root用户下运行测试程序
92 ```
93 sudo hdc list targets
94 ```
95
96### 命令帮助<a name="section129654513265"></a>
97
98hdc当前常用命令如下,未尽命令使用hdc -h或者hdc --help查看:
99
100**表 1** hdc常用命令列表
101
102<table><thead align="left"><tr id="row149291357182511"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p14423184344212"><a name="p14423184344212"></a><a name="p14423184344212"></a>Option</p>
103</th>
104<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p164237433425"><a name="p164237433425"></a><a name="p164237433425"></a>Description</p>
105</th>
106</tr>
107</thead>
108<tbody><tr id="row139291857142520"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1042344310428"><a name="p1042344310428"></a><a name="p1042344310428"></a>-t <em id="i198036018011"><a name="i198036018011"></a><a name="i198036018011"></a>key</em></p>
109</td>
110<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19423174317428"><a name="p19423174317428"></a><a name="p19423174317428"></a>用于<span>指定连接该指定设备识Key</span></p>
111<p id="p2014511479313"><a name="p2014511479313"></a><a name="p2014511479313"></a>举例:hdc -t *****(设备id) shell</p>
112</td>
113</tr>
114<tr id="row1092965782514"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p04231743194215"><a name="p04231743194215"></a><a name="p04231743194215"></a>-s <em id="i510618125015"><a name="i510618125015"></a><a name="i510618125015"></a>socket</em></p>
115</td>
116<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p5424134314429"><a name="p5424134314429"></a><a name="p5424134314429"></a>用于<span>指定服务监听的socket配置</span></p>
117<p id="p1599174953215"><a name="p1599174953215"></a><a name="p1599174953215"></a>举例:hdc -s ip:port</p>
118</td>
119</tr>
120<tr id="row4929185718255"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p17424204354216"><a name="p17424204354216"></a><a name="p17424204354216"></a>-h/help -v/version</p>
121</td>
122<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p742444364214"><a name="p742444364214"></a><a name="p742444364214"></a><span>用于显示hdc相关的帮助、版本信息</span></p>
123</td>
124</tr>
125<tr id="row4929185718355"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p17424204354316"><a name="p17424204354316"></a><a name="p17424204354316"></a>-l 0-5</p>
126</td>
127<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p742444364314"><a name="p742444364314"></a><a name="p742444364314"></a><span>用于指定运行时日志等级</span></p>
128<p id="p23801376355"><a name="p23801376355"></a><a name="p23801376355"></a>举例: hdc -l5 start</p>
129</td>
130</tr>
131<tr id="row4929185718335"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p17424204354336"><a name="p17424204354336"></a><a name="p17424204354336"></a>checkserver</p>
132</td>
133<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p742444364334"><a name="p742444364334"></a><a name="p742444364334"></a><span>用于获取client-server版本</span></p>
134<p id="p23801376341"><a name="p23801376341"></a><a name="p23801376341"></a>举例: hdc checkserver </p>
135</td>
136</tr>
137<tr id="row169301574251"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p13424743134216"><a name="p13424743134216"></a><a name="p13424743134216"></a>list targets[-v]</p>
138</td>
139<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p6424643164211"><a name="p6424643164211"></a><a name="p6424643164211"></a><span>显示所有已经连接的目标设备列表</span>,-v选项显示详细信息</p>
140<p id="p423202318349"><a name="p423202318349"></a><a name="p423202318349"></a>举例: hdc list targets</p>
141</td>
142</tr>
143<tr id="row139301957122519"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8424164318423"><a name="p8424164318423"></a><a name="p8424164318423"></a>target mount</p>
144</td>
145<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p13424154324215"><a name="p13424154324215"></a><a name="p13424154324215"></a><span>以读写模式挂载/vendor、/data等分区,因为安全性问题,需要挂在根目录或者/system分区</br>请单独使用'hdc shell mount -o rw,remount /'等命令</span></p>
146<p id="p23801376351"><a name="p23801376351"></a><a name="p23801376351"></a>举例: hdc target mount</p>
147</td>
148</tr>
149<tr id="row139301957122511"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8424164318421"><a name="p8424164318421"></a><a name="p8424164318421"></a>target boot</p>
150</td>
151<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p13424154324211"><a name="p13424154324211"></a>重启设备</p>
152<p id="p23801376355"><a name="p23801376355"></a><a name="p23801376355"></a>举例: hdc target boot</p>
153</td>
154</tr>
155<tr id="row5930657142518"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1642534318425"><a name="p1642534318425"></a><a name="p1642534318425"></a>smode [-r]</p>
156</td>
157<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p44253434422"><a name="p44253434422"></a><a name="p44253434422"></a>授予后台服务进程root权限, 使用-r参数取消授权</p>
158<p id="p9806102118436"><a name="p9806102118436"></a><a name="p9806102118436"></a>举例: hdc smode</p>
159</td>
160</tr>
161<tr id="row893010573254"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1842544334210"><a name="p1842544334210"></a><a name="p1842544334210"></a>kill [-r]</p>
162</td>
163<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p11425543124210"><a name="p11425543124210"></a><a name="p11425543124210"></a><span>终止hdc服务进程</span>, -r选项会触发再次重启hdc server</p>
164<p id="p162862374437"><a name="p162862374437"></a><a name="p162862374437"></a>举例: hdc kill</p>
165</td>
166</tr>
167<tr id="row865473444617"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p5655334184610"><a name="p5655334184610"></a><a name="p5655334184610"></a>start [-r]</p>
168</td>
169<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p819155019464"><a name="p819155019464"></a><a name="p819155019464"></a><span>启动hdc服务进程</span>, -r选项会触发重启hdc server</p>
170<p id="p219115074615"><a name="p219115074615"></a><a name="p219115074615"></a>举例: hdc start</p>
171</td>
172</tr>
173<tr id="row1493015702512"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1542610433424"><a name="p1542610433424"></a><a name="p1542610433424"></a>tconn <em id="i82358142025"><a name="i82358142025"></a><a name="i82358142025"></a>host</em>[:<em id="i860817161021"><a name="i860817161021"></a><a name="i860817161021"></a>port</em>][-remove]</p>
174</td>
175<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p17426174384210"><a name="p17426174384210"></a><a name="p17426174384210"></a>通过【ip地址:端口号】来指定连接的设备</p>
176<p id="p15653482487"><a name="p15653482487"></a><a name="p15653482487"></a>使用TCP模式连接设备,需在USB模式工作下使用tmode tcp切换至TCP工作模式,或者在<br>系统属性值中设置persist.hdc.mode属性值为tcp,如果需要监听固定TCP端口需要再设置<br>persist.hdc.port的端口号,反之则TCP监听端口随机</p>
177<p id="p15653482488"><a name="p15653482488"></a><a name="p15653482488"></a>举例: hdc tconn 192.168.0.100:10178</p>
178</td>
179</tr>
180<tr id="row193125772516"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p542613431429"><a name="p542613431429"></a><a name="p542613431429"></a>tmode usb</p>
181</td>
182<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19426174319422"><a name="p19426174319422"></a><a name="p19426174319422"></a><span>执行后设备端对应daemon进程重启,并首先选用usb连接方式</span></p>
183</td>
184</tr>
185<tr id="row1184551114811"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1742614354215"><a name="p1742614354215"></a><a name="p1742614354215"></a>tmode port <em id="i1850518591411"><a name="i1850518591411"></a><a name="i1850518591411"></a>port-number</em></p>
186</td>
187<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p124267438425"><a name="p124267438425"></a><a name="p124267438425"></a><span>执行后设备端对应daemon进程重启,并优先使用网络方式连接设备,如果连接设备再选择usb连接</span></p>
188</td>
189</tr>
190<tr id="row1157737165213"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p442704315428"><a name="p442704315428"></a><a name="p442704315428"></a>file send<em id="i34274438428"><a name="i34274438428"></a><a name="i34274438428"></a> </em><em id="i6958481309"><a name="i6958481309"></a><a name="i6958481309"></a>local remote</em></p>
191</td>
192<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12427114316425"><a name="p12427114316425"></a><a name="p12427114316425"></a><span>从host端发送文件至设备</span>端</p>
193<p id="p292614408162"><a name="p292614408162"></a><a name="p292614408162"></a>举例: hdc file send E:\a.txt /data/local/tmp/a.txt</p>
194</td>
195</tr>
196<tr id="row8748171465317"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p7427164310425"><a name="p7427164310425"></a><a name="p7427164310425"></a>file recv [-a] <em id="i1880435111020"><a name="i1880435111020"></a><a name="i1880435111020"></a>remote local</em></p>
197</td>
198<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19427143174220"><a name="p19427143174220"></a><a name="p19427143174220"></a><span>从设备端拉出文件至本地</span>host端</p>
199<p id="p191761424101713"><a name="p191761424101713"></a><a name="p191761424101713"></a>举例: hdc file recv /data/local/tmp/a.txt ./a.txt</p>
200</td>
201</tr>
202<tr id="row1973583819559"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p20428943104259"><a name="p20428943104259"></a><a name="p20428943104259"></a>fport <em id="i84129581558"><a name="i84129581558"></a><a name="i84129581558"></a>localnode remotenode</em></p>
203</td>
204<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p0428144314459"><a name="p0428144314459"></a><a name="p0428144314459"></a><span>端口转发</span><span id="text442834344259"><a name="text442834344259"></a><a name="text442834344259"></a>主机端口 转发数据到 设备侧端口</span></p>
205<p id="p23801376355"><a name="p23801376355"></a><a name="p23801376355"></a>举例: hdc fport tcp:1234 tcp:1080</p>
206</td>
207</tr>
208<tr id="row1973583819359"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p20428943104359"><a name="p20428943104359"></a><a name="p20428943104359"></a>rport <em id="i84129581358"><a name="i84129581358"></a><a name="i84129581358"></a>remotenode localnode</em></p>
209</td>
210<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p0428144314359"><a name="p0428144314359"></a><a name="p0428144314359"></a><span>端口转发</span><span id="text442834344359"><a name="text442834344359"></a><a name="text442834344359"></a>设备侧端口 转发数据到 主机端口</span></p>
211<p id="p23801376355"><a name="p23801376355"></a><a name="p23801376355"></a>举例: hdc rport tcp:1234 tcp:1080</p>
212</td>
213</tr>
214<tr id="row193125772576"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p542613431479"><a name="p542613431479"></a><a name="p542613431479"></a>fport ls</p>
215</td>
216<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19426174319472"><a name="p19426174319472"></a><a name="p19426174319472"></a><span>展示全部转发任务</span></p>
217</td>
218</tr>
219<tr id="row139301957122511"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8424164318428"><a name="p8424164318428"></a><a name="p8424164318428"></a>fport rm</p>
220</td>
221<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p13424154324211"><a name="p13424154324211"></a>删除指定转发任务</p>
222<p id="p23801376358"><a name="p23801376358"></a><a name="p23801376358"></a>举例: hdc fport rm tcp:1234 tcp:1080</p>
223</td>
224</tr>
225<tr id="row887171025420"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p204287432425"><a name="p204287432425"></a><a name="p204287432425"></a>install<em id="i242704315422"><a name="i242704315422"></a><a name="i242704315422"></a> </em>[-r/-d/-g]<em id="i642814310424"><a name="i642814310424"></a><a name="i642814310424"></a> </em><em id="i103610557016"><a name="i103610557016"></a><a name="i103610557016"></a>package</em></p>
226</td>
227<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12428194312421"><a name="p12428194312421"></a><a name="p12428194312421"></a><span>安装</span><span id="text242884314423"><a name="text242884314423"></a><a name="text242884314423"></a>OpenHarmony</span><span> package</span></p>
228<p id="p1419642611411"><a name="p1419642611411"></a><a name="p1419642611411"></a>举例: hdc install E:\***.hap</p>
229</td>
230</tr>
231<tr id="row1973583819549"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p20428943104214"><a name="p20428943104214"></a><a name="p20428943104214"></a>uninstall [-k] <em id="i84129581508"><a name="i84129581508"></a><a name="i84129581508"></a>package</em></p>
232</td>
233<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p0428144314429"><a name="p0428144314429"></a><a name="p0428144314429"></a><span>卸载</span><span id="text442834344220"><a name="text442834344220"></a><a name="text442834344220"></a>OpenHarmony</span><span>应用</span></p>
234</td>
235</tr>
236<tr id="row1513010417560"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p84281143184214"><a name="p84281143184214"></a><a name="p84281143184214"></a>hilog</p>
237</td>
238<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p11428343144216"><a name="p11428343144216"></a><a name="p11428343144216"></a><span>支持查看抓取hilog调试信息</span></p>
239<p id="p555163671514"><a name="p555163671514"></a><a name="p555163671514"></a>举例: hdc hilog</p>
240</td>
241</tr>
242<tr id="row119311957172516"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p144297439423"><a name="p144297439423"></a><a name="p144297439423"></a>shell<em id="i15429144314210"><a name="i15429144314210"></a><a name="i15429144314210"></a> </em>[<em id="i04791261510"><a name="i04791261510"></a><a name="i04791261510"></a>command</em>]</p>
243</td>
244<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p16429843124213"><a name="p16429843124213"></a><a name="p16429843124213"></a><span>远程执行命令或进入交互命令环境</span></p>
245<p id="p1490692061519"><a name="p1490692061519"></a><a name="p1490692061519"></a>举例: hdc shell</p>
246</td>
247</tr>
248<tr id="row193125772572"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p542613431472"><a name="p542613431479"></a><a name="p542613431472"></a>jpid</p>
249</td>
250<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19426174319422"><a name="p19426174319422"></a><a name="p19426174319422"></a><span>获取JDWP调试进程列表 </span></p>
251</td>
252</tr>
253</tbody>
254</table>
255
256以下是常用hdc命令示例,供开发者参考:
257
258- 查看设备连接信息
259
260 ```
261 hdc list targets
262 ```
263
264- 往设备中推送文件
265
266 ```
267 hdc file send E:\a.txt /data/local/tmp/a.txt
268 ```
269
270- 从设备中拉取文件
271
272 ```
273 hdc file recv /data/local/tmp/a.txt ./a.txt
274 ```
275
276- 安装应用
277
278 ```
279 hdc install E:\***.hap
280 ```
281
282- 查看日志
283
284 ```
285 hdc hilog
286 ```
287
288- 进入命令行交互模式
289
290 ```
291 hdc shell
292 ```
293
294- TCP网络连接。
295
296 ```
297 hdc tconn 192.168.0.100:10178
298 ```
299
300
301## 使用问题自查说明<a name="section1371113476307"></a>
302
303工具使用过程中碰到问题,可以参考如下流程自助排查:
304
305* step1: 先检查pc(host)端hdc 和L2设备端hdcd版本是否一致(-v 查看版本):
306 - step1a: 版本不一致请更新使用一致版本再验证;
307 - step1b: 版本一致请继续下面排查step2步骤;
308* step2: 检查pc(host)端设备管理器设备信息是否正常(设备是否正常加载显示、驱动、id是否正常):
309 - step2a: 设备管理器设备异常或无设备, 请结合板测试设备端串口下确认下usb部分设备枚举上报是否异常;
310 - step2b: 设备管理器设备正常时,
3111)list targets 是否正常;
3122)hdc kill 后重试是否正常;
313
314**注意:客户端和设备端版本保持一致(hdc -v,hdcd -v参数查看版本)!**
315
316## FAQ<a name="section1371113476308"></a>
317- 1. list targets无设备:
318
319 ```
320 请参考上面《使用问题自查说明》小节
321 1)检查设备是否连接正常;
322 2)host端设备管理器设备信息是否正常;
323 3)两端工具版本是否一致;
324 4)设备端hdcd是否启动正常;
325 如果仍然无法解决问题,请尝试下面两种方法进行恢复
326 1)执行命令hdc kill来重启pc侧hdc服务;
327 2)重启端侧设备;
328 ```
329- 2. 同样版本windows下正常,linux下无设备:
330
331 ```
332 同问题1同样排查步骤,另外注意在root权限下执行;
333 如果server进程起不来,请先sudo rm /tmp/*.pid 然后再使用sudo 执行list targets看看是否正常显示设备列表
334 ```
335- 3. windows版本工具无法执行报错:
336
337 ```
338 1)从dailybuild或正式发布的sdk压缩包,重新解压提取工具;
339 2)检查文件大小和版本、校验哈希值;
340 3)本工具是控制台命令行下执行即可,适配平台下无任何组件和驱动依赖,不需要安装,不要尝试双击运行;
341 ```
342- 4. system分区推文件报错 [Fail]Error opening file: read-only file system:
343
344 ```
345 推送文件前参考执行如下命令:
346 hdc smode
347 hdc shell mount -o rw,remount /
348 ```
349