diff --git a/mac_sender.c b/mac_sender.c index 6f78500..709ddbd 100644 --- a/mac_sender.c +++ b/mac_sender.c @@ -126,10 +126,12 @@ void MacSender(void *argument) { } else { // Checksum error, send original message again if(lastSentMsgPtr != NULL) { - retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr); - CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); + //retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr); + //CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); + + memcpy(queueMsg.anyPtr, lastSentMsgPtr, sizeof(lastSentMsgPtr)); queueMsg.type = TO_PHY; - queueMsg.anyPtr = lastSentMsgPtr; + //queueMsg.anyPtr = lastSentMsgPtr; retCode = osMessageQueuePut( queue_phyS_id, &queueMsg, @@ -240,7 +242,7 @@ void MacSender(void *argument) { msg = osMemoryPoolAlloc(memPool, 0); // TODO - Leak of memory if(msg == NULL) { - printf("Memory allocation failed\r\n"); + printf("Memory allocation failed #1\r\n"); assert(false); } msg[0] = src.raw; @@ -254,8 +256,15 @@ void MacSender(void *argument) { CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); if(dst.addr != BROADCAST_ADDRESS) { - lastSentMsgPtr = osMemoryPoolAlloc(memPool, osWaitForever); - memcpy(lastSentMsgPtr, msg, length+4); + if(dst.sapi == CHAT_SAPI) { + lastSentMsgPtr = osMemoryPoolAlloc(memPool, 0); + if(lastSentMsgPtr == NULL) { + printf("Memory allocation failed #2\r\n"); + assert(false); + } + memcpy(lastSentMsgPtr, msg, length+4); + // TODO test if station is online + } } queueMsg.anyPtr = msg; diff --git a/main.h b/main.h index 5c94e42..2cf9529 100644 --- a/main.h +++ b/main.h @@ -139,3 +139,17 @@ typedef union { }; uint8_t raw; } Status; + +typedef union { + struct { + bool_t nothing0: 1; // MSB + bool_t chat: 1; + bool_t nothing2: 1; + bool_t time: 1; + bool_t nothing4: 1; + bool_t nothing5: 1; + bool_t nothing6: 1; + bool_t nothing7: 1; // LSB + }; + uint8_t raw; +} SapiToken; diff --git a/tokenring_project.uvoptx b/tokenring_project.uvoptx index ee93c83..ca70f24 100644 --- a/tokenring_project.uvoptx +++ b/tokenring_project.uvoptx @@ -120,7 +120,7 @@ 0 EVENTREC_CNF - -l2 -a1 -s0 -f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + -l0 -a1 -s0 -f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 @@ -145,7 +145,7 @@ 0 ST-LINKIII-KEIL_SWO - -U066DFF485153826687131237 -O8398 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP (ARM Core") -D00(5BA02477) -L00(0) -TO131075 -TC216000000 -TT216000000 -TP21 -TDS806B -TDT0 -TDC1F -TIE1 -TIP1 -FO7 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 + -U066DFF485153826687131237 -O8398 -SF1800 -C0 -A0 -I2 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP (ARM Core") -D00(5BA02477) -L00(0) -TO131075 -TC216000000 -TT216000000 -TP21 -TDS806B -TDT0 -TDC1F -TIE1 -TIP1 -FO7 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 0 @@ -153,40 +153,7 @@ UL2CM3(-S0 -C0 -P0 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM)) - - - 0 - 0 - 18 - 1 -
134311210
- 0 - 0 - 0 - 0 - 0 - 1 - .\mac_receiver.c - - \\tokenring_project\mac_receiver.c\18 -
- - 1 - 0 - 199 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
-
+ 0 @@ -208,11 +175,6 @@ 1 lastToken - - 4 - 1 - queue_macData_id - @@ -287,7 +249,7 @@ 0 0 2 - 10000000 + 1800000 diff --git a/tokenring_project.uvprojx b/tokenring_project.uvprojx index 6099233..0ad19f1 100644 --- a/tokenring_project.uvprojx +++ b/tokenring_project.uvprojx @@ -10,7 +10,7 @@ Target 1 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::C:\Program Files (x86)\ARM_Compiler_5.06u7 + 5060960::V5.06 update 7 (build 960)::..\..\Program Files (x86)\ARM_Compiler_5.06u7 0