> 文档中心 > OpenHarmony 调试命令

OpenHarmony 调试命令

文章目录

  • 一、hdc
    • 1、设备
      • hdc 帮助手册
      • 查看当前连接设备
      • 重启设备
      • 设置屏幕旋转
      • power-shell
    • 2、文件
      • 获取文件到本地
      • 发送文件到设备
  • 二、Serial-COM
    • 设置电源模式、电源管理,例如屏幕常亮
    • 重启设备

本文源码默认为OpenHarmony v3.2 Beta4版本,如有纰漏,望不吝赐教~

一、hdc

1、设备

hdc 帮助手册

> hdc -h    OpenHarmony device connector(HDC) ...---------------------------------global commands:---------------------------------- -h/help   - Print hdc help -v/version- Print hdc version -l 0-5    - Set runtime loglevel -t connectkey    - Use device with given connect key checkserver      - check client-server version checkdevice      - check server-daemon version---------------------------------component commands:-------------------------------session commands(on server): discover  - Discover devices listening on TCP via LAN broadcast list targets [-v]- List all devices status, -v for detail tconn key - Connect device via key, TCP use ip:port      example:192.168.0.100:10178/192.168.0.100      USB connect automatic, TCP need to connect manually      UART connect need connect manually.      Baud Rate can be specified with commas.      key format: [,Baud Rate]      example: tconn COM5,921600      Default Baud Rate is 921600. start [-r]- Start server. If with '-r', will be restart server kill [-r] - Kill server. If with '-r', will be restart server -s [ip:]port     - Set hdc server listen configservice commands(on daemon): target mount     - Set /system /vendor partition read-write target boot [-bootloader|-recovery]   - Reboot the device or boot into bootloader\recovery. target boot [MODE]      - Reboot the into MODE. smode [-r]- Restart daemon with root permissions, '-r' to cancel root      permissions tmode usb - Reboot the device, listening on USB tmode port [port]- Reboot the device, listening on TCP port---------------------------------task commands:-------------------------------------file commands: file send [option] local remote- Send file to device file recv [option] remote local- Recv file from device      option is -a|-s|-z      -a: hold target file timestamp      -sync: just update newer file      -z: compress transfer      -m: mode syncforward commands: fport localnode remotenode     - Forward local traffic to remote device rport remotenode localnode     - Reserve remote traffic to local host      node config name format 'schema:content'      examples are below:      tcp:      localfilesystem:      localreserved:      localabstract:      dev:      jdwp: (remote only) fport ls  - Display forward/reverse tasks fport rm taskstr - Remove forward/reverse task by taskstringapp commands: install [-r] src - Send package(s) to device and install them      src examples: single or multiple packages and directories      (.hap)      -r: replace existing application uninstall [-k] package  - Remove application package from device      -k: keep the data and cache directoriesdebug commands: hilog [-v]- Show device log, -v for detail shell [COMMAND...]      - Run shell command (interactive shell if no command given) bugreport [PATH] - Return all information from the device, path will be save localpath jpid      - List pids of processes hosting a JDWP transport sideload [PATH]  - Sideload the given full OTA packagesecurity commands: keygen FILE      - Generate public/private key; key stored in FILE and FILE.pub---------------------------------flash commands:------------------------------------flash commands: update packagename      - Update system by package flash [-f] partition imagename - Flash partition by image erase [-f] partition    - Erase partition format [-f] partition

查看当前连接设备

#查看当前连接所有设备,-v 显示详情> hdc list targets (-v)7001005458323933328a59612f4b3900#设备为DAYU200 rk3568

重启设备

> hdc shell reboot#串口命令下直接输入reboot即可

设置屏幕旋转

源码路径:#foundation/window/window_manager/resources/config/${product}/display_manager_config.xml

#修改系统显示配置文件/system/etc/window/resources/display_manager_config.xml  buildInDefaultOrientation配置项,如下        #未指明    #横屏    #反横屏    0#Step1、获取display_manager_config.xml配置文件到本地> hdc file recv /system/etc/window/resources/display_manager_config.xml C:\Users\xxx\Desktop\hdcLog#Step2、修改本地display_manager_config.xml buildInDefaultOrientation配置项...3#由于DAYU200 DEBUG线、USB线与电脑连接原因,为了操作方便将屏幕设为反竖屏...#Step3、替换设备的display_manager_config.xml> hdc shell mount -o remount,rw /> hdc shell chmod 777 /system/etc/window/resources/display_manager_config.xml> hdc file send C:\Users\xxx\Desktop\hdcLog\display_manager_config.xml /system/etc/window/resources/display_manager_config.xml#Step4、重启设备> hdc shell reboot

power-shell

>hdc shell power-shellusage: power-shellcommand list:  setmode :    Set power mode.#设置电源模式  wakeup  :    Wakeup system and turn screen on.#唤醒系统,点亮屏幕  suspend :    Suspend system and turn screen off.#系统待机,熄灭屏幕  display :    Update or Override display brightness.#更新或覆盖屏幕亮度  timeout :    Override or Restore screen off time.#覆盖或重置熄屏时间  dump    :    Dump power info.#查看电源信息  help    :    Show this help menu.#展示帮助菜单

设置电源模式/电源管理,例如屏幕常亮

方法一:命令设置电源性能模式,保持屏幕常亮
注意:重启后需要重新设置,源码修改见底部

#设置性能模式,屏幕常亮;600:正常模式601:省电模式602:性能模式603:极省电模式> hdc shell power-shell setmode 602

方法二:修改设备电源管理配置文件power_mode_config.xml (原理可行,但实际无效,望大佬指点)

#Step1、获取power_mode_config.xml配置文件到本地> hdc file recv /system/etc/power_config/power_mode_config.xml C:\Users\xxx\Desktop\hdcLog#Step2、修改本地power_mode_config.xml 各个电源模式的DisplayOffTime 配置项设为-1,即功能关闭    -+             -+                           -+         #Step3、替换设备的power_mode_config.xml> hdc shell mount -o remount,rw /> hdc shell chmod 777 /system/etc/power_config/power_mode_config.xml> hdc file send C:\Users\xxx\Desktop\hdcLog\power_mode_config.xml /system/etc/power_config/power_mode_config.xml#Step4、重启设备> hdc shell reboot

如果想一劳永逸,可修改源码后编译即可。
源码路径:
base\powermgr\power_manager\services\native\profile\power_mode_config.xml

2、文件

获取文件到本地

> hdc file recv /system/etc/window/resources/display_manager_config.xml C:\Users\xxx\Desktop\hdcLog

发送文件到设备

#挂载系统根目录> hdc shell mount -o remount,rw /#替换设备display_manager_config.xml文件> hdc file send C:\Users\xxx\Desktop\hdcLog\display_manager_config.xml /system/etc/window/resources/display_manager_config.xml#若display_manager_config.xml文件只读,无权限操作,需更改其权限> hdc shell chmod 777 /system/etc/window/resources/display_manager_config.xml

二、Serial-COM

设置电源模式、电源管理,例如屏幕常亮

power-shell setmode 602

重启设备

reboot