Misaligned

You inherited firmware for an environmental monitoring module. An I2C sensor at address 0x48 reports device ID, temperature, status, and pressure in a contiguous 6-byte register block starting at register 0x00:

Offset 0: device_id (1 byte) Offset 1: temp_lo (1 byte) } temperature, little-endian uint16 Offset 2: temp_hi (1 byte) } Offset 3: status (1 byte) Offset 4: press_lo (1 byte) } pressure, little-endian uint16 Offset 5: press_hi (1 byte) }

The firmware reads the register block into a C struct, then prints the parsed values over UART. Example correct output for device 0x5A, 21 C, status 0x02, pressure 985:

ID:0x5A TEMP:21 STATUS:0x02 PRESS:985

The code compiles without warnings, the I2C bus is active, and the device ID prints correctly. But the temperature, status, and pressure values are all wrong. Find and fix the bug.

Loading the interactive arena.