nancy.liao
7 天以前 cc47c934744c759fa47133fc70b7d23aa4a2d7f1
修改了一部分的宏定义声明和屏蔽了一些调试时的无效干扰
8个文件已修改
53 ■■■■ 已修改文件
.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/inc/scpi/ieee488.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/inc/scpi/parser.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/inc/scpi/types.h 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/ieee488.c 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/parser.c 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/scpi-def.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/test-interactive.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -41,3 +41,4 @@
build/
.vscode/
*Zone.Identifier
libscpi/inc/scpi/ieee488.h
@@ -59,8 +59,6 @@
    scpi_result_t SCPI_CoreTstQ(scpi_t * context);
    scpi_result_t SCPI_CoreWai(scpi_t * context);
    scpi_result_t SCPI_NanCy(scpi_t * context);
#define STB_R01 0x01    /* Not used */
#define STB_PRO 0x02    /* Protection Event Flag */
libscpi/inc/scpi/parser.h
@@ -121,6 +121,10 @@
    scpi_bool_t SCPI_ParamUInt64(scpi_t * context, uint64_t * value, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamFloat(scpi_t * context, float * value, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamDouble(scpi_t * context, double * value, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamCharacters(scpi_t * context, const char ** value, size_t * len, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamArbitraryBlock(scpi_t * context, const char ** value, size_t * len, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamCopyText(scpi_t * context, char * buffer, size_t buffer_len, size_t * copy_len, scpi_bool_t mandatory);
libscpi/inc/scpi/types.h
@@ -368,6 +368,20 @@
        SCPI_NUM_NINF,
        SCPI_NUM_AUTO
    };
    enum SCPIRError
    {
        RETURN_TRUE = 0,
        //命令未定义
        RETURN_UnDefine = -1,
        //长度溢出
        RETURN_LengthOverFlow = -2,
        //命令非法
        RETURN_IllegalCommand = -3,
        //回调函数没有找到
        RETURN_NotFind = -4
    };
    typedef enum _scpi_special_number_t scpi_special_number_t;
    struct _scpi_choice_def_t {
@@ -420,6 +434,7 @@
        scpi_command_callback_t reset;
    };
    struct _scpi_t {
        //命令表的指针
        const scpi_command_t * cmdlist;
@@ -455,10 +470,12 @@
        const char * idn[4];
        //剩余待传输的字节
        size_t arbitrary_remaining;
        //output为自增字段,保存返回结果,提供给程序响应内部输出
        char outPut[1024];
        int SCPIerror;
    };
    enum _scpi_array_format_t {
        SCPI_FORMAT_ASCII = 0,
        SCPI_FORMAT_NORMAL = 1,
libscpi/src/ieee488.c
@@ -329,8 +329,7 @@
        if (context->idn[i])
        {
            char* outPut = "IDNS响应";
            memcpy(context->outPut,outPut,strlen(outPut));
            context->interface->write(context,context->idn[i],0);
           // context->interface->write(context,context->idn[i],0);
            SCPI_ResultMnemonic(context, context->idn[i]);
        } else {
            SCPI_ResultMnemonic(context, "0");
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;
libscpi/src/scpi-def.cpp
@@ -98,7 +98,7 @@
}
static scpi_result_t DMM_ConfigureVoltageDc(scpi_t * context) {
    double param1, param2;
    double param1 = -1.0, param2 = -1.0;
    fprintf(stderr, "conf:volt:dc\r\n"); /* debug command name */
    /* read first parameter if present */
libscpi/src/test-interactive.cpp
@@ -91,7 +91,7 @@
    (void) argv;
    // SCPI_Init(&scpi_context,
    //         myscpi_commands,
      //       scpi_commands,
    //         &scpi_interface,
    //         scpi_units_def,
    //         SCPI_IDN1, SCPI_IDN2, SCPI_IDN3, SCPI_IDN4,