-
Notifications
You must be signed in to change notification settings - Fork 0
Command Structure
IoliteCoding edited this page Aug 5, 2024
·
1 revision
This document describes the structure of commands used for communication over a serial interface. Each command is a structured message consisting of several key components. The protocol is designed to ensure reliable and efficient data transmission.
Each command consists of the following components:
-
Start Byte:
-
Value:
0xFE(254) - Purpose: Marks the beginning of a command message.
-
Value:
-
Message Length:
- Purpose: Specifies the total length of the command excluding the start byte, stop byte, and the length byte itself.
-
Value Range: The length can range from
0x00to0xFD(253) since0xFEand0xFFare reserved.
-
Address:
- Purpose: Identifies the target or type of the command.
- Format: At least one byte is required to specify the address. Addresses use a base-200 numbering system, allowing for extended address ranges.
-
Data (Optional):
- Purpose: Contains the command's payload or additional information.
- Format: May include zero or more bytes. The data field is optional and can be omitted if not needed.
-
Stop Byte:
-
Value:
0xFF(255) - Purpose: Indicates the end of the command.
-
Value:
Here are examples illustrating commands with and without data:
| Start | Message Length | Address | Data | Stop |
|---|---|---|---|---|
| 0xFE | 0x02 | 0x0A | 0x7C | 0xFF |
- 0xFE: Start byte.
- 0x02: Message length indicates a total of 2 bytes for address and data.
- 0x0A: Address byte for command number 10.
-
0x7C: Data byte (
'|'in ASCII). - 0xFF: Stop byte.
| Start | Message Length | Address | Stop |
|---|---|---|---|
| 0xFE | 0x01 | 0x0B | 0xFF |
- 0xFE: Start byte.
- 0x01: Message length indicates 1 byte for the address.
- 0x0B: Address byte for command number 11.
- 0xFF: Stop byte.
-
Single Byte Address: Supports values from
0x00to0xC7. - Multiple Byte Address: For larger address ranges, multiple bytes can be used, leveraging a base-200 system.
-
Address 316:
- Requires two bytes:
0x01(1) and0x74(116) - Calculation:
(1 * 200^1) + (116 * 200^0)
- Requires two bytes:
-
Address 605:
- Requires two bytes:
0x03(3) and0x05(5) - Calculation:
(3 * 200^1) + (5 * 200^0)
- Requires two bytes:
-
Address 456703:
- Requires three bytes:
0x11(11),0x53(83),0x67(103) - Calculation:
(11 * 200^2) + (83 * 200^1) + (103 * 200^0)
- Requires three bytes:
The command structure is designed for flexible and efficient serial communication, supporting optional data fields and an extended addressing system while maintaining a consistent framework for transmitting commands and data.