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

- Extract the zip file and open the project in DevEco Studio to view the source code.
1.2 Obtaining the Case HAP Package
- Download SerialTool_API12.hap from Baidu Netdisk.
Link: https://pan.baidu.com/s/1cI0q2Lc9I-xDgQqDWTlFFA?pwd=re5h
Extraction code: re5h
2 Case Installation Tutorial
This section introduces how to use the application case by pushing the HAP package to M4-R1.
- Connect the computer's USB port to the M4-R1 OTG port, and open the command prompt (cmd) on the computer.
- Execute the following command to check if the HDC connection is successful. If successful, it will display the device as shown in the following figure.
hdc list targets
- Execute the following command to navigate to the directory where the HAP package is stored. In this case, the HAP package is stored on the desktop.
cd C:\Users\Administrator\DesktopSuccessful directory switching is shown in the following figure.

- Execute the following command to install the HAP package.
hdc install ${hap_name} #hap_name: The name of the HAP package
hdc install SerialTool_API12.hapUpon success, the following information will be returned.

The application icon will now appear on the development board desktop.

3 Case 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 computer.
- After connecting, enter the baud rate and click [Set Baud Rate] to set UART3's baud rate. This case uses 115200 as an example.
After successfully setting the baud rate, a success popup will appear. Click OK to confirm.

- Open the serial debug assistant on the computer, find the corresponding COM port, set the baud rate of the computer's serial debug assistant according to the baud rate set on the board, and click [Open] to proceed.

- Click [Open Serial] on the board's application interface. If it changes to [Close Serial], the serial port has been opened successfully.
- The data sending area and data receiving area can select formats. Choose ASCII or HEX format as needed.
- Fill in the content to be sent in the data sending input box and click send. The sent data can be viewed in the sent data records and the computer's serial debug assistant.
- Click [Start Receiving] in the data receiving area. If it changes to [Stop Receiving], receiving has been enabled successfully. At this point, data sent from the computer will be displayed in the receiving data box.
Note:
Attention:If the serial port is opened without starting receiving, the next time receiving is started, all data sent from the computer during that period will be displayed at once. This can be cleared by clicking [Clear Received Data].
The specific implementation effect is shown in the following figures:


