6 #ifndef VREKRER_SCPI_PARSER_H_
7 #define VREKRER_SCPI_PARSER_H_
11 #ifndef SCPI_ARRAY_SYZE
12 #define SCPI_ARRAY_SYZE 6
16 #ifndef SCPI_MAX_TOKENS
17 #define SCPI_MAX_TOKENS 15
21 #ifndef SCPI_MAX_COMMANDS
22 #define SCPI_MAX_COMMANDS 20
26 #ifndef SCPI_BUFFER_LENGTH
27 #define SCPI_BUFFER_LENGTH 64
32 #define SCPI_TIMEOUT 10
36 #ifndef SCPI_HASH_TYPE
37 #define SCPI_HASH_TYPE uint8_t
140 void Execute(
char* message, Stream& interface);
142 void ProcessInput(Stream &interface,
const char* term_chars);
144 char*
GetMessage(Stream& interface,
const char* term_chars);
154 uint8_t tokens_size_ = 0;
158 uint8_t codes_size_ = 0;
168 uint8_t message_length_ = 0;
170 unsigned long time_checker_;
#define SCPI_HASH_TYPE
Integer size used for hashes.
Definition: Vrekrer_scpi_parser.h:37
SCPI_Commands SCPI_C
Alias of SCPI_Commands.
Definition: Vrekrer_scpi_parser.h:97
#define SCPI_MAX_TOKENS
Max number of valid tokens.
Definition: Vrekrer_scpi_parser.h:17
void(* SCPI_caller_t)(SCPI_Commands, SCPI_Parameters, Stream &)
Void template used with SCPI_Parser::RegisterCommand.
Definition: Vrekrer_scpi_parser.h:103
#define SCPI_ARRAY_SYZE
Max branch size of the command tree and max number of parameters.
Definition: Vrekrer_scpi_parser.h:12
#define SCPI_BUFFER_LENGTH
Length of the message buffer.
Definition: Vrekrer_scpi_parser.h:27
#define SCPI_MAX_COMMANDS
Max number of registered commands.
Definition: Vrekrer_scpi_parser.h:22
SCPI_Parameters SCPI_P
Alias of SCPI_Parameters.
Definition: Vrekrer_scpi_parser.h:100
String array class used to store the tokens of a command.
Definition: Vrekrer_scpi_parser.h:72
SCPI_Commands()
Dummy constructor.
Definition: Vrekrer_scpi_parser.cpp:55
char * not_processed_message
Not processed part of the message after the constructor is called.
Definition: Vrekrer_scpi_parser.h:79
String array class used to store the parameters found after a command.
Definition: Vrekrer_scpi_parser.h:86
char * not_processed_message
Not processed part of the message after the constructor is called.
Definition: Vrekrer_scpi_parser.h:93
SCPI_Parameters()
Dummy constructor.
Definition: Vrekrer_scpi_parser.cpp:90
Main class of the Vrekrer_SCPI_Parser library.
Definition: Vrekrer_scpi_parser.h:108
ErrorCode last_error
Variable that holds the last error code.
Definition: Vrekrer_scpi_parser.h:138
SCPI_HASH_TYPE GetCommandCode_(SCPI_Commands &commands)
Get a hash from a valid command.
Definition: Vrekrer_scpi_parser.cpp:167
void SetErrorHandler(SCPI_caller_t caller)
Set the function to be used by the error handler.
Definition: Vrekrer_scpi_parser.cpp:316
void RegisterCommand(char *command, SCPI_caller_t caller)
Registers a new valid command and associate a procedure to it.
Definition: Vrekrer_scpi_parser.cpp:277
SCPI_Parser()
SCPI_Parser constructor.
Definition: Vrekrer_scpi_parser.cpp:134
ErrorCode
SCPI Error codes.
Definition: Vrekrer_scpi_parser.h:127
@ BufferOverflow
Message buffer overflow.
@ Timeout
Timeout before receiving the termination chars.
@ UnknownCommand
Unknown command received.
void AddToken_(char *token)
Add a token to the tokens' storage.
Definition: Vrekrer_scpi_parser.cpp:139
void SetCommandTreeBase(char *tree_base)
Change the TreeBase for the next RegisterCommand calls.
Definition: Vrekrer_scpi_parser.cpp:237
void ProcessInput(Stream &interface, const char *term_chars)
Gets a message from a Stream interface and execute it.
Definition: Vrekrer_scpi_parser.cpp:353
char * GetMessage(Stream &interface, const char *term_chars)
Gets a message from a Stream interface.
Definition: Vrekrer_scpi_parser.cpp:373
void PrintDebugInfo()
Prints registered tokens and command hashes to the serial interface.
Definition: Vrekrer_scpi_parser.cpp:416
void Execute(char *message, Stream &interface)
Process a message and execute it a valid command is found.
Definition: Vrekrer_scpi_parser.cpp:332
Variable size string array class.
Definition: Vrekrer_scpi_parser.h:55
char * Last()
Returns the last element of the array.
Definition: Vrekrer_scpi_parser.cpp:38
uint8_t Size()
Array size.
Definition: Vrekrer_scpi_parser.cpp:47
void Append(char *value)
Append new string (LIFO stack Push).
Definition: Vrekrer_scpi_parser.cpp:11
char * Pop()
LIFO stack Pop.
Definition: Vrekrer_scpi_parser.cpp:19
char * First()
Returns the first element of the array.
Definition: Vrekrer_scpi_parser.cpp:29
char * operator[](const byte index)
Add indexing capability.
Definition: Vrekrer_scpi_parser.cpp:6