Support RESPONSE MESSAGE UNIT SEPARATOR, issue #21
| | |
| | | } |
| | | |
| | | /** |
| | | * 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; |
| | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | state = &context->parser_state; |
| | | context->output_count = 0; |
| | | |
| | | while (1) { |
| | | result = 0; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /* conditionaly write new line */ |
| | | writeNewLine(context); |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | TEST_INPUT("*IDN?\r\n*IDN?\r\n*IDN?\r\n*IDN?\r\n", "MA,IN,0,VER\r\nMA,IN,0,VER\r\nMA,IN,0,VER\r\nMA,IN,0,VER\r\n"); |
| | | output_buffer_clear(); |
| | | |
| | | TEST_INPUT("*IDN?;*IDN?;*IDN?;*IDN?\r\n", "MA,IN,0,VER;MA,IN,0,VER;MA,IN,0,VER;MA,IN,0,VER\r\n"); |
| | | output_buffer_clear(); |
| | | |
| | | TEST_INPUT("*IDN?;*OPC;*IDN?\r\n", "MA,IN,0,VER;MA,IN,0,VER\r\n"); |
| | | output_buffer_clear(); |
| | | |
| | | /* Test one command in multiple buffers */ |
| | | TEST_INPUT("*IDN?", ""); |
| | | TEST_INPUT("\r\n", "MA,IN,0,VER\r\n"); |
| | |
| | | output_buffer_clear(); |
| | | |
| | | /* Test ctree traversal */ |
| | | TEST_INPUT("TEST:TREEA?;TREEB?\r\n", "10\r\n20\r\n"); |
| | | TEST_INPUT("TEST:TREEA?;TREEB?\r\n", "10;20\r\n"); |
| | | output_buffer_clear(); |
| | | |
| | | TEST_INPUT("TEST:TREEA?;:TEXT? \"PARAM1\", \"PARAM2\"\r\n", "10\r\n\"PARAM2\"\r\n"); |
| | | TEST_INPUT("TEST:TREEA?;:TEXT? \"PARAM1\", \"PARAM2\"\r\n", "10;\"PARAM2\"\r\n"); |
| | | output_buffer_clear(); |
| | | |
| | | CU_ASSERT_EQUAL(err_buffer_pos, 0); |