| | |
| | | * @return number of characters written |
| | | */ |
| | | static size_t writeNewLine(scpi_t * context) { |
| | | if (context->output_count > 0) { |
| | | if (!context->first_output) { |
| | | size_t len; |
| | | #ifndef SCPI_LINE_ENDING |
| | | #error no termination character defined |
| | |
| | | const scpi_command_t * cmd = context->param_list.cmd; |
| | | lex_state_t * state = &context->param_list.lex_state; |
| | | scpi_bool_t result = TRUE; |
| | | scpi_bool_t is_query = context->param_list.cmd_raw.data[context->param_list.cmd_raw.length - 1] == '?'; |
| | | |
| | | /* conditionaly write ; */ |
| | | writeSemicolon(context); |
| | | /* conditionally write ; */ |
| | | if(!context->first_output && is_query) { |
| | | writeData(context, ";", 1); |
| | | } |
| | | |
| | | context->cmd_error = FALSE; |
| | | context->output_count = 0; |
| | |
| | | } else { |
| | | if (context->cmd_error) { |
| | | result = FALSE; |
| | | } else { |
| | | if(context->first_output && is_query) { |
| | | context->first_output = FALSE; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | state = &context->parser_state; |
| | | context->output_count = 0; |
| | | context->first_output = TRUE; |
| | | |
| | | while (1) { |
| | | r = scpiParser_detectProgramMessageUnit(state, data, len); |
| | |
| | | context->buffer.position -= totcmdlen; |
| | | totcmdlen = 0; |
| | | } else { |
| | | if (context->parser_state.programHeader.type == SCPI_TOKEN_UNKNOWN) break; |
| | | if (context->parser_state.programHeader.type == SCPI_TOKEN_UNKNOWN |
| | | && context->parser_state.termination == SCPI_MESSAGE_TERMINATION_NONE) break; |
| | | if (totcmdlen >= context->buffer.position) break; |
| | | } |
| | | } |