add all features for debug without keyboard
This commit is contained in:
parent
e7287f6878
commit
d5e1467b3f
9
checksum_read-true_table.txt
Normal file
9
checksum_read-true_table.txt
Normal 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
|
@ -105,7 +105,6 @@ void MacReceiver(void *argument) {
|
||||
&queueMsg,
|
||||
osPriorityNormal,
|
||||
osWaitForever);
|
||||
printf("Token received\r\n");
|
||||
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
|
||||
|
||||
} else {
|
||||
@ -127,7 +126,7 @@ void MacReceiver(void *argument) {
|
||||
status.ack = 1;
|
||||
|
||||
if(dst.sapi == CHAT_SAPI && gTokenInterface.connected ||
|
||||
dst.sapi == TIME_SAPI && gTokenInterface.broadcastTime) {
|
||||
dst.sapi == TIME_SAPI) {
|
||||
// Send to Time or Chat ----------------------------
|
||||
send_DATA_IND(src, dst, queueMsg.anyPtr);
|
||||
status.read = 1;
|
||||
@ -152,7 +151,7 @@ void MacReceiver(void *argument) {
|
||||
|
||||
} else { // for me but bad checksum
|
||||
status.ack = 0;
|
||||
status.read = 0;
|
||||
status.read = gTokenInterface.connected; // Maybe it's 1
|
||||
msg[3+length] = status.raw;
|
||||
send_DATABACK(src, dst, queueMsg.anyPtr);
|
||||
}
|
||||
|
50
mac_sender.c
50
mac_sender.c
@ -1,10 +1,13 @@
|
||||
#include "main.h"
|
||||
#include <cstdio>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
|
||||
uint8_t* lastToken;
|
||||
uint8_t* lastSentMsgPtr[15];
|
||||
|
||||
osMessageQueueId_t queue_macData_id;
|
||||
const osMessageQueueAttr_t queue_macData_attr = {
|
||||
.name = "MAC_DATA"
|
||||
@ -60,7 +63,6 @@ void MacSender(void *argument) {
|
||||
&queueMsg,
|
||||
osPriorityNormal,
|
||||
osWaitForever);
|
||||
printf("Token sended\r\n");
|
||||
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
|
||||
|
||||
// Send one msg from internal queue if exist
|
||||
@ -99,18 +101,53 @@ void MacSender(void *argument) {
|
||||
if(dst.addr == BROADCAST_ADDRESS) {
|
||||
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
|
||||
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
|
||||
} else if(src.addr != gTokenInterface.myAddress) {
|
||||
// Send original message when token is here
|
||||
queueMsg.type = TO_PHY;
|
||||
retCode = osMessageQueuePut(
|
||||
queue_phyS_id,
|
||||
&queueMsg,
|
||||
osPriorityNormal,
|
||||
0);
|
||||
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
|
||||
|
||||
} else if(status.read == 1) {
|
||||
if(status.ack == 0) {
|
||||
msg = osMemoryPoolAlloc(memPool, osWaitForever);
|
||||
queueMsg.type = TO_PHY;
|
||||
//queueMsg.anyPtr =
|
||||
if(status.ack == 1) {
|
||||
// Everything is fine, free memory
|
||||
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
|
||||
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
|
||||
|
||||
} 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 {
|
||||
// Send original message to PHY
|
||||
// Send original message when token is here
|
||||
queueMsg.type = TO_PHY;
|
||||
retCode = osMessageQueuePut(
|
||||
queue_macData_id,
|
||||
@ -133,7 +170,6 @@ void MacSender(void *argument) {
|
||||
0);
|
||||
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
3
main.c
3
main.c
@ -354,8 +354,7 @@ uint32_t HAL_GetTick(void)
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
/// \brief Init all and start RTX5
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
int main(void)
|
||||
{
|
||||
int main(void) {
|
||||
SystemClock_Config();
|
||||
|
||||
EventRecorderInitialize(EventRecordAll,0);
|
||||
|
Reference in New Issue
Block a user