58. Serialized Data Buffer

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:

FieldSizeDescription
Start1 byteAlways 0xA5
Command1 byteUser input
Value2 byte16-bit data (uint16_t)
Status1 byteFlags (0 or 1)
Checksum4 byte32-bit checksum (uint32_t)
End1 byteAlways 0x5A

Your task is to:

  • Fill a uint8_t buffer[10] with the data in this order
  • Use pointer casting or byte manipulation
  • Print the entire buffer contents as space-separated integers
     

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


 

Loading...

Input

1 4660 1 2864434397

Expected Output

165 1 52 18 1 221 204 187 170 90