fixed bug with not requiring last argument (?)

master
Ondřej Hruška 9 years ago
parent af87602fb8
commit e4ff2e0243
  1. 8
      scpi.pro
  2. 2
      source/scpi_errors.c
  3. 13
      source/scpi_parser.c

@ -3,8 +3,12 @@ CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
CONFIG -= qt CONFIG -= qt
DEFINES += __null=0
INCLUDEPATH += source/ \ INCLUDEPATH += source/ \
include/ include/ \
/usr/arm-none-eabi/include \
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/plugin/include
SOURCES += \ SOURCES += \
main.c \ main.c \
@ -30,4 +34,4 @@ HEADERS += \
include/scpi_errors.h \ include/scpi_errors.h \
include/scpi_parser.h \ include/scpi_parser.h \
include/scpi_regs.h \ include/scpi_regs.h \
include/scpi.h include/scpi.h

@ -8,7 +8,7 @@
#include "scpi_regs.h" #include "scpi_regs.h"
#define ERR_QUEUE_LEN 4 #define ERR_QUEUE_LEN 4
#define MAX_ERROR_LEN 255 #define MAX_ERROR_LEN 150
// --- queue impl --- // --- queue impl ---

@ -12,7 +12,7 @@
#include "scpi_regs.h" #include "scpi_regs.h"
// Config // Config
#define MAX_CHARBUF_LEN 255 #define MAX_CHARBUF_LEN 64
// Char matching // Char matching
@ -39,7 +39,7 @@
/** Parser internal state enum */ /** Parser internal state enum */
typedef enum { typedef enum ParserStateEnum {
PARS_COMMAND = 0, PARS_COMMAND = 0,
// collect generic arg, terminated with comma or newline. Leading and trailing whitespace ignored. // collect generic arg, terminated with comma or newline. Leading and trailing whitespace ignored.
PARS_ARG, // generic argument (bool, float...) PARS_ARG, // generic argument (bool, float...)
@ -55,7 +55,7 @@ typedef enum {
/** Parser internal state struct */ /** Parser internal state struct */
static struct { static struct ParserInternalStateStruct {
parser_state_t state; // current parser internal state parser_state_t state; // current parser internal state
// string buffer, chars collected here until recognized // 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) static bool match_cmd(bool partial)
{ {
charbuf_terminate(); // zero-end and rewind index 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); 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 // not the last arg yet - fail
if (pst.charbuf_i > 0) pst.arg_i++; // acknowledge the last arg if (pst.charbuf_i > 0) pst.arg_i++; // acknowledge the last arg

Loading…
Cancel
Save