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 1 commit
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
Next Next commit
output block data with delimiter
scpi-99 6.2.3.4 and 6.2.6 suggest returning multiple blocks is valid, so SCPI_ResultArbitraryBlockHeader() needs to insert a delimiter,
other changes are: accepting _GLIBCXX_HAVE_STDBOOL_H, testing for non-NULL data in writeData(), and some spelling fixes.
  • Loading branch information
MisterHW committed Feb 1, 2022
commit 28b17f7935b446edec4dfa85974ea1bf6fcfa1ed
6 changes: 3 additions & 3 deletions libscpi/inc/scpi/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
extern "C" {
#endif

#if !HAVE_STDBOOL
#if (!HAVE_STDBOOL) && (!_GLIBCXX_HAVE_STDBOOL_H)
typedef unsigned char bool;
#endif

Expand Down Expand Up @@ -354,7 +354,7 @@ extern "C" {
#if USE_COMMAND_TAGS
int32_t tag;
#endif /* USE_COMMAND_TAGS */
};
};

struct _scpi_interface_t {
scpi_error_callback_t error;
Expand All @@ -381,7 +381,7 @@ extern "C" {
void * user_context;
scpi_parser_state_t parser_state;
const char * idn[4];
size_t arbitrary_reminding;
size_t arbitrary_remaining;
};

enum _scpi_array_format_t {
Expand Down
25 changes: 14 additions & 11 deletions libscpi/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
* Write data to SCPI output
* @param context
* @param data
* @param len - lenght of data to be written
* @param len - length of data to be written
* @return number of bytes written
*/
static size_t writeData(scpi_t * context, const char * data, size_t len) {
if (len > 0) {
if ((len > 0) && (data != NULL)) {
return context->interface->write(context, data, len);
} else {
return 0;
Expand Down Expand Up @@ -134,7 +134,7 @@ static scpi_bool_t processCommand(scpi_t * context) {
context->cmd_error = FALSE;
context->output_count = 0;
context->input_count = 0;
context->arbitrary_reminding = 0;
context->arbitrary_remaining = 0;

/* if callback exists - call command callback */
if (cmd->callback != NULL) {
Expand Down Expand Up @@ -221,7 +221,7 @@ scpi_bool_t SCPI_Parse(scpi_t * context, char * data, int len) {
cmd_prev = state->programHeader;
} else {
/* place undefined header with error */
/* calculate length of errornouse header and trim \r\n */
/* calculate length of errorenous header and trim \r\n */
size_t r2 = r;
while (r2 > 0 && (data[r2 - 1] == '\r' || data[r2 - 1] == '\n')) r2--;
SCPI_ErrorPushEx(context, SCPI_ERROR_UNDEFINED_HEADER, data, r2);
Expand All @@ -238,7 +238,7 @@ scpi_bool_t SCPI_Parse(scpi_t * context, char * data, int len) {

}

/* conditionaly write new line */
/* conditionally write new line */
writeNewLine(context);

return result;
Expand Down Expand Up @@ -506,7 +506,7 @@ size_t SCPI_ResultDouble(scpi_t * context, double val) {
}

/**
* Write string withn " to the result
* Write string within "" to the result
* @param context
* @param data
* @return
Expand Down Expand Up @@ -606,6 +606,7 @@ size_t SCPI_ResultError(scpi_t * context, scpi_error_t * error) {
* @return
*/
size_t SCPI_ResultArbitraryBlockHeader(scpi_t * context, size_t len) {
size_t result = 0;
char block_header[12];
size_t header_len;
block_header[0] = '#';
Expand All @@ -614,8 +615,10 @@ size_t SCPI_ResultArbitraryBlockHeader(scpi_t * context, size_t len) {
header_len = strlen(block_header + 2);
block_header[1] = (char) (header_len + '0');

context->arbitrary_reminding = len;
return writeData(context, block_header, header_len + 2);
context->arbitrary_remaining = len;
result = writeDelimiter(context);
result += writeData(context, block_header, header_len + 2);
return result;
}

/**
Expand All @@ -627,14 +630,14 @@ size_t SCPI_ResultArbitraryBlockHeader(scpi_t * context, size_t len) {
*/
size_t SCPI_ResultArbitraryBlockData(scpi_t * context, const void * data, size_t len) {

if (context->arbitrary_reminding < len) {
if (context->arbitrary_remaining < len) {
SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
return 0;
}

context->arbitrary_reminding -= len;
context->arbitrary_remaining -= len;

if (context->arbitrary_reminding == 0) {
if (context->arbitrary_remaining == 0) {
context->output_count++;
}

Expand Down