Overview
This Python script is designed to establish a serial communication with a device (referred to as the Burro IPA) over a specified serial port. The main purpose of the script is to send a handshake message (@HLWD*) to the device and wait for an acknowledgment response (#ACK*). If the acknowledgment is received, it indicates that the device is ready for communication. The script includes error handling mechanisms to manage issues with the serial connection and allows for graceful termination via a keyboard interrupt.Functions
- The main function establishes serial communication over a specified USB or TTL connection using the provided port and baud rate.
- It enters a continuous loop to send a request message (@HLWD_) to the Burro IPA robot, initiating a handshake to establish communication.
- Upon receiving a response from the robot, it processes the incoming data to confirm if an acknowledgment (#ACK_) is received.
- If the acknowledgment is successful, the function prepares to send a status check request (?STTN_) to the robot, querying its current station status.
- It reads the response from the robot, interprets the data, and checks if the robot is stopped at a station.
- If the robot is confirmed to be stopped, the function sends a specific message to the robot and activates an LED to indicate the status visually.
Example
example_client_handshake.py