Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce SCPI_HelpQ with descriptions #135

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
28b17f7
output block data with delimiter
MisterHW Feb 1, 2022
8ed2623
fix typos
MisterHW Feb 2, 2022
bc4f1d5
introduce SCPI_HelpQ
MisterHW Feb 3, 2022
315f20d
introduce help search
MisterHW Feb 7, 2022
159fe83
drop C++20 keyword
MisterHW Feb 7, 2022
d099d9a
rename to USE_HELP_FILTER
MisterHW Feb 7, 2022
aa660db
fix expression
MisterHW Feb 7, 2022
1460793
add full command descriptions to examples common def, set desc. defau…
MisterHW Jan 6, 2023
7d0c83d
clean-up
MisterHW Jan 7, 2023
c394eb9
propagate MODE to Makefile for cross-compiling
MisterHW Jan 7, 2023
1e1b594
provide more elaborate description depending on USE_HELP_FILTER
MisterHW Jan 14, 2023
f7c4cc4
Merge branch 'j123b567:master' into scpi_helpq_enhancement
MisterHW Jan 16, 2023
b3668be
Merge branch 'j123b567:master' into scpi_helpq_enhancement
MisterHW Jan 17, 2023
36ddafe
strncasestr, strncasestrn_s, pp_xstr clean-up and formatting
MisterHW Jan 17, 2023
9c66dcd
fix C89 issue (FALSE, for syntax)
MisterHW Jan 17, 2023
0e7c828
remove strcasestr
MisterHW Jan 17, 2023
5dfac2b
strncasecmp -> SCPIDEFINE_strncasecmp
MisterHW Jan 17, 2023
5153e03
C style comments
MisterHW Jan 17, 2023
8aa90a7
split off HELP? into help.h/.c
MisterHW Jan 17, 2023
31a3e44
add help.c, help.h to Makefile
MisterHW Jan 17, 2023
d8a5d24
redo delete SCPI_HelpQ
MisterHW Jan 17, 2023
63f5e88
Revert "propagate MODE to Makefile for cross-compiling"
MisterHW Jan 17, 2023
d803ffe
simply SCPI_CMD_LIST_END definition
MisterHW Jan 17, 2023
a44b9aa
add missing ,
MisterHW Jan 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 63 additions & 58 deletions examples/common/scpi-def.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,70 +353,75 @@ static scpi_result_t My_CoreTstQ(scpi_t * context) {
return SCPI_RES_OK;
}

const scpi_command_t scpi_commands[] = {
/* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */
{ .pattern = "*CLS", .callback = SCPI_CoreCls,},
{ .pattern = "*ESE", .callback = SCPI_CoreEse,},
{ .pattern = "*ESE?", .callback = SCPI_CoreEseQ,},
{ .pattern = "*ESR?", .callback = SCPI_CoreEsrQ,},
{ .pattern = "*IDN?", .callback = SCPI_CoreIdnQ,},
{ .pattern = "*OPC", .callback = SCPI_CoreOpc,},
{ .pattern = "*OPC?", .callback = SCPI_CoreOpcQ,},
{ .pattern = "*RST", .callback = SCPI_CoreRst,},
{ .pattern = "*SRE", .callback = SCPI_CoreSre,},
{ .pattern = "*SRE?", .callback = SCPI_CoreSreQ,},
{ .pattern = "*STB?", .callback = SCPI_CoreStbQ,},
{ .pattern = "*TST?", .callback = My_CoreTstQ,},
{ .pattern = "*WAI", .callback = SCPI_CoreWai,},

/* Required SCPI commands (SCPI std V1999.0 4.2.1) */
{.pattern = "SYSTem:ERRor[:NEXT]?", .callback = SCPI_SystemErrorNextQ,},
{.pattern = "SYSTem:ERRor:COUNt?", .callback = SCPI_SystemErrorCountQ,},
{.pattern = "SYSTem:VERSion?", .callback = SCPI_SystemVersionQ,},

/* {.pattern = "STATus:OPERation?", .callback = scpi_stub_callback,}, */
/* {.pattern = "STATus:OPERation:EVENt?", .callback = scpi_stub_callback,}, */
/* {.pattern = "STATus:OPERation:CONDition?", .callback = scpi_stub_callback,}, */
/* {.pattern = "STATus:OPERation:ENABle", .callback = scpi_stub_callback,}, */
/* {.pattern = "STATus:OPERation:ENABle?", .callback = scpi_stub_callback,}, */

{.pattern = "STATus:QUEStionable[:EVENt]?", .callback = SCPI_StatusQuestionableEventQ,},
/* {.pattern = "STATus:QUEStionable:CONDition?", .callback = scpi_stub_callback,}, */
{.pattern = "STATus:QUEStionable:ENABle", .callback = SCPI_StatusQuestionableEnable,},
{.pattern = "STATus:QUEStionable:ENABle?", .callback = SCPI_StatusQuestionableEnableQ,},

{.pattern = "STATus:PRESet", .callback = SCPI_StatusPreset,},

/* DMM */
{.pattern = "MEASure:VOLTage:DC?", .callback = DMM_MeasureVoltageDcQ,},
{.pattern = "CONFigure:VOLTage:DC", .callback = DMM_ConfigureVoltageDc,},
{.pattern = "MEASure:VOLTage:DC:RATio?", .callback = SCPI_StubQ,},
{.pattern = "MEASure:VOLTage:AC?", .callback = DMM_MeasureVoltageAcQ,},
{.pattern = "MEASure:CURRent:DC?", .callback = SCPI_StubQ,},
{.pattern = "MEASure:CURRent:AC?", .callback = SCPI_StubQ,},
{.pattern = "MEASure:RESistance?", .callback = SCPI_StubQ,},
{.pattern = "MEASure:FRESistance?", .callback = SCPI_StubQ,},
{.pattern = "MEASure:FREQuency?", .callback = SCPI_StubQ,},
{.pattern = "MEASure:PERiod?", .callback = SCPI_StubQ,},

{.pattern = "SYSTem:COMMunication:TCPIP:CONTROL?", .callback = SCPI_SystemCommTcpipControlQ,},

{.pattern = "TEST:BOOL", .callback = TEST_Bool,},
{.pattern = "TEST:CHOice?", .callback = TEST_ChoiceQ,},
{.pattern = "TEST#:NUMbers#", .callback = TEST_Numbers,},
{.pattern = "TEST:TEXT", .callback = TEST_Text,},
{.pattern = "TEST:ARBitrary?", .callback = TEST_ArbQ,},
{.pattern = "TEST:CHANnellist", .callback = TEST_Chanlst,},

const scpi_command_t scpi_commands[] = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please provide alternative definition files for this functionality?

It is a generally useful but unusual extension. I would like to keep examples simple. Users can decide on their own if they would like to use help command or not and it is generally not needed. It will find its way, but I would like to keep the first impression simple.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, somehow divide the existing source (it is just an example anyway) so one part of the commands has help and the other does not so it is clear, that it is not mandatory to use and define help and tag.

Copy link
Contributor Author

@MisterHW MisterHW Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scpi-def.c and scpi-def.cpp are essentially identical. scpi-def.c could be stripped down to illustrate what a version with no help and no command tags could look like. One could additionally introduce

#define NO_CMD_DESC SCPI_CMD_DESC(NULL)

which would help being explicit about the generalized structure. With scpi-def being in common, offering definitions for all possible cases seems a bit excessive to me.

Retrospective Context:
Keep in mind that prior to this PR, the default was

#define USE_COMMAND_TAGS 1

and setting it to 0 would cause a type mismatch, as in scpi-def.c/.cpp there were extra (unconditional) , 0 in the scpi_commands[] items.

The documentation on HELP? might be the best place to elaborate on way to further strip down the definition and explain the implications. This was warrented through the existence of USE_COMMAND_TAGS, and in my opinion is underscored yet again through the introduction of USE_COMMAND_DESCRIPTIONS.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, scpi-def.cpp is identical to the scpi-def.c but all C specific features are removed so it can be compiled by the C++ compiler. Because this is C library, C++ file is just an example without real usage here.

Initially, examples were more about the communication interface and the command interface was the same. In the current perspective, there could be more standalone examples promoting separate features of the library, like enabling/disabling TAGs, and more importantly, introducing HELP? command.

Maybe, there can be a new example based on e.g. test-interactive to show, how HELP? command works and how to define all strings. It can have a completely different structure and its own commands definition.

/* Optional help command */
#if USE_HELP_FILTER
{"HELP?", SCPI_HelpQ, SCPI_CMD_DESC("[<string>] - list supported commands [containing \"<string>\"] (multiple block data)") SCPI_CMD_TAG(0)},
#else
{"HELP?", SCPI_HelpQ, SCPI_CMD_DESC("\t - list supported commands (multiple block data)") SCPI_CMD_TAG(0)},
#endif
/* IEEE Mandated Commands (SCPI std V1999.0 4.1.1): *CLS *ESE *ESE? *ESR? *IDN? *OPC *OPC? *RST *SRE *SRE? *STB? *TST? *WAI */
{"*CLS", SCPI_CoreCls, SCPI_CMD_DESC("\t - clear all Event Status registers, errors, output queue") SCPI_CMD_TAG(0)},
/* -- Standard Event Status Group [EVENT]-[ENABLE] */
{"*ESE", SCPI_CoreEse, SCPI_CMD_DESC("<0..255> - set Standard Event Status Enable / event mask") SCPI_CMD_TAG(0)},
{"*ESE?", SCPI_CoreEseQ, SCPI_CMD_DESC("\t - read ESE (0..255)") SCPI_CMD_TAG(0)},
{"*ESR?", SCPI_CoreEsrQ, SCPI_CMD_DESC("\t - read+clear Standard Event Status register (0..255)") SCPI_CMD_TAG(0)},
/* -- IEEE Mandated Commands (continued ...) */
{"*IDN?", SCPI_CoreIdnQ, SCPI_CMD_DESC("\t - read device identifier (str,str,str,str)") SCPI_CMD_TAG(0)},
{"*OPC", SCPI_CoreOpc, SCPI_CMD_DESC("\t - complete ops preceding Operation Complete Command, set ESR.OPC 1") SCPI_CMD_TAG(0)},
{"*OPC?", SCPI_CoreOpcQ, SCPI_CMD_DESC("\t - read ESR.OPC (0:ongoing-ops 1:done)") SCPI_CMD_TAG(0)},
{"*RST", SCPI_CoreRst, SCPI_CMD_DESC("\t - reset instrument and interface") SCPI_CMD_TAG(0)},
{"*SRE", SCPI_CoreSre, SCPI_CMD_DESC("<0..255> - set Service Request Enable / event mask over STB") SCPI_CMD_TAG(0)},
{"*SRE?", SCPI_CoreSreQ, SCPI_CMD_DESC("\t - read SRE (0..255)") SCPI_CMD_TAG(0)},
{"*STB?", SCPI_CoreStbQ, SCPI_CMD_DESC("\t - read STatus Byte (0..255)") SCPI_CMD_TAG(0)},
{"*TST?", My_CoreTstQ, SCPI_CMD_DESC("\t - read self-test result (0:no-failures)") SCPI_CMD_TAG(0)},
{"*WAI", SCPI_CoreWai, SCPI_CMD_DESC("\t - halt cmd execution until pending operations complete") SCPI_CMD_TAG(0)},

/* Required SCPI commands (SCPI std V1999.0 4.2.1) : SYSTem:ERRor, STATus:OPERation, STATus:QUEStionable and STATus:PRESet */
{"SYSTem:ERRor[:NEXT]?", SCPI_SystemErrorNextQ, SCPI_CMD_DESC("\t - get next error in queue (int-errno,str)") SCPI_CMD_TAG(0)},
{"SYSTem:ERRor:COUNt?", SCPI_SystemErrorCountQ, SCPI_CMD_DESC("\t - queued error count (0.." SCPI_ERROR_QUEUE_SIZE_STR ")") SCPI_CMD_TAG(0)},
{"SYSTem:VERSion?", SCPI_SystemVersionQ, SCPI_CMD_DESC("\t - query system version (str)") SCPI_CMD_TAG(0)},
/* -- Operation Status Group [CONDITION]-[EVENT]-[ENABLE] */
{"STATus:OPERation:CONDition?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"STATus:OPERation[:EVENt]?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"STATus:OPERation:ENABle", SCPI_Stub, SCPI_CMD_DESC("\t - not implemented") SCPI_CMD_TAG(0)},
{"STATus:OPERation:ENABle?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
/* -- Questionable Status Group [CONDITION]-[EVENT]-[ENABLE] */
{"STATus:QUEStionable:CONDition?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)}, /* "\t - read momentary Questionable Condition register (0..65535)" */
{"STATus:QUEStionable[:EVENt]?", SCPI_StatusQuestionableEventQ, SCPI_CMD_DESC("\t - read Questionable Event register (0..65535)") SCPI_CMD_TAG(0)},
{"STATus:QUEStionable:ENABle", SCPI_StatusQuestionableEnable, SCPI_CMD_DESC("<0..65535> - set Questionable Enable / event mask") SCPI_CMD_TAG(0)},
{"STATus:QUEStionable:ENABle?", SCPI_StatusQuestionableEnableQ, SCPI_CMD_DESC("\t - Questionable Status Enable (0..65535)") SCPI_CMD_TAG(0)},
{"STATus:PRESet", SCPI_StatusPreset, SCPI_CMD_DESC("\t - load Status sub-system register defaults") SCPI_CMD_TAG(0)},

/* commands specific to DMM example with TEST sub-system */
{"SYSTem:COMMunication:TCPIP:CONTROL?", SCPI_SystemCommTcpipControlQ, SCPI_CMD_DESC("\t - read TCPIP control port (int)") SCPI_CMD_TAG(0)},
{"CONFigure:VOLTage:DC", DMM_ConfigureVoltageDc, SCPI_CMD_DESC("<float>[,<float>] - test command") SCPI_CMD_TAG(0)},
{"MEASure:VOLTage:DC?", DMM_MeasureVoltageDcQ, SCPI_CMD_DESC("[<float>[,<float>]] - test command (0)") SCPI_CMD_TAG(0)},
{"MEASure:VOLTage:DC:RATio?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:VOLTage:AC?", DMM_MeasureVoltageAcQ, SCPI_CMD_DESC("[<float>[,<float>]] - test command (0)") SCPI_CMD_TAG(0)},
{"MEASure:CURRent:DC?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:CURRent:AC?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:RESistance?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:FRESistance?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:FREQuency?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:PERiod?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"TEST:BOOL", TEST_Bool, SCPI_CMD_DESC("<bool> - test command") SCPI_CMD_TAG(0)},
{"TEST:CHOice?", TEST_ChoiceQ, SCPI_CMD_DESC("<choice> - test command (\"BUS\":5 \"IMMediate\":6 \"EXTernal\":7)") SCPI_CMD_TAG(0)},
{"TEST#:NUMbers#", TEST_Numbers, SCPI_CMD_DESC("\t - test command with optional numbers - default 1") SCPI_CMD_TAG(0)},
{"TEST:TEXT", TEST_Text, SCPI_CMD_DESC("<param>[, ...] - debug print param as received") SCPI_CMD_TAG(0)},
{"TEST:ARBitrary?", TEST_ArbQ, SCPI_CMD_DESC("<block data> - receive and return block data (block data)") SCPI_CMD_TAG(0)},
{"TEST:CHANnellist", TEST_Chanlst, SCPI_CMD_DESC("<channel_list> - test channel list parsing") SCPI_CMD_TAG(0)},

SCPI_CMD_LIST_END
};

scpi_interface_t scpi_interface = {
.error = SCPI_Error,
.write = SCPI_Write,
.error = SCPI_Error,
MisterHW marked this conversation as resolved.
Show resolved Hide resolved
.write = SCPI_Write,
.control = SCPI_Control,
.flush = SCPI_Flush,
.reset = SCPI_Reset,
.flush = SCPI_Flush,
.reset = SCPI_Reset,
};

char scpi_input_buffer[SCPI_INPUT_BUFFER_LENGTH];
Expand Down
121 changes: 63 additions & 58 deletions examples/common/scpi-def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,70 +353,75 @@ static scpi_result_t My_CoreTstQ(scpi_t * context) {
return SCPI_RES_OK;
}

const scpi_command_t scpi_commands[] = {
/* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */
{"*CLS", SCPI_CoreCls, 0},
{"*ESE", SCPI_CoreEse, 0},
{"*ESE?", SCPI_CoreEseQ, 0},
{"*ESR?", SCPI_CoreEsrQ, 0},
{"*IDN?", SCPI_CoreIdnQ, 0},
{"*OPC", SCPI_CoreOpc, 0},
{"*OPC?", SCPI_CoreOpcQ, 0},
{"*RST", SCPI_CoreRst, 0},
{"*SRE", SCPI_CoreSre, 0},
{"*SRE?", SCPI_CoreSreQ, 0},
{"*STB?", SCPI_CoreStbQ, 0},
{"*TST?", My_CoreTstQ, 0},
{"*WAI", SCPI_CoreWai, 0},

/* Required SCPI commands (SCPI std V1999.0 4.2.1) */
{"SYSTem:ERRor[:NEXT]?", SCPI_SystemErrorNextQ, 0},
{"SYSTem:ERRor:COUNt?", SCPI_SystemErrorCountQ, 0},
{"SYSTem:VERSion?", SCPI_SystemVersionQ, 0},

//{"STATus:OPERation?", scpi_stub_callback, 0},
//{"STATus:OPERation:EVENt?", scpi_stub_callback, 0},
//{"STATus:OPERation:CONDition?", scpi_stub_callback, 0},
//{"STATus:OPERation:ENABle", scpi_stub_callback, 0},
//{"STATus:OPERation:ENABle?", scpi_stub_callback, 0},

{"STATus:QUEStionable[:EVENt]?", SCPI_StatusQuestionableEventQ, 0},
//{"STATus:QUEStionable:CONDition?", scpi_stub_callback, 0},
{"STATus:QUEStionable:ENABle", SCPI_StatusQuestionableEnable, 0},
{"STATus:QUEStionable:ENABle?", SCPI_StatusQuestionableEnableQ, 0},

{"STATus:PRESet", SCPI_StatusPreset, 0},

/* DMM */
{"MEASure:VOLTage:DC?", DMM_MeasureVoltageDcQ, 0},
{"CONFigure:VOLTage:DC", DMM_ConfigureVoltageDc, 0},
{"MEASure:VOLTage:DC:RATio?", SCPI_StubQ, 0},
{"MEASure:VOLTage:AC?", DMM_MeasureVoltageAcQ, 0},
{"MEASure:CURRent:DC?", SCPI_StubQ, 0},
{"MEASure:CURRent:AC?", SCPI_StubQ, 0},
{"MEASure:RESistance?", SCPI_StubQ, 0},
{"MEASure:FRESistance?", SCPI_StubQ, 0},
{"MEASure:FREQuency?", SCPI_StubQ, 0},
{"MEASure:PERiod?", SCPI_StubQ, 0},

{"SYSTem:COMMunication:TCPIP:CONTROL?", SCPI_SystemCommTcpipControlQ, 0},

{"TEST:BOOL", TEST_Bool, 0},
{"TEST:CHOice?", TEST_ChoiceQ, 0},
{"TEST#:NUMbers#", TEST_Numbers, 0},
{"TEST:TEXT", TEST_Text, 0},
{"TEST:ARBitrary?", TEST_ArbQ, 0},
{"TEST:CHANnellist", TEST_Chanlst, 0},

const scpi_command_t scpi_commands[] = {
/* Optional help command */
#if USE_HELP_FILTER
{"HELP?", SCPI_HelpQ, SCPI_CMD_DESC("[<string>] - list supported commands [containing \"<string>\"] (multiple block data)") SCPI_CMD_TAG(0)},
#else
{"HELP?", SCPI_HelpQ, SCPI_CMD_DESC("\t - list supported commands (multiple block data)") SCPI_CMD_TAG(0)},
#endif
/* IEEE Mandated Commands (SCPI std V1999.0 4.1.1): *CLS *ESE *ESE? *ESR? *IDN? *OPC *OPC? *RST *SRE *SRE? *STB? *TST? *WAI */
{"*CLS", SCPI_CoreCls, SCPI_CMD_DESC("\t - clear all Event Status registers, errors, output queue") SCPI_CMD_TAG(0)},
MisterHW marked this conversation as resolved.
Show resolved Hide resolved
/* -- Standard Event Status Group [EVENT]-[ENABLE] */
{"*ESE", SCPI_CoreEse, SCPI_CMD_DESC("<0..255> - set Standard Event Status Enable / event mask") SCPI_CMD_TAG(0)},
{"*ESE?", SCPI_CoreEseQ, SCPI_CMD_DESC("\t - read ESE (0..255)") SCPI_CMD_TAG(0)},
{"*ESR?", SCPI_CoreEsrQ, SCPI_CMD_DESC("\t - read+clear Standard Event Status register (0..255)") SCPI_CMD_TAG(0)},
/* -- IEEE Mandated Commands (continued ...) */
{"*IDN?", SCPI_CoreIdnQ, SCPI_CMD_DESC("\t - read device identifier (str,str,str,str)") SCPI_CMD_TAG(0)},
{"*OPC", SCPI_CoreOpc, SCPI_CMD_DESC("\t - complete ops preceding Operation Complete Command, set ESR.OPC 1") SCPI_CMD_TAG(0)},
{"*OPC?", SCPI_CoreOpcQ, SCPI_CMD_DESC("\t - read ESR.OPC (0:ongoing-ops 1:done)") SCPI_CMD_TAG(0)},
{"*RST", SCPI_CoreRst, SCPI_CMD_DESC("\t - reset instrument and interface") SCPI_CMD_TAG(0)},
{"*SRE", SCPI_CoreSre, SCPI_CMD_DESC("<0..255> - set Service Request Enable / event mask over STB") SCPI_CMD_TAG(0)},
{"*SRE?", SCPI_CoreSreQ, SCPI_CMD_DESC("\t - read SRE (0..255)") SCPI_CMD_TAG(0)},
{"*STB?", SCPI_CoreStbQ, SCPI_CMD_DESC("\t - read STatus Byte (0..255)") SCPI_CMD_TAG(0)},
{"*TST?", My_CoreTstQ, SCPI_CMD_DESC("\t - read self-test result (0:no-failures)") SCPI_CMD_TAG(0)},
{"*WAI", SCPI_CoreWai, SCPI_CMD_DESC("\t - halt cmd execution until pending operations complete") SCPI_CMD_TAG(0)},

/* Required SCPI commands (SCPI std V1999.0 4.2.1) : SYSTem:ERRor, STATus:OPERation, STATus:QUEStionable and STATus:PRESet */
{"SYSTem:ERRor[:NEXT]?", SCPI_SystemErrorNextQ, SCPI_CMD_DESC("\t - get next error in queue (int-errno,str)") SCPI_CMD_TAG(0)},
{"SYSTem:ERRor:COUNt?", SCPI_SystemErrorCountQ, SCPI_CMD_DESC("\t - queued error count (0.." SCPI_ERROR_QUEUE_SIZE_STR ")") SCPI_CMD_TAG(0)},
{"SYSTem:VERSion?", SCPI_SystemVersionQ, SCPI_CMD_DESC("\t - query system version (str)") SCPI_CMD_TAG(0)},
/* -- Operation Status Group [CONDITION]-[EVENT]-[ENABLE] */
{"STATus:OPERation:CONDition?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"STATus:OPERation[:EVENt]?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"STATus:OPERation:ENABle", SCPI_Stub, SCPI_CMD_DESC("\t - not implemented") SCPI_CMD_TAG(0)},
{"STATus:OPERation:ENABle?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
/* -- Questionable Status Group [CONDITION]-[EVENT]-[ENABLE] */
{"STATus:QUEStionable:CONDition?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)}, /* "\t - read momentary Questionable Condition register (0..65535)" */
{"STATus:QUEStionable[:EVENt]?", SCPI_StatusQuestionableEventQ, SCPI_CMD_DESC("\t - read Questionable Event register (0..65535)") SCPI_CMD_TAG(0)},
{"STATus:QUEStionable:ENABle", SCPI_StatusQuestionableEnable, SCPI_CMD_DESC("<0..65535> - set Questionable Enable / event mask") SCPI_CMD_TAG(0)},
{"STATus:QUEStionable:ENABle?", SCPI_StatusQuestionableEnableQ, SCPI_CMD_DESC("\t - Questionable Status Enable (0..65535)") SCPI_CMD_TAG(0)},
{"STATus:PRESet", SCPI_StatusPreset, SCPI_CMD_DESC("\t - load Status sub-system register defaults") SCPI_CMD_TAG(0)},

/* commands specific to DMM example with TEST sub-system */
{"SYSTem:COMMunication:TCPIP:CONTROL?", SCPI_SystemCommTcpipControlQ, SCPI_CMD_DESC("\t - read TCPIP control port (int)") SCPI_CMD_TAG(0)},
{"CONFigure:VOLTage:DC", DMM_ConfigureVoltageDc, SCPI_CMD_DESC("<float>[,<float>] - test command") SCPI_CMD_TAG(0)},
{"MEASure:VOLTage:DC?", DMM_MeasureVoltageDcQ, SCPI_CMD_DESC("[<float>[,<float>]] - test command (0)") SCPI_CMD_TAG(0)},
{"MEASure:VOLTage:DC:RATio?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:VOLTage:AC?", DMM_MeasureVoltageAcQ, SCPI_CMD_DESC("[<float>[,<float>]] - test command (0)") SCPI_CMD_TAG(0)},
{"MEASure:CURRent:DC?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:CURRent:AC?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:RESistance?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:FRESistance?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:FREQuency?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"MEASure:PERiod?", SCPI_StubQ, SCPI_CMD_DESC("\t - not implemented (0)") SCPI_CMD_TAG(0)},
{"TEST:BOOL", TEST_Bool, SCPI_CMD_DESC("<bool> - test command") SCPI_CMD_TAG(0)},
{"TEST:CHOice?", TEST_ChoiceQ, SCPI_CMD_DESC("<choice> - test command (\"BUS\":5 \"IMMediate\":6 \"EXTernal\":7)") SCPI_CMD_TAG(0)},
{"TEST#:NUMbers#", TEST_Numbers, SCPI_CMD_DESC("\t - test command with optional numbers - default 1") SCPI_CMD_TAG(0)},
{"TEST:TEXT", TEST_Text, SCPI_CMD_DESC("<param>[, ...] - debug print param as received") SCPI_CMD_TAG(0)},
{"TEST:ARBitrary?", TEST_ArbQ, SCPI_CMD_DESC("<block data> - receive and return block data (block data)") SCPI_CMD_TAG(0)},
{"TEST:CHANnellist", TEST_Chanlst, SCPI_CMD_DESC("<channel_list> - test channel list parsing") SCPI_CMD_TAG(0)},

SCPI_CMD_LIST_END
};

scpi_interface_t scpi_interface = {
/*.error = */ SCPI_Error,
/*.write = */ SCPI_Write,
/*.error = */ SCPI_Error,
MisterHW marked this conversation as resolved.
Show resolved Hide resolved
/*.write = */ SCPI_Write,
/*.control = */ SCPI_Control,
/*.flush = */ SCPI_Flush,
/*.reset = */ SCPI_Reset,
/*.flush = */ SCPI_Flush,
/*.reset = */ SCPI_Reset,
};

char scpi_input_buffer[SCPI_INPUT_BUFFER_LENGTH];
Expand Down
2 changes: 2 additions & 0 deletions examples/common/scpi-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ extern "C" {
#define SCPI_IDN3 NULL
#define SCPI_IDN4 "01-02"

#define SCPI_ERROR_QUEUE_SIZE_STR PP_XSTR(SCPI_ERROR_QUEUE_SIZE)

extern const scpi_command_t scpi_commands[];
extern scpi_interface_t scpi_interface;
extern char scpi_input_buffer[];
Expand Down
4 changes: 2 additions & 2 deletions libscpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SHAREDLIBVER = $(SHAREDLIB).$(VERSION)

SRCS = $(addprefix src/, \
error.c fifo.c ieee488.c \
minimal.c parser.c units.c utils.c \
minimal.c help.c parser.c units.c utils.c \
lexer.c expression.c \
)

Expand All @@ -37,7 +37,7 @@ OBJS_SHARED = $(addprefix $(OBJDIR_SHARED)/, $(notdir $(SRCS:.c=.o)))

HDRS = $(addprefix inc/scpi/, \
scpi.h constants.h error.h \
ieee488.h minimal.h parser.h types.h units.h \
ieee488.h minimal.h help.h parser.h types.h units.h \
expression.h \
) \
$(addprefix src/, \
Expand Down
Loading