修改了一部分的宏定义声明和屏蔽了一些调试时的无效干扰
| | |
| | | |
| | | build/ |
| | | .vscode/ |
| | | *Zone.Identifier |
| | |
| | | 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 */ |
| | |
| | | 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); |
| | |
| | | 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 { |
| | |
| | | scpi_command_callback_t reset; |
| | | }; |
| | | |
| | | |
| | | struct _scpi_t { |
| | | //命令表的指针 |
| | | const scpi_command_t * cmdlist; |
| | |
| | | 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, |
| | |
| | | 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"); |
| | |
| | | */ |
| | | 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; |
| | | } |
| | |
| | | |
| | | //负命令回调的执行、参数处理和错误管理 |
| | | 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; |
| | | // 先检测是否为查询命令(以?结尾) |
| | |
| | | return TRUE; |
| | | } |
| | | } |
| | | context->SCPIerror = RETURN_NotFind; |
| | | return FALSE; |
| | | } |
| | | |
| | |
| | | |
| | | 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) |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Read signed/unsigned 32 bit integer parameter |
| | | * @param context |
| | |
| | | */ |
| | | //识别完整的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; |
| | |
| | | } |
| | | |
| | | 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 */ |
| | |
| | | (void) argv; |
| | | |
| | | // SCPI_Init(&scpi_context, |
| | | // myscpi_commands, |
| | | // scpi_commands, |
| | | // &scpi_interface, |
| | | // scpi_units_def, |
| | | // SCPI_IDN1, SCPI_IDN2, SCPI_IDN3, SCPI_IDN4, |