Motor Driver Evaluation Kit NEVB-MTR1-t01-1.1.0
Firmware for NEVB-MTR1-KIT1 for trapezoidal control of BLDC motors using Hall-effect sensors
Loading...
Searching...
No Matches
scpi.cpp
Go to the documentation of this file.
1/* This file has been prepared for Doxygen automatic documentation generation.*/
27
28#include "scpi.h"
29#include "config.h"
30#include "scpi_config.h"
31#include "scpi_helper.h"
32
33// Forward declarations
34static void ScpiCoreIdnQ(SCPI_C commands, SCPI_P parameters, Stream &interface);
35static void ScpiSystemErrorCountQ(SCPI_C commands, SCPI_P parameters, Stream &interface);
36static void ScpiSystemErrorNextQ(SCPI_C commands, SCPI_P parameters, Stream &interface);
37static void GetMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface);
38static void ConfigureMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface);
39static void GetConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface);
40static void ConfigureMotorDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface);
41static void ConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface);
42static void GetConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface);
43static void ConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface);
44static void GetConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface);
45static void MeasureMotorSpeed(SCPI_C commands, SCPI_P parameters, Stream &interface);
46static void MeasureMotorCurrentVBus(SCPI_C commands, SCPI_P parameters, Stream &interface);
47static void MeasureMotorCurrentPhaseU(SCPI_C commands, SCPI_P parameters, Stream &interface);
48static void MeasureMotorCurrentPhaseV(SCPI_C commands, SCPI_P parameters, Stream &interface);
49static void MeasureMotorCurrentPhaseW(SCPI_C commands, SCPI_P parameters, Stream &interface);
50static void MeasureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface);
51static void MeasureMotorVoltage(SCPI_C commands, SCPI_P parameters, Stream &interface);
52static void MeasureGateDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface);
53#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
54static void ConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface);
55#elif (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP)
56static void ConfigureMotorSpeedSource(SCPI_C commands, SCPI_P parameters, Stream &interface);
57static void GetMotorSpeedSource(SCPI_C commands, SCPI_P parameters, Stream &interface);
58static void ConfigureMotorSpeed(SCPI_C commands, SCPI_P parameters, Stream &interface);
59#endif
60
61// Instantiate the SCPI Parser
63
71void ScpiInit(void)
72{
73 /* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */
74 // "*CLS" and "*RST" are not supported
75 scpiParser.RegisterCommand(F("*IDN?"), &ScpiCoreIdnQ);
76
77 /* Required SCPI commands (SCPI std V1999.0 4.2.1) */
78 // "SYSTem:VERSion?" and "SYSTem:ERRor:NEXT?" are not supported
79 scpiParser.SetCommandTreeBase(F("SYSTem"));
80 scpiParser.RegisterCommand(F(":ERRor?"), &ScpiSystemErrorNextQ);
81 scpiParser.RegisterCommand(F(":ERRor:COUNt?"), &ScpiSystemErrorCountQ);
82
83 /* Motor Configuration Commands */
84 scpiParser.SetCommandTreeBase(F("CONFigure"));
85 scpiParser.RegisterCommand(F(":ENABle"), &ConfigureMotorEnable);
86 scpiParser.RegisterCommand(F(":ENABle?"), &GetMotorEnable);
87#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
88 scpiParser.RegisterCommand(F(":DUTYcycle:SOURce"), &ConfigureMotorDutyCycleSource);
89 scpiParser.RegisterCommand(F(":DUTYcycle:SOURce?"), &GetConfigureMotorDutyCycleSource);
90 scpiParser.RegisterCommand(F(":DUTYcycle"), &ConfigureMotorDutyCycle);
91#else
92 scpiParser.RegisterCommand(F(":SPEED:SOURce"), &ConfigureMotorSpeedSource);
93 scpiParser.RegisterCommand(F(":SPEED:SOURce?"), &GetMotorSpeedSource);
94 scpiParser.RegisterCommand(F(":SPEED"), &ConfigureMotorSpeed);
95#endif
96 scpiParser.RegisterCommand(F(":FREQuency"), &ConfigureMotorFrequency);
97 scpiParser.RegisterCommand(F(":FREQuency?"), &GetConfigureMotorFrequency);
98 scpiParser.RegisterCommand(F(":DIREction"), &ConfigureMotorDirection);
99 scpiParser.RegisterCommand(F(":DIREction?"), &GetConfigureMotorDirection);
100
101 /* Motor Measurement Commands */
102 scpiParser.SetCommandTreeBase(F("MEASure"));
103 scpiParser.RegisterCommand(F(":SPEEd?"), &MeasureMotorSpeed);
104 scpiParser.RegisterCommand(F(":CURRent:IBUS?"), &MeasureMotorCurrentVBus);
105 scpiParser.RegisterCommand(F(":CURRent:IPHU?"), &MeasureMotorCurrentPhaseU);
106 scpiParser.RegisterCommand(F(":CURRent:IPHV?"), &MeasureMotorCurrentPhaseV);
107 scpiParser.RegisterCommand(F(":CURRent:IPHW?"), &MeasureMotorCurrentPhaseW);
108 scpiParser.RegisterCommand(F(":VOLTage?"), &MeasureMotorVoltage);
109 scpiParser.RegisterCommand(F(":DIREction?"), &MeasureMotorDirection);
110 scpiParser.RegisterCommand(F(":DUTYcycle?"), &MeasureGateDutyCycle);
111}
112
122void ScpiInput(Stream &interface)
123{
124 scpiParser.ProcessInput(interface, SCPI_CMD_TERM);
125}
126
138static void ScpiCoreIdnQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
139{
140 interface.print(F(SCPI_IDN_MANUFACTURER));
141 interface.print(F(","));
142 interface.print(F(SCPI_IDN_MODEL));
143 interface.print(F(","));
144 if (SCPI_IDN_DEFAULT_SERIAL != NULL && strlen(SCPI_IDN_DEFAULT_SERIAL) > 0)
145 {
146 interface.print(F(SCPI_IDN_DEFAULT_SERIAL));
147 }
148 interface.print(F(","));
149 interface.println(F(SCPI_IDN_FIRMWARE_VERSION));
150}
151
163static void ScpiSystemErrorCountQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
164{
165 interface.println(scpiParser.last_error == ErrorCode::NoError ? 0 : 1);
166}
167
179static void ScpiSystemErrorNextQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
180{
181 switch (scpiParser.last_error)
182 {
184 interface.println(F("Buffer overflow error"));
185 break;
187 interface.println(F("Communication timeout error"));
188 break;
190 interface.println(F("Unknown command received"));
191 break;
193 interface.println(F("No Error"));
194 break;
196 interface.println(F("Missing or invalid parameter"));
197 break;
198 default:
199 interface.println(F("Unknown error"));
200 }
201 scpiParser.last_error = ErrorCode::NoError;
202}
203
214static void GetMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface)
215{
216 interface.println(motorFlags.enable);
217}
218
234static void ConfigureMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface)
235{
236 bool param;
237 if (!ScpiParamBool(parameters, param))
238 {
240 return;
241 }
242 if (param)
243 {
244 // Set the enable pin
245 PORTD |= (1 << ENABLE_PIN);
246 }
247 else
248 {
249 // Clear the enable pin
250 PORTD &= ~(1 << ENABLE_PIN);
251 }
252
253 scpiParser.last_error = ErrorCode::NoError;
254}
255
267#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
268static void ConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
269#elif (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP)
270static void ConfigureMotorSpeedSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
271#endif
272{
273 uint8_t param;
274
275 // read first parameter if present
276 if (!ScpiParamChoice(parameters, inputSources, INPUT_SOURCE_OPTIONS, param))
277 {
279 return;
280 }
281
282 if (param == SPEED_INPUT_SOURCE_LOCAL)
283 {
284 motorConfigs.speedInputSource = SPEED_INPUT_SOURCE_LOCAL;
285 return;
286 }
287 else
288 {
289 motorConfigs.speedInputSource = SPEED_INPUT_SOURCE_REMOTE;
290 speedInput = 0;
291 return;
292 }
293 scpiParser.last_error = ErrorCode::NoError;
294}
295
296#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
307static void GetConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
308#elif (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP)
319static void GetMotorSpeedSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
320#endif
321{
322 String name;
324 interface.println(name);
325}
326
327#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
338static void ConfigureMotorDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface)
339{
340 double param;
341 if (!ScpiParamDouble(parameters, param) || param < 0.0 || param > 100.0)
342 {
344 return;
345 }
346 speedInput = param;
347 scpiParser.last_error = ErrorCode::NoError;
348}
349#elif (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP)
361static void ConfigureMotorSpeed(SCPI_C commands, SCPI_P parameters, Stream &interface)
362{
363 double param;
364 if (!ScpiParamDouble(parameters, param) || param > ((((uint32_t)SPEED_CONTROLLER_MAX_SPEED * 15) << 3) / MOTOR_POLES))
365 {
367 return;
368 }
369 speedInput = ((param * SPEED_CONTROLLER_MAX_INPUT * MOTOR_POLES) >> 3) / ((uint32_t)SPEED_CONTROLLER_MAX_SPEED * 15);
370 scpiParser.last_error = ErrorCode::NoError;
371}
372#endif
373
386static void ConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface)
387{
388 // Clear the enable pin to stop the motor before changing frequency
389 PORTD &= ~(1 << ENABLE_PIN);
390
391 uint32_t param;
392
393 // Read first parameter if present and within range
394 if (!ScpiParamUInt32(parameters, param) || param < F_MOSFET_MIN || param > F_MOSFET_MAX)
395 {
397 return;
398 }
399
400 // Reload the configs
401 motorConfigs.tim4Freq = param;
402 motorConfigs.tim4Top = (uint16_t)TIM4_TOP(motorConfigs.tim4Freq);
403
404 // Wait until motor is stopped
405 while (faultFlags.motorStopped == FALSE)
406 {
407 ;
408 }
409
410 // Re-init timers with the new frequency
411 TimersInit();
412 scpiParser.last_error = ErrorCode::NoError;
413}
414
425static void GetConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface)
426{
427 interface.println(motorConfigs.tim4Freq);
428}
429
445static void ConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
446{
447 uint8_t param;
448
449 // read first parameter if present
451 {
453 return;
454 }
455
456 if (param)
457 {
458 // Set the direction pin if param is 1 (DIRECTION_REVERSE)
459 PORTD |= (1 << DIRECTION_COMMAND_PIN);
460 }
461 else
462 {
463 // Clear the direction pin if param is 0 (DIRECTION_FORWARD)
464 PORTD &= ~(1 << DIRECTION_COMMAND_PIN);
465 }
466 scpiParser.last_error = ErrorCode::NoError;
467}
468
480static void GetConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
481{
482 String name;
484 interface.println(name);
485}
486
498static void MeasureMotorSpeed(SCPI_C commands, SCPI_P parameters, Stream &interface)
499{
500 if (lastCommutationTicks == 0xffff)
501 {
502 interface.println(0.0);
503 }
504 else
505 {
506 interface.println(
507 (motorConfigs.tim4Freq * 20.0) / (lastCommutationTicks * MOTOR_POLES));
508 }
509}
510
521static void MeasureMotorCurrentVBus(SCPI_C commands, SCPI_P parameters, Stream &interface)
522{
523 interface.println(((double)ibus * 5.0 * 1000000.0) / ((double)1023.0 * IBUS_GAIN * IBUS_SENSE_RESISTOR));
524}
525
537static void MeasureMotorCurrentPhaseU(SCPI_C commands, SCPI_P parameters, Stream &interface)
538{
539 interface.println(((double)(iphaseU - 511) * 5.0 * 1000000.0) / ((double)1023.0 * IPHASE_GAIN * IPHASE_SENSE_RESISTOR));
540}
541
553static void MeasureMotorCurrentPhaseV(SCPI_C commands, SCPI_P parameters, Stream &interface)
554{
555 interface.println(((double)(iphaseV - 511) * 5.0 * 1000000.0) / ((double)1023.0 * IPHASE_GAIN * IPHASE_SENSE_RESISTOR));
556}
557
569static void MeasureMotorCurrentPhaseW(SCPI_C commands, SCPI_P parameters, Stream &interface)
570{
571 interface.println(((double)(iphaseW - 511) * 5.0 * 1000000.0) / ((double)1023.0 * IPHASE_GAIN * IPHASE_SENSE_RESISTOR));
572}
573
585static void MeasureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
586{
587 if (motorFlags.actualDirection == DIRECTION_UNKNOWN)
588 {
589 interface.println(F("UNKN"));
590 }
591 else
592 {
593 String name;
595 interface.println(name);
596 }
597}
598
609static void MeasureMotorVoltage(SCPI_C commands, SCPI_P parameters, Stream &interface)
610{
611 interface.println(((double)vbusVref * 5.0 * (VBUS_RTOP + VBUS_RBOTTOM)) / ((double)1023.0 * VBUS_RBOTTOM));
612}
613
626static void MeasureGateDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface)
627{
628 if (motorFlags.enable == TRUE)
629 {
630 // Reading 16 bit register so disabling interrupts for atomic operation
631 cli();
632 uint16_t duty = 0xff & OCR4A;
633 duty |= (0x03 & TC4H) << 8;
634 sei();
635
636 interface.println((double)duty / (double)motorConfigs.tim4Top * 100.0);
637 }
638 else
639 {
640 interface.println(0.0);
641 }
642}
643
652const SCPI_choice_def_t motorDirections[MOTOR_DIRECTION_OPTIONS] = {
653 {"FORW", "ard", DIRECTION_FORWARD},
654 {"REVE", "rse", DIRECTION_REVERSE},
655};
656
665const SCPI_choice_def_t inputSources[INPUT_SOURCE_OPTIONS] = {
666 {"LOCA", "l", SPEED_INPUT_SOURCE_LOCAL},
667 {"REMO", "te", SPEED_INPUT_SOURCE_REMOTE},
668};
SCPI Parser class.
Definition scpi_parser.h:55
Motor config header file.
#define TIM4_TOP(tim4Freq)
Definition config.h:1216
#define DIRECTION_FORWARD
Forward direction flag value.
Definition config.h:699
#define DIRECTION_COMMAND_PIN
Pin where direction command input is located.
Definition config.h:753
#define SPEED_INPUT_SOURCE_LOCAL
Speed input source - Local or speed input pin.
Definition config.h:763
#define SPEED_CONTROLLER_MAX_INPUT
Maximum Speed Reference Input.
Definition config.h:805
#define DIRECTION_REVERSE
Reverse direction flag value.
Definition config.h:701
#define ENABLE_PIN
Enable input pin.
Definition config.h:755
#define SPEED_INPUT_SOURCE_REMOTE
Speed input source - Remote input.
Definition config.h:765
#define TRUE
TRUE constant value, defined to be compatible with comparisons.
Definition config.h:661
#define FALSE
FALSE constant value.
Definition config.h:659
#define DIRECTION_UNKNOWN
Unknown direction flag value.
Definition config.h:703
#define IBUS_GAIN
Hi-side Current (IBUS) Gain for Current Measurement.
Definition config.h:314
#define IPHASE_SENSE_RESISTOR
Hi-side Current (IBUS) Sense Resistor Value.
Definition config.h:294
#define IBUS_SENSE_RESISTOR
Hi-side Current (IBUS) Sense Resistor Value.
Definition config.h:332
#define F_MOSFET_MAX
Maximum allowed gate switching frequency.
Definition config.h:99
#define VBUS_RBOTTOM
Bottom resistor value in the VBUS voltage potential divider.
Definition config.h:606
#define MOTOR_POLES
Number of poles in the motor.
Definition config.h:85
#define SPEED_CONTROLLER_MAX_SPEED
Speed Controller Maximum Speed.
Definition config.h:490
#define IPHASE_GAIN
In-line Phase Current Gain for Current Measurement.
Definition config.h:276
#define VBUS_RTOP
Top resistor value in the VBUS voltage potential divider.
Definition config.h:586
volatile uint16_t vbusVref
VBUS voltage measurement (Register Value)
Definition main.ino:255
volatile motorflags_t motorFlags
Motor control flags placed in I/O space for fast access.
Definition main.ino:50
volatile uint8_t speedInput
The most recent "speed" input measurement.
Definition main.ino:101
volatile uint16_t ibus
Hi-side Current (IBUS) measurement (Register Value).
Definition main.ino:137
volatile motorconfigs_t motorConfigs
Motor Configs.
Definition main.ino:66
volatile int16_t iphaseW
In-line Phase W current current measurement (Register Value).
Definition main.ino:226
volatile faultflags_t faultFlags
Fault flags placed in I/O space for fast access.
Definition main.ino:60
volatile uint16_t lastCommutationTicks
The number of 'ticks' between two hall sensor changes (store).
Definition main.ino:94
void TimersInit(void)
Initializes and synchronizes Timers.
Definition main.ino:455
volatile int16_t iphaseU
In-line Phase U current current measurement (Register Value).
Definition main.ino:167
volatile int16_t iphaseV
In-line Phase V current current measurement (Register Value).
Definition main.ino:196
static void GetConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the configured direction of the motor.
Definition scpi.cpp:480
static void GetConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the configured motor's duty cycle source.
Definition scpi.cpp:307
static void MeasureMotorCurrentPhaseV(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's phase V current.
Definition scpi.cpp:553
static void ScpiSystemErrorNextQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
Implements the SYSTem:ERRor? (System Error Next Query) command.
Definition scpi.cpp:179
static void MeasureMotorSpeed(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures the motor speed.
Definition scpi.cpp:498
static void MeasureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and reports the current direction of the motor.
Definition scpi.cpp:585
static void ScpiSystemErrorCountQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
Implements the SYSTem:ERRor:COUNt? (System Error Count Query) command.
Definition scpi.cpp:163
static void MeasureMotorCurrentPhaseU(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's phase U current.
Definition scpi.cpp:537
static void MeasureMotorCurrentVBus(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's VBUS current.
Definition scpi.cpp:521
static void ConfigureMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's enable state.
Definition scpi.cpp:234
static void ScpiCoreIdnQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
Implements the *IDN? (Identification Query) command.
Definition scpi.cpp:138
static void GetConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the configured motor frequency.
Definition scpi.cpp:425
static void ConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's speed input source.
Definition scpi.cpp:268
static void GetMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the current motor enable state.
Definition scpi.cpp:214
static void ConfigureMotorDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's speed input by setting the duty cycle.
Definition scpi.cpp:338
static void MeasureMotorCurrentPhaseW(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's phase W current.
Definition scpi.cpp:569
static void ConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
Sets the motor's direction based on the input parameter.
Definition scpi.cpp:445
static void MeasureMotorVoltage(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the VBUS voltage of the motor.
Definition scpi.cpp:609
void ScpiInput(Stream &interface)
Processes incoming data from a serial interface for SCPI commands.
Definition scpi.cpp:122
void ScpiInit(void)
Initializes the SCPI command parser and registers all supported commands.
Definition scpi.cpp:71
const SCPI_choice_def_t inputSources[2]
Array defining the possible input sources for speed/duty cycle control.
Definition scpi.cpp:665
SCPI_Parser scpiParser
Speed input source options array.
Definition scpi.cpp:62
static void MeasureGateDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the gate PWM duty cycle as a percentage.
Definition scpi.cpp:626
static void ConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's operating frequency.
Definition scpi.cpp:386
const SCPI_choice_def_t motorDirections[2]
Array defining the possible motor directions for SCPI commands.
Definition scpi.cpp:652
SCPI implementation header file.
#define INPUT_SOURCE_OPTIONS
Motor direction options array.
Definition scpi.h:39
#define MOTOR_DIRECTION_OPTIONS
Motor direction options array.
Definition scpi.h:35
SCPI parser configuration header file.
#define SCPI_IDN_MODEL
Model number identification string for the *IDN? command.
#define SCPI_CMD_TERM
Command termination character used to identify the end of a SCPI command.
#define SCPI_IDN_DEFAULT_SERIAL
Revision level identification string for the *IDN? command (optional).
#define SCPI_IDN_MANUFACTURER
Manufacturer identification string for the *IDN? command.
#define SCPI_IDN_FIRMWARE_VERSION
Firmware version identification string for the *IDN? command.
uint8_t ScpiParamChoice(SCPI_P &parameters, const SCPI_choice_def_t *options, size_t optionsSize, uint8_t &param)
Extracts a choice parameter from the SCPI parameter list and maps it to a numerical tag.
uint8_t ScpiParamBool(SCPI_P &parameters, bool &param)
Extracts a boolean parameter ('ON', '1', 'OFF', or '0') from the SCPI parameter list.
uint8_t ScpiParamUInt32(SCPI_P &parameters, uint32_t &param)
Extracts an unsigned 32-bit integer parameter from the SCPI parameter list.
uint8_t ScpiParamDouble(SCPI_P &parameters, double &param)
Extracts a double-precision floating-point parameter from the SCPI parameter list.
uint8_t ScpiChoiceToName(const SCPI_choice_def_t *options, size_t optionsSize, int8_t value, String &name)
Converts a numerical choice tag back to its string representation.
SCPI helper header file.
@ MissingOrInvalidParameter
A required parameter was missing or an invalid parameter was provided.
Definition scpi_types.h:132
@ BufferOverflow
The message buffer was exceeded during message reception.
Definition scpi_types.h:129
@ NoError
No error occurred.
Definition scpi_types.h:120
@ Timeout
A timeout occurred before receiving the expected termination characters.
Definition scpi_types.h:126
@ UnknownCommand
An unknown command was received that could not be matched to a known handler.
Definition scpi_types.h:123
SCPI_Parameters SCPI_P
Alias for SCPI_Parameters.
Definition scpi_types.h:106
SCPI_Commands SCPI_C
Alias for SCPI_Commands.
Definition scpi_types.h:102