From a5a84c429ac548eafd1d3903225a4ce72104201f Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周三, 22 4月 2015 03:50:26 +0800 Subject: [PATCH] Support RESPONSE MESSAGE UNIT SEPARATOR, issue #21 --- libscpi/src/parser.c | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index ad7ebc4..4b73e3c 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -99,12 +99,28 @@ } /** + * Conditionaly write ";" + * @param context + * @return number of characters written + */ +static size_t writeSemicolon(scpi_t * context) { + if (context->output_count > 0) { + return writeData(context, ";", 1); + } else { + return 0; + } +} + +/** * Process command * @param context */ static void processCommand(scpi_t * context) { const scpi_command_t * cmd = context->param_list.cmd; lex_state_t * state = &context->param_list.lex_state; + + /* conditionaly write ; */ + writeSemicolon(context); context->cmd_error = FALSE; context->output_count = 0; @@ -117,9 +133,6 @@ SCPI_ErrorPush(context, SCPI_ERROR_EXECUTION_ERROR); } } - - /* conditionaly write new line */ - writeNewLine(context); /* set error if command callback did not read all parameters */ if (state->pos < (state->buffer + state->len) && !context->cmd_error) { @@ -164,6 +177,7 @@ } state = &context->parser_state; + context->output_count = 0; while (1) { result = 0; @@ -202,6 +216,10 @@ } } + + /* conditionaly write new line */ + writeNewLine(context); + return result; } -- Gitblit v1.9.1