nancy.liao
7 天以前 cc47c934744c759fa47133fc70b7d23aa4a2d7f1
libscpi/src/parser.c
@@ -55,7 +55,8 @@
 */
static size_t writeData(scpi_t * context, const char * data, size_t len) {
    if ((len > 0) && (data != NULL)) {
        return context->interface->write(context, data, len);
        return 0;
       // return context->interface->write(context, data, len);
    } else {
        return 0;
    }
@@ -126,7 +127,9 @@
 //负命令回调的执行、参数处理和错误管理
static scpi_bool_t processCommand(scpi_t * context) {
    //这个地方修改为 读comdlist->pattern
    const scpi_command_t * cmd = context->param_list.cmd;
    //const scpi_command_t * cmd = context->cmdlist->pattern;
    lex_state_t * state = &context->param_list.lex_state;
    scpi_bool_t result = TRUE;
    // 先检测是否为查询命令(以?结尾)
@@ -188,6 +191,7 @@
            return TRUE;
        }
    }
    context->SCPIerror = RETURN_NotFind;
    return FALSE;
}
@@ -229,6 +233,7 @@
        if (state->programHeader.type == SCPI_TOKEN_INVALID) {
            SCPI_ErrorPush(context, SCPI_ERROR_INVALID_CHARACTER);
            context->SCPIerror = RETURN_IllegalCommand;
            result = FALSE;
        } 
        else if (state->programHeader.len > 0) 
@@ -254,6 +259,7 @@
                size_t r2 = r;
                while (r2 > 0 && (data[r2 - 1] == '\r' || data[r2 - 1] == '\n')) r2--;
                SCPI_ErrorPushEx(context, SCPI_ERROR_UNDEFINED_HEADER, data, r2);
                context->SCPIerror = RETURN_UnDefine;
                result = FALSE;
            }
        }
@@ -372,7 +378,8 @@
            context->buffer.position = 0;
            context->buffer.data[context->buffer.position] = 0;
            SCPI_ErrorPush(context, SCPI_ERROR_INPUT_BUFFER_OVERRUN);
            return FALSE;
            context->SCPIerror = RETURN_LengthOverFlow;
            return result;
        }
        memcpy(&context->buffer.data[context->buffer.position], data, len);
        context->buffer.position += len;
@@ -1051,6 +1058,9 @@
    return result;
}
/**
 * Read signed/unsigned 32 bit integer parameter
 * @param context
@@ -1480,8 +1490,8 @@
 */
 //识别完整的SCPI命令
int scpiParser_detectProgramMessageUnit(scpi_parser_state_t * state, char * buffer, int len) {
    lex_state_t lex_state;
    scpi_token_t tmp;
    lex_state_t lex_state = {};
    scpi_token_t tmp = {};
    int result = 0;
    // 初始化词法分析
    lex_state.buffer = lex_state.pos = buffer;