Serial-Debug-Assistant Application Demo
1 Demo Source Code and HAP Package Acquisition
1.1 Demo Source Code Acquisition
- Download SerialTool_API12.zip from the Baidu Netdisk materials. Link: https://pan.baidu.com/s/1Zq6Ui-348QDMuqMnO9lOCA?pwd=fw8w
Extraction code: fw8w

- After extracting the compressed package, open the project through DevEco Studio to view the source code.
1.2 Demo HAP Package Acquisition
- Download SerialTool_API12.hap from the Baidu Netdisk materials. Link: https://pan.baidu.com/s/1cI0q2Lc9I-xDgQqDWTlFFA?pwd=re5h
Extraction code: re5h
2 Demo Installation Tutorial
Taking pushing a HAP package to the M4-R1 as an example, this introduces how to use the application demo.
- Connect the PC's USB port to the M4-R1's OTG port, and open Command Prompt (cmd) on the PC.
- Run the following command to check whether the HDC connection is successful. If successful, the device will be displayed as shown in the figure below.
hdc list targets
- Run the following command to switch to the directory where the HAP package is stored. In this demo the HAP package is stored on the desktop.
cd C:\Users\Administrator\DesktopIf the directory switch succeeds, it will appear as shown below.

- Run the following command to install the HAP package.
hdc install ${hap_name} #hap_name:HAP 包的名字
hdc install SerialTool_API12.hapOn success, the following information will be returned.

At this point the application icon will be displayed on the development board's desktop.

3 Demo Function Introduction
- Click the desktop icon to enter the application interface.

Note:
When using this application, the development board's UART3 must be connected to the PC.
- After the connection is complete, enter the baud rate and click [Set Baud Rate] to set the UART3 baud rate. This demo uses 115200 as an example. After the baud rate is set successfully, a popup will prompt that the setting succeeded. Click OK.

- Open the serial-debug assistant on the PC, find the corresponding COM port, and set the PC serial-debug-assistant baud rate according to the baud rate set on the board. Click [Open].

- Click [Open Serial Port] in the board application interface. If it changes to [Close Serial Port], the serial port has been opened normally.
- The data-send area and data-receive area can select a format. Choose ASCII or HEX format according to your needs.
- Fill in the content to be sent in the data-send input box and click Send. You can then view the sent information in the sent-data record and in the PC serial-debug assistant.
- Click [Start Receiving] in the data-receive area. If it changes to [Stop Receiving], receiving has been enabled successfully. At this point, data sent from the PC will be displayed in the received-data box.
Note:
Note:If the serial port is opened but receiving is not started, the data previously sent from the PC will be displayed all at once the next time receiving is started. You can clear it via [Clear Received Data].
The specific implementation effect is shown in the figure below:


