Use TCP API
1 Overview
TCP (Transmission Control Protocol) is a commonly used network transport protocol primarily designed to ensure the reliability and order of network communication. TCP API commands are data instructions (messages or commands) exchanged between the client and server during TCP-based communication for purposes such as control, operation, and querying. This document focuses on the communication between Hesai lidar and a host computer.
2 Application Method
The usage of TCP API commands is as follows:
- Connect the lidar to the host computer and ensure proper communication is established (refer to Configure Ethernet for details);
- Send TCP API commands from the host computer to the lidar, receive the response from the lidar, and parse the response based on the TCP API manual to confirm whether the command was successfully executed.
This document introduces three different methods for sending TCP API commands along with corresponding examples. User can choose one or more methods based on the actual needs.
Note: The following examples are based on the TCP API command of changing the operation mode (0x1C) on OT128. The TCP API commands for different lidar models may vary. Please refer to the TCP API manual of the specific model.
3 Examples
3.1 Sending TCP API Commands through LidarUtilities
Download and install LidarUtilities from Hesai's official website. Open the software and switch to the "Send PTC Command" interface. Enter the corresponding command code and payload in the "Send Command" field. The response is shown as follows:

Here, 47 74
is the identifier, 1C
represents the command just sent, the fourth byte 00
is the return code indicating "No error," and the fifth to eighth bytes 00
indicate no payload information.
Note: LidarUtilities only supports some Hesai lidar models (OT128, AT128P, etc.).
3.2 Sending TCP API Commands through Python Scripts
If the current lidar model does not support LidarUtilities, users can use the Python script provided by Hesai. Configure the following settings based on the actual requirement:
After completing the configuration, run the script to send the specified TCP API command to the lidar and receive the corresponding response. The output is as follows:
payload :
01
response:
b'Gt\x1c\x00\x00\x00\x00\x00'
command is: 1c, get return code: 00, return length: 0,
return string:
{'response_command': '1c', 'response_return_code': '00', 'response_payload_length':0,'response_payload': b''}
Here, the return code
00
indicates that the command was successfully executed with "No error". Additionally, users can also use Wireshark to analyze the TCP packets sent by the lidar to obtain the results. As shown in the image below, the returned data field contains 47 74
is the data identifier, 1C
is the command just sent, the fourth byte 00
is the return code indicating "No error", and the fifth to eighth bytes 00
indicating no payload information.

3.3 Sending TCP API Commands through External Tools (Packet Sender)
Download and install Packet Sender, a free and open-source tool. Its using method is similar to LidarUtilities.
As shown in the image below, enter the raw command (Hex format) in the HEX field, configure the corresponding lidar IP address and TCP port, select the "TCP" mode, and click "Send". Then users can check the sent command and received response in the Log window below (the response needs to be parsed based on the instructions from TCP API manual).
