Implemented UART_CTRL Interface (missing Hardware implementation)

This commit is contained in:
AlexanderHD27
2024-12-30 02:23:38 +01:00
parent 877040362c
commit 65df7b1912
13 changed files with 246 additions and 4 deletions

View File

@@ -2,6 +2,8 @@
#include "protocol.hpp"
#include <string.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
RPCHeader parseRPCHeader(char data)
{
RPCHeader header;
@@ -50,6 +52,7 @@ FrameSubmitionResult GobotRPCParser::submit_frame(char *data, size_t length, uin
insertFrameInPackageSlot(&this->buffer[slotNum], data, header.segment, length);
this->buffer[slotNum].timestamp = timestamp;
this->buffer[slotNum].length = MAX(this->buffer[slotNum].length, header.segment*7 + (length - 1));
volatile FrameSubmitionResult res = getPackageStatus(&(this->buffer[slotNum]));
if (res == COMPLEATE) {
@@ -112,6 +115,7 @@ void GobotRPCParser::retrivePackage(RPCPackage *dest, int index) {
dest->addr = buffer[index].sender_address;
dest->rpcNum = buffer[index].rpcNum;
dest->type = buffer[index].type;
dest->length = buffer[index].length;
freePackageSlot(index);
}
@@ -124,4 +128,5 @@ void GobotRPCParser::freePackageSlot(size_t index) {
this->buffer[index].sender_address = 0;
this->buffer[index].rpcNum = Invalid;
this->buffer[index].type = INVALID;
this->buffer[index].length = 0;
}