build command parser

This commit is contained in:
Leonetienne
2025-12-14 12:50:48 +01:00
parent 181139aae5
commit 25313b198e
6 changed files with 71 additions and 13 deletions
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <Arduino.h>
// This class takes max-16-character packet and parses commands from it
// Singleton-class
class CommandParser
{
// Each command is 5 bytes long (assuming no padding)
struct Command {
enum class TYPE : uint8_t {
MOVE_ABSOLUTE = 0x00,
MOVE_RELATIVE = 0x01,
RESET_POSITIONS = 0x02,
} instruction;
uint16_t args[2];
};
public:
static CommandParser& getInstance() noexcept;
// Expecting command to be a packet of max size UartHandler::PACKET_SIZE
Command parsePacket(const uint8_t* packet) noexcept;
private:
CommandParser() noexcept;
CommandParser(const CommandParser&) = delete;
CommandParser(CommandParser&&) = delete;
~CommandParser();
};