Casting to uint8_t is a good solution given the nature of the structs we are copying to/from:
can_health_t is packed so it is fine to consider it an array of uint8_t
ControlPacket_t is packed so it is fine to consider it an array of uint8_t + trying to set each fields manually will make assumptions about endianness (since some ControlPacket_t elements are uint16_t and the buffer elements are uint8_t)
CANPacket_t is mostly a bit field struct that would require getting each fields manually with bit-wise operations and make assumptions about the order of the bits in the struct. But since it is also a packed struct, it is fine to just assume an array of uint8_t and proceed as before.
Casting to uint8_t is a good solution given the nature of the structs we are copying to/from:
can_health_t
is packed so it is fine to consider it an array of uint8_tControlPacket_t
is packed so it is fine to consider it an array of uint8_t + trying to set each fields manually will make assumptions about endianness (since someControlPacket_t
elements are uint16_t and the buffer elements are uint8_t)CANPacket_t
is mostly a bit field struct that would require getting each fields manually with bit-wise operations and make assumptions about the order of the bits in the struct. But since it is also a packed struct, it is fine to just assume an array of uint8_t and proceed as before.