1
0

add sapi check online

This commit is contained in:
Rémi Heredero 2024-04-24 20:54:35 +02:00
parent f9b4ecb42c
commit 35b3457585
3 changed files with 91 additions and 6 deletions

View File

@ -34,6 +34,7 @@ void MacSender(void *argument) {
Status status;
osStatus_t retCode; // return error code
char* strPtr;
SapiToken stationStatus;
lastToken = osMemoryPoolAlloc(memPool, osWaitForever);
queue_macData_id = osMessageQueueNew(4, sizeof(struct queueMsg_t), &queue_macData_attr);
@ -79,7 +80,9 @@ void MacSender(void *argument) {
// Send one msg from internal queue if exist
//if (osMemoryPoolGetCount(queue_macData_id) != 0) { // Message in Queue
if(osMessageQueueGet(queue_macData_id, &queueMsg, NULL, 0) == 0){
retCode = osMessageQueueGet(queue_macData_id, &queueMsg, NULL, 0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
if(retCode == 0){
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
queue_phyS_id,
@ -121,6 +124,8 @@ void MacSender(void *argument) {
// Everything is fine, free memory
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
retCode = osMemoryPoolFree(memPool, lastSentMsgPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
sendToken();
} else {
@ -129,7 +134,7 @@ void MacSender(void *argument) {
//retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
//CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
memcpy(queueMsg.anyPtr, lastSentMsgPtr, sizeof(lastSentMsgPtr));
memcpy(queueMsg.anyPtr, lastSentMsgPtr, lastSentMsgPtr[2]+4);
queueMsg.type = TO_PHY;
//queueMsg.anyPtr = lastSentMsgPtr;
retCode = osMessageQueuePut(
@ -240,7 +245,7 @@ void MacSender(void *argument) {
status.ack = 0;
}
msg = osMemoryPoolAlloc(memPool, 0); // TODO - Leak of memory
msg = osMemoryPoolAlloc(memPool, 0);
if(msg == NULL) {
printf("Memory allocation failed #1\r\n");
assert(false);
@ -255,6 +260,10 @@ void MacSender(void *argument) {
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
stationStatus.raw = lastToken[dst.addr+1];
if(stationStatus.chat == 1) {
if(dst.addr != BROADCAST_ADDRESS) {
if(dst.sapi == CHAT_SAPI) {
lastSentMsgPtr = osMemoryPoolAlloc(memPool, 0);
@ -275,6 +284,21 @@ void MacSender(void *argument) {
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else {
strPtr = queueMsg.anyPtr;
sprintf(strPtr, "%d is not online\0", dst.addr+1);
queueMsg.type = MAC_ERROR;
queueMsg.addr = src.addr;
queueMsg.anyPtr = strPtr;
retCode = osMessageQueuePut(
queue_lcd_id,
&queueMsg,
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
}
break;
}

View File

@ -153,7 +153,56 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>18</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134311438</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\mac_receiver.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\tokenring_project\mac_receiver.c\18</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>263</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134256140</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\mac_sender.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\tokenring_project\mac_sender.c\263</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>199</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>
@ -175,6 +224,11 @@
<WinNumber>1</WinNumber>
<ItemText>lastToken</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>memPool</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
@ -244,6 +298,13 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<LogicAnalyzers>
<Wi>
<IntNumber>0</IntNumber>
<FirstString>`memPool</FirstString>
<SecondString>FF00000000000000000000000000E0FFFFFFEF41000000000000000000000000000000006D656D506F6F6C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1000000000000000000000000000000000000000726D0108</SecondString>
</Wi>
</LogicAnalyzers>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>

View File

@ -10,7 +10,7 @@
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060960::V5.06 update 7 (build 960)::..\..\Program Files (x86)\ARM_Compiler_5.06u7</pCCUsed>
<pCCUsed>5060960::V5.06 update 7 (build 960)::C:\Program Files (x86)\ARM_Compiler_5.06u7</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>