1
0

finish project

This commit is contained in:
Rémi Heredero 2024-04-25 14:59:15 +02:00
parent 35b3457585
commit ecf4b3617e
2 changed files with 75 additions and 42 deletions

View File

@ -81,7 +81,7 @@ void MacSender(void *argument) {
// Send one msg from internal queue if exist
//if (osMemoryPoolGetCount(queue_macData_id) != 0) { // Message in Queue
retCode = osMessageQueueGet(queue_macData_id, &queueMsg, NULL, 0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
//CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
if(retCode == 0){
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
@ -237,35 +237,37 @@ void MacSender(void *argument) {
src.nothing = 0;
length = strlen(queueMsg.anyPtr);
if(dst.addr == BROADCAST_ADDRESS) {
status.read = 1;
status.ack = 1;
} else {
status.read = 0;
status.ack = 0;
}
msg = osMemoryPoolAlloc(memPool, 0);
if(msg == NULL) {
printf("Memory allocation failed #1\r\n");
assert(false);
}
msg[0] = src.raw;
msg[1] = dst.raw;
msg[2] = length;
memcpy(&msg[3], queueMsg.anyPtr, length);
status.checksum = Checksum(msg);
msg[3+length] = status.raw;
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) {
stationStatus.raw = gTokenInterface.station_list[dst.addr];
}
if( (stationStatus.chat == 1) || (dst.addr == BROADCAST_ADDRESS)) {
if(dst.addr == BROADCAST_ADDRESS) {
status.read = 1;
status.ack = 1;
} else {
status.read = 0;
status.ack = 0;
}
msg = osMemoryPoolAlloc(memPool, 0);
if(msg == NULL) {
printf("Memory allocation failed #1\r\n");
assert(false);
}
msg[0] = src.raw;
msg[1] = dst.raw;
msg[2] = length;
memcpy(&msg[3], queueMsg.anyPtr, length);
status.checksum = Checksum(msg);
msg[3+length] = status.raw;
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
if( (dst.addr != BROADCAST_ADDRESS) && (dst.sapi == CHAT_SAPI) ) {
lastSentMsgPtr = osMemoryPoolAlloc(memPool, 0);
if(lastSentMsgPtr == NULL) {
printf("Memory allocation failed #2\r\n");
@ -274,16 +276,15 @@ void MacSender(void *argument) {
memcpy(lastSentMsgPtr, msg, length+4);
// TODO test if station is online
}
}
queueMsg.anyPtr = msg;
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
queue_macData_id,
&queueMsg,
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
queueMsg.anyPtr = msg;
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
queue_macData_id,
&queueMsg,
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else {
strPtr = queueMsg.anyPtr;

View File

@ -159,7 +159,7 @@
<Type>0</Type>
<LineNumber>18</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134311438</Address>
<Address>134311450</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -173,9 +173,9 @@
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>263</LineNumber>
<LineNumber>264</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134256140</Address>
<Address>134256144</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -184,11 +184,43 @@
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\mac_sender.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\tokenring_project\mac_sender.c\263</Expression>
<Expression>\\tokenring_project\mac_sender.c\264</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>86</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134255102</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\86</Expression>
</Bp>
<Bp>
<Number>3</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>.\mac_sender.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>4</Number>
<Type>0</Type>
<LineNumber>199</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>