74. Unions-II

Question.2

A developer transmits a union-based packet over SPI:

typedef union {
   struct {
       uint8_t cmd;
       uint16_t addr;
       uint8_t data;
   } fields;
   uint8_t raw[4];
} SPIFrame;

spi_transmit(frame.raw, 4);

He assumes the frame is exactly 4 bytes. Is this safe?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!