#pragma once #include #ifdef __cplusplus extern "C" { #endif #define ERROR_CODE(errortype, suberrorcode) (errortype + suberrorcode) typedef enum { ksucc = ERROR_CODE(0, 0), kfail = ERROR_CODE(0, 1), kparam_out_of_range = ERROR_CODE(100, 2), // 参数超出范围 kcmd_not_support = ERROR_CODE(100, 3), // 操作不支持 kdevice_is_busy = ERROR_CODE(100, 4), // 设备忙 kdevice_is_offline = ERROR_CODE(100, 5), // 设备离线 kovertime = ERROR_CODE(100, 6), knoack = ERROR_CODE(100, 7), kerrorack = ERROR_CODE(100, 8), kdevice_offline = ERROR_CODE(100, 9), ksubdevice_overtime = ERROR_CODE(100, 11), kbuffer_not_enough = ERROR_CODE(100, 12), kcmd_param_num_error = ERROR_CODE(100, 14), kcheckcode_is_error = ERROR_CODE(100, 15), killegal_operation = ERROR_CODE(100, 16), kstep_motor_not_found_zero_point = ERROR_CODE(600, 0), // 未找到零点 kstep_motor_not_go_zero = ERROR_CODE(600, 1), // 设备未归零 kstep_motor_over_temperature = ERROR_CODE(600, 2), // 过温 kstep_motor_over_voltage = ERROR_CODE(600, 3), // 过压 kstep_motor_run_overtime = ERROR_CODE(600, 4), // 运行超时 kstep_motor_not_enable = ERROR_CODE(600, 5), // 电机未使能 kstep_motor_ioindex_out_of_range = ERROR_CODE(600, 6), // IO超出范围 kstep_motor_subic_reset = ERROR_CODE(600, 7), // 子IC复位 kstep_motor_drv_err = ERROR_CODE(600, 8), // 驱动器异常 kstep_motor_uv_cp = ERROR_CODE(600, 9), // 驱动器异常 kstep_motor_not_found_point_edge = ERROR_CODE(600, 10), // 未找到零点 } error_t; typedef struct { int index; const char* info; } ecode_table_item_t; const char* error2str(int32_t code); ecode_table_item_t* error_get_table(); int error_get_table_size(); #ifdef __cplusplus } #endif