74. Unions-II

Question.4

A firmware engineer writes this for UART communication:

typedef union {
   struct __attribute__((packed)) {
       uint8_t sync;
       uint8_t len;
       uint8_t payload[4];
       uint8_t crc;
   } fields;
   uint8_t raw[7];
} UARTFrame;

UARTFrame tx;
tx.fields.sync = 0xAA;
tx.fields.len = 4;
// ... fill payload and crc ...
uart_write(tx.raw, 7);

What firmware technique does this demonstrate?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!