You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

#include "errorcode.h"
#define ERR2STR(code) \
case code: \
return #code;
#define ERR_ITERM(enum) \
{ enum, #enum }
static ecode_table_item_t table[] = {
ERR_ITERM(ksucc),
ERR_ITERM(kfail),
ERR_ITERM(kparam_out_of_range),
ERR_ITERM(kcmd_not_support),
ERR_ITERM(kdevice_is_busy),
ERR_ITERM(kdevice_is_offline),
ERR_ITERM(kovertime),
ERR_ITERM(knoack),
ERR_ITERM(kerrorack),
ERR_ITERM(kdevice_offline),
ERR_ITERM(ksubdevice_overtime),
ERR_ITERM(kbuffer_not_enough),
ERR_ITERM(kcmd_param_num_error),
ERR_ITERM(kcheckcode_is_error),
ERR_ITERM(killegal_operation),
ERR_ITERM(kstep_motor_not_found_zero_point),
ERR_ITERM(kstep_motor_not_go_zero),
ERR_ITERM(kstep_motor_over_temperature),
ERR_ITERM(kstep_motor_over_voltage),
ERR_ITERM(kstep_motor_run_overtime),
ERR_ITERM(kstep_motor_not_enable),
ERR_ITERM(kstep_motor_ioindex_out_of_range),
ERR_ITERM(kstep_motor_subic_reset),
ERR_ITERM(kstep_motor_drv_err),
ERR_ITERM(kstep_motor_uv_cp),
ERR_ITERM(kstep_motor_not_found_point_edge),
};
const char* error2str(int32_t code) {
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++) {
if (table[i].index == code) {
return table[i].info;
}
}
return "unknown error";
}
ecode_table_item_t* error_get_table() { return table; }
int error_get_table_size() { return sizeof(table) / sizeof(table[0]); }