Open MisterHW opened 2 years ago
Yeah well, C89 build fails because strncasecmp() was introduced later.
Unfortunately, some manufacturers stick to C89 for their compilers (e.g. Microchip was using a prehistoric compiler for PIC32. Newer version is now available but hard to adopt because of frequent and incompatible changes in their core libraries)
You can use use SCPIDEFINE_strncasecmp
instead of strncasecmp
. It is already provided by the library.
I will get back to this eventually :)
Human-readability is often a welcome aspect when developing software for SCPI devices, but also valuable when testing configurations or debugging issues in a lab or test setup. Command syntax and parameter ranges are traditionally only documented in manuals or programmer's guides, but often control software allows sending raw commands and performing queries.
To both help people implementing and using systems based on scpi-parser and to help projects stand the test of time, it seems valuable for the device to be able to list its supported commands, preferably with a short description exposing expected parameter types and ranges.
This PR provides
SCPI_HelpQ()
callback for a "HELP?" pattern and aUSE_COMMAND_DESCRIPTIONS
option which extends_scpi_command_t
by a description string.Data returned is formatted as an array of arbitrary block data. Newline characters are absorbed into the data of each block so the output is easily readable and can be parsed and displayed in control software (e.g. to provide a list of commands or syntax help).
Usage of the new features is demonstrated in the common example code.
The first column seen in the screenshot originates from the necessary block header information.
Memory Use
Backward compatibility is provided by setting
USE_COMMAND_DESCRIPTIONS 0
, not usingSCPI_HelpQ()
and if needed, by instructing the linker to drop unused sections (--gc-sections
). Even withUSE_COMMAND_DESCRIPTIONS 0
, the help command can provide value by accessing the pattern strings already in place. When settingUSE_COMMAND_DESCRIPTIONS 1
,_scpi_command_t
is exended by a pointer (default:nullptr
) to a null-terminated description string.resolves #129