From e4ff2e0243fc9c6624f2cbd5dcd86f93190e1616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 17 Jan 2016 16:41:55 +0100 Subject: [PATCH] fixed bug with not requiring last argument (?) --- scpi.pro | 8 ++++++-- source/scpi_errors.c | 2 +- source/scpi_parser.c | 13 ++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/scpi.pro b/scpi.pro index 4dc37b7..754cd68 100644 --- a/scpi.pro +++ b/scpi.pro @@ -3,8 +3,12 @@ CONFIG += console CONFIG -= app_bundle CONFIG -= qt +DEFINES += __null=0 + INCLUDEPATH += source/ \ - include/ + include/ \ + /usr/arm-none-eabi/include \ + /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/plugin/include SOURCES += \ main.c \ @@ -30,4 +34,4 @@ HEADERS += \ include/scpi_errors.h \ include/scpi_parser.h \ include/scpi_regs.h \ - include/scpi.h + include/scpi.h diff --git a/source/scpi_errors.c b/source/scpi_errors.c index 6cd968d..c399cbb 100644 --- a/source/scpi_errors.c +++ b/source/scpi_errors.c @@ -8,7 +8,7 @@ #include "scpi_regs.h" #define ERR_QUEUE_LEN 4 -#define MAX_ERROR_LEN 255 +#define MAX_ERROR_LEN 150 // --- queue impl --- diff --git a/source/scpi_parser.c b/source/scpi_parser.c index 195aac6..b9a1fae 100644 --- a/source/scpi_parser.c +++ b/source/scpi_parser.c @@ -12,7 +12,7 @@ #include "scpi_regs.h" // Config -#define MAX_CHARBUF_LEN 255 +#define MAX_CHARBUF_LEN 64 // Char matching @@ -39,7 +39,7 @@ /** Parser internal state enum */ -typedef enum { +typedef enum ParserStateEnum { PARS_COMMAND = 0, // collect generic arg, terminated with comma or newline. Leading and trailing whitespace ignored. PARS_ARG, // generic argument (bool, float...) @@ -55,7 +55,7 @@ typedef enum { /** Parser internal state struct */ -static struct { +static struct ParserInternalStateStruct { parser_state_t state; // current parser internal state // string buffer, chars collected here until recognized @@ -608,7 +608,10 @@ static bool level_str_matches(const char *test, const char *pattern) } - +/** + * Match content of the charbuf to a command. + * @param partial - match also parts of a command (until a colon) + */ static bool match_cmd(bool partial) { charbuf_terminate(); // zero-end and rewind index @@ -788,7 +791,7 @@ static void pars_arg_eol_do(bool keep_levels) { int req_cnt = cmd_param_count(pst.matched_cmd); - if (pst.arg_i < req_cnt - 1) { + if (pst.arg_i < req_cnt) { // not the last arg yet - fail if (pst.charbuf_i > 0) pst.arg_i++; // acknowledge the last arg