From 06857724497cf46133f624f6ba1a0bdf70fe7ab7 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周五, 19 4月 2013 18:48:30 +0800 Subject: [PATCH] Changes inspired by HMM: startup colon, Makefile --- examples/Makefile | 15 +++++++ libscpi/inc/scpi/types.h | 7 ++- libscpi/test/test_scpi_utils.c | 5 ++ Makefile | 8 ++++ libscpi/src/utils.c | 37 ++++++------------ 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1f6ee32 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + +all: + $(MAKE) -C libscpi + $(MAKE) -C examples + +clean: + $(MAKE) clean -C libscpi + $(MAKE) clean -C examples diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..7ba0bdb --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,15 @@ + +all: + $(MAKE) -C test-interactive + $(MAKE) -C test-parser + $(MAKE) -C test-tcp + $(MAKE) -C test-tcp-srq + + +clean: + $(MAKE) clean -C test-interactive + $(MAKE) clean -C test-parser + $(MAKE) clean -C test-tcp + $(MAKE) clean -C test-tcp-srq + + diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h index 295009c..dff7991 100644 --- a/libscpi/inc/scpi/types.h +++ b/libscpi/inc/scpi/types.h @@ -1,5 +1,7 @@ /*- - * Copyright (c) 2012-2013 Jan Breuer, + * Copyright (c) 2013 Jan Breuer + * Richard.hmm + * Copyright (c) 2012 Jan Breuer * * All Rights Reserved * @@ -135,7 +137,8 @@ SCPI_UNIT_OHM, SCPI_UNIT_HERTZ, SCPI_UNIT_CELSIUS, - SCPI_UNIT_SECONDS + SCPI_UNIT_SECONDS, + SCPI_UNIT_DISTANCE }; typedef enum _scpi_unit_t scpi_unit_t; diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c index 89c7a56..0562487 100644 --- a/libscpi/src/utils.c +++ b/libscpi/src/utils.c @@ -1,5 +1,7 @@ /*- - * Copyright (c) 2012-2013 Jan Breuer, + * Copyright (c) 2013 Jan Breuer + * Richard.hmm + * Copyright (c) 2012 Jan Breuer * * All Rights Reserved * @@ -375,33 +377,12 @@ } /** - * is colon or not. add by hmm 2013.4.1 + * is colon or not * @param cmd - command * @return */ -static bool_t iscolon(const char * cmd) { - char* pColon = ":"; - if(0 == SCPI_strncasecmp(cmd, pColon, 1)) - { - return TRUE; - } - return FALSE; -} - -/** - * Count colon from the beggining add by hmm 2013.4.1 - * @param cmd - command - * @param len - max search length - * @return number of colon - */ -size_t skipColon(const char * cmd, size_t len) { - size_t i; - for (i = 0; i < len; i++) { - if (!iscolon(&cmd[i])) { - return i; - } - } - return len; +static bool_t iscolon(char ch) { + return (':' == ch) ? TRUE : FALSE; } /** @@ -488,6 +469,12 @@ size_t cmd_len = SCPI_strnlen(cmd, len); const char * cmd_end = cmd + cmd_len; + /* TODO: now it is possible to send command ":*IDN?" which is incorrect */ + if (iscolon(cmd_ptr[0])) { + cmd_len --; + cmd_ptr ++; + } + while (1) { int pattern_sep_pos = patternSeparatorPos(pattern_ptr, pattern_end - pattern_ptr); int cmd_sep_pos = cmdSeparatorPos(cmd_ptr, cmd_end - cmd_ptr); diff --git a/libscpi/test/test_scpi_utils.c b/libscpi/test/test_scpi_utils.c index 1081d6e..4cfd5a0 100644 --- a/libscpi/test/test_scpi_utils.c +++ b/libscpi/test/test_scpi_utils.c @@ -269,6 +269,11 @@ TEST_MATCH_COMMAND("ABc:AACddd", "abc:aacddd", TRUE); TEST_MATCH_COMMAND("ABc:AACddd", "abc:aacdd", FALSE); TEST_MATCH_COMMAND("ABc:AACddd", "a:aac", FALSE); + TEST_MATCH_COMMAND("ABc:AACddd", ":ab:aac", TRUE); + TEST_MATCH_COMMAND("ABc:AACddd", ":abc:aac", TRUE); + TEST_MATCH_COMMAND("ABc:AACddd", ":abc:aacddd", TRUE); + TEST_MATCH_COMMAND("ABc:AACddd", ":abc:aacdd", FALSE); + TEST_MATCH_COMMAND("ABc:AACddd", ":a:aac", FALSE); } int main() { -- Gitblit v1.9.1