Refactor protocol/parsing code; implement address parsing
This commit is contained in:
parent
28be3c4e8b
commit
bc849d9662
7 changed files with 303 additions and 159 deletions
29
firmware/src/parsing.h
Normal file
29
firmware/src/parsing.h
Normal 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_ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue