Ich erhalte in netbuf[130] Daten und die ersten Bytes stellen den header dar. Ich möchte nichts umkopieren, sondern jeglich nur auf das erste Byte des Buffers zugreifen können mit: net_header_t x; x.command = 1; Gibt es da ein cast wie: x = (net_header_t)netbuf;
1 | typedef struct __attribute__((__packed__)) |
2 | { |
3 | uint8_t command; |
4 | union |
5 | { |
6 | uint8_t val; |
7 | struct |
8 | { |
9 | uint8_t direction : 1; |
10 | uint8_t ack_ok : 1; |
11 | uint8_t ack_error : 1; |
12 | uint8_t rsvd : 5; |
13 | } bits; |
14 | } status; |
15 | } net_header_t; |
16 | |
17 | static uint8_t netbuf[130]; |