Motor Driver Evaluation Kit NEVB-MTR1-t01-1.0.0
Firmware for NEVB-MTR1-KIT1 for trapezoidal control of BLDC motors using Hall-effect sensors
Loading...
Searching...
No Matches
scpi_types.cpp
Go to the documentation of this file.
1/* This file has been prepared for Doxygen automatic documentation generation.*/
28
29#include "scpi_types.h"
30
31// ========================== SCPI_String_Array member functions ==========================
32
41char *SCPI_String_Array::operator[](const uint8_t index) const
42{
43 if (index >= size_)
44 return NULL; // Invalid index
45 return values_[index];
46}
47
56{
59 return;
60 values_[size_] = value;
61 size_++;
62}
63
72{
73 if (size_ == 0)
74 return NULL; // Empty array
75 size_--;
76 return values_[size_];
77}
78
85{
86 if (size_ == 0)
87 return NULL;
88 return values_[0];
89}
90
97{
98 if (size_ == 0)
99 return NULL;
100 return values_[size_ - 1];
101}
102
109{
110 return size_;
111}
112
113// ========================== SCPI_Commands member functions ==========================
114
119
130{
131 char *token = message;
132 // Trim leading spaces and tabs
133 while (isspace(*token))
134 token++;
135 // Save parameters and multicommands for later
136 not_processed_message = strpbrk(token, " \t");
137 if (not_processed_message != NULL)
138 {
139 not_processed_message[0] = '\0';
141 }
142 // Split using ':'
143 token = strtok(token, ":");
144 while (token != NULL)
145 {
146 this->Append(token);
147 token = strtok(NULL, ":");
148 }
149}
150
151// ========================== SCPI_Parameters member functions ==========================
152
157
167{
168 char *parameter = message;
169 // Split using ','
170 parameter = strtok(parameter, ",");
171 while (parameter != NULL)
172 {
173 while (isspace(*parameter))
174 parameter++;
175 this->Append(parameter);
176 parameter = strtok(NULL, ",");
177 }
178 // TODO add support for strings parameters (do not split parameters inside "")
179}
SCPI_Commands()
Default constructor.
char * not_processed_message
Remaining message text after token parsing.
Definition scpi_types.h:79
SCPI_Parameters()
Default constructor.
uint8_t size_
Current size of the array.
Definition scpi_types.h:61
uint8_t Size() const
Get the number of stored strings.
char * operator[](const byte index) const
Read-only array indexing.
bool overflow_error
Flag set when exceeding storage_size.
Definition scpi_types.h:58
const uint8_t storage_size
Max number of entries allowed.
Definition scpi_types.h:59
void Append(char *value)
Append a new string to the array (LIFO push).
char * values_[6]
Internal storage for string pointers.
Definition scpi_types.h:62
char * Last() const
Get the last appended string.
char * Pop()
Remove and return the last string (LIFO pop).
char * First() const
Get the first appended string.
SCPI types header file.