Refactor protocol/parsing code; implement address parsing

This commit is contained in:
Lexi / Zoe 2021-04-04 02:50:25 +02:00
parent 28be3c4e8b
commit bc849d9662
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
7 changed files with 303 additions and 159 deletions

29
firmware/src/parsing.h Normal file
View file

@ -0,0 +1,29 @@
#ifndef PARSING_H_
#define PARSING_H_
#include "config.h"
#include "eeprom.h"
#include <stdbool.h>
// Type definition for a command line with optional argument (actually just two pointers to strings)
typedef struct {
char* command;
char* arg;
} CommandLine;
// Type definition for address ranges (from-to)
typedef struct {
bool isValid;
address_t from;
address_t to;
} AddressRange;
void parseNextCommand();
CommandLine readNextCommand(char* buffer, uint8_t bufferLength);
CommandLine tokenizeCommand(char* cmd);
bool parseSingleAddressTo(char* addressStr, address_t* address);
AddressRange parseSingleAddress(char* addressStr);
AddressRange parseAddressRange(char* addressStr);
#endif /* PARSING_H_ */