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.

55 lines
1.9 KiB

1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define ERROR_CODE(errortype, suberrorcode) (errortype + suberrorcode)
  7. typedef enum {
  8. ksucc = ERROR_CODE(0, 0),
  9. kfail = ERROR_CODE(0, 1),
  10. kparam_out_of_range = ERROR_CODE(100, 2), // 参数超出范围
  11. kcmd_not_support = ERROR_CODE(100, 3), // 操作不支持
  12. kdevice_is_busy = ERROR_CODE(100, 4), // 设备忙
  13. kdevice_is_offline = ERROR_CODE(100, 5), // 设备离线
  14. kovertime = ERROR_CODE(100, 6),
  15. knoack = ERROR_CODE(100, 7),
  16. kerrorack = ERROR_CODE(100, 8),
  17. kdevice_offline = ERROR_CODE(100, 9),
  18. ksubdevice_overtime = ERROR_CODE(100, 11),
  19. kbuffer_not_enough = ERROR_CODE(100, 12),
  20. kcmd_param_num_error = ERROR_CODE(100, 14),
  21. kcheckcode_is_error = ERROR_CODE(100, 15),
  22. killegal_operation = ERROR_CODE(100, 16),
  23. kstep_motor_not_found_zero_point = ERROR_CODE(600, 0), // 未找到零点
  24. kstep_motor_not_go_zero = ERROR_CODE(600, 1), // 设备未归零
  25. kstep_motor_over_temperature = ERROR_CODE(600, 2), // 过温
  26. kstep_motor_over_voltage = ERROR_CODE(600, 3), // 过压
  27. kstep_motor_run_overtime = ERROR_CODE(600, 4), // 运行超时
  28. kstep_motor_not_enable = ERROR_CODE(600, 5), // 电机未使能
  29. kstep_motor_ioindex_out_of_range = ERROR_CODE(600, 6), // IO超出范围
  30. kstep_motor_subic_reset = ERROR_CODE(600, 7), // 子IC复位
  31. kstep_motor_drv_err = ERROR_CODE(600, 8), // 驱动器异常
  32. kstep_motor_uv_cp = ERROR_CODE(600, 9), // 驱动器异常
  33. kstep_motor_not_found_point_edge = ERROR_CODE(600, 10), // 未找到零点
  34. } error_t;
  35. typedef struct {
  36. int index;
  37. const char* info;
  38. } ecode_table_item_t;
  39. const char* error2str(int32_t code);
  40. ecode_table_item_t* error_get_table();
  41. int error_get_table_size();
  42. #ifdef __cplusplus
  43. }
  44. #endif