In firmware, you often need to assemble a communication packet as a byte array before sending it over UART/SPI.
You are given the following fields:
Field | Size | Description |
Start | 1 byte | Always 0xA5 |
Command | 1 byte | User input |
Value | 2 byte | 16-bit data (uint16_t) |
Status | 1 byte | Flags (0 or 1) |
Checksum | 4 byte | 32-bit checksum (uint32_t) |
End | 1 byte | Always 0x5A |
Your task is to:
Example-1
Input:
Command = 0x01
Value = 0x1234
Status = 1
Checksum = 0xAABBCCDD
Output:
165 1 52 18 1 221 204 187 170 90
Example-2
Input:
Command = 0xFF
Value = 0x00FF
Status = 0
Checksum = 0x01020304
Output:
165 255 255 0 0 4 3 2 1 90
Input
1 4660 1 2864434397
Expected Output
165 1 52 18 1 221 204 187 170 90