1
0

add all features for debug without keyboard

This commit is contained in:
Rémi Heredero 2024-04-22 17:01:41 +02:00
parent e7287f6878
commit d5e1467b3f
4 changed files with 55 additions and 12 deletions

View File

@ -0,0 +1,9 @@
From me
C R |
--------------
0 0 | Station isn't on the ring -> Error msg on lcd
0 1 | Received message but checksum not ok -> Send again
1 0 | Sapi on the station isn't connected -> Error msg on lcd
1 1 | Everything all right -> free
Frome someone else -> Send back now

View File

@ -105,7 +105,6 @@ void MacReceiver(void *argument) {
&queueMsg, &queueMsg,
osPriorityNormal, osPriorityNormal,
osWaitForever); osWaitForever);
printf("Token received\r\n");
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else { } else {
@ -127,7 +126,7 @@ void MacReceiver(void *argument) {
status.ack = 1; status.ack = 1;
if(dst.sapi == CHAT_SAPI && gTokenInterface.connected || if(dst.sapi == CHAT_SAPI && gTokenInterface.connected ||
dst.sapi == TIME_SAPI && gTokenInterface.broadcastTime) { dst.sapi == TIME_SAPI) {
// Send to Time or Chat ---------------------------- // Send to Time or Chat ----------------------------
send_DATA_IND(src, dst, queueMsg.anyPtr); send_DATA_IND(src, dst, queueMsg.anyPtr);
status.read = 1; status.read = 1;
@ -152,7 +151,7 @@ void MacReceiver(void *argument) {
} else { // for me but bad checksum } else { // for me but bad checksum
status.ack = 0; status.ack = 0;
status.read = 0; status.read = gTokenInterface.connected; // Maybe it's 1
msg[3+length] = status.raw; msg[3+length] = status.raw;
send_DATABACK(src, dst, queueMsg.anyPtr); send_DATABACK(src, dst, queueMsg.anyPtr);
} }

View File

@ -1,10 +1,13 @@
#include "main.h" #include "main.h"
#include <cstdio> #include <cstdio>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <cassert> #include <cassert>
uint8_t* lastToken; uint8_t* lastToken;
uint8_t* lastSentMsgPtr[15];
osMessageQueueId_t queue_macData_id; osMessageQueueId_t queue_macData_id;
const osMessageQueueAttr_t queue_macData_attr = { const osMessageQueueAttr_t queue_macData_attr = {
.name = "MAC_DATA" .name = "MAC_DATA"
@ -60,7 +63,6 @@ void MacSender(void *argument) {
&queueMsg, &queueMsg,
osPriorityNormal, osPriorityNormal,
osWaitForever); osWaitForever);
printf("Token sended\r\n");
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
// Send one msg from internal queue if exist // Send one msg from internal queue if exist
@ -99,18 +101,53 @@ void MacSender(void *argument) {
if(dst.addr == BROADCAST_ADDRESS) { if(dst.addr == BROADCAST_ADDRESS) {
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr); retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else if(status.read == 1) { } else if(src.addr != gTokenInterface.myAddress) {
if(status.ack == 0) { // Send original message when token is here
msg = osMemoryPoolAlloc(memPool, osWaitForever);
queueMsg.type = TO_PHY; queueMsg.type = TO_PHY;
//queueMsg.anyPtr = retCode = osMessageQueuePut(
queue_phyS_id,
&queueMsg,
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else if(status.read == 1) {
if(status.ack == 1) {
// Everything is fine, free memory
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else { } else {
// Checksum error, send original message again when token is here
if(lastSentMsgPtr[src.addr] != NULL) {
queueMsg.anyPtr = lastSentMsgPtr[src.addr];
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
queue_macData_id,
&queueMsg,
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} else {
// Error, no original message found
strPtr = osMemoryPoolAlloc(memPool, osWaitForever);
sprintf(strPtr, "Someone did shit on the ring #1\0");
queueMsg.type = MAC_ERROR;
queueMsg.addr = src.addr;
queueMsg.sapi = src.sapi;
queueMsg.anyPtr = strPtr;
retCode = osMessageQueuePut(
queue_lcd_id,
&queueMsg,
osPriorityNormal,
0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
}
} }
} else { } else {
// Send original message to PHY // Send original message when token is here
queueMsg.type = TO_PHY; queueMsg.type = TO_PHY;
retCode = osMessageQueuePut( retCode = osMessageQueuePut(
queue_macData_id, queue_macData_id,
@ -133,7 +170,6 @@ void MacSender(void *argument) {
0); 0);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
} }
}
break; break;
} }

3
main.c
View File

@ -354,8 +354,7 @@ uint32_t HAL_GetTick(void)
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
/// \brief Init all and start RTX5 /// \brief Init all and start RTX5
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
int main(void) int main(void) {
{
SystemClock_Config(); SystemClock_Config();
EventRecorderInitialize(EventRecordAll,0); EventRecorderInitialize(EventRecordAll,0);