From 24f63b261bb0932152a2dc65d8ebc4a3b463f6be Mon Sep 17 00:00:00 2001 From: Klagarge Date: Mon, 4 Sep 2023 07:33:33 +0200 Subject: [PATCH] fix union --- 306-controller_interface.X/middleware/can_interface.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/306-controller_interface.X/middleware/can_interface.c b/306-controller_interface.X/middleware/can_interface.c index 6c893fd..ab667e2 100644 --- a/306-controller_interface.X/middleware/can_interface.c +++ b/306-controller_interface.X/middleware/can_interface.c @@ -34,9 +34,7 @@ typedef union { uint8_t byte2; uint8_t byte3; } separate; - struct { - uint32_t bytes; - } full; + uint32_t full; } CAN_4_BYTES; void CAN_init(){ @@ -55,6 +53,7 @@ bool CAN_processEvent(Event* ev) { evIDT evid = Event_getId(ev); uint64_t data = Event_getData(ev); + CAN_4_BYTES tmpData; switch (me->state) { // onState @@ -72,8 +71,7 @@ bool CAN_processEvent(Event* ev) { uint32_t canData = (uint32_t) data; data = data>>32; - CAN_4_BYTES tmpData; - tmpData.full.bytes = data; + tmpData.full = data; uint8_t idMsg = tmpData.separate.byte0; idMsg = idMsg >> 4; idMsg = idMsg & 0xF;