bxError.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. class BxError:
  2. def __init__(self, error_code, name, description):
  3. self.ErrorCode = error_code
  4. self.Name = name
  5. self.Description = description
  6. # 错误码定义
  7. bxErrors = {
  8. 0: BxError(0, "ERR_NO", "No Err"),
  9. 1: BxError(1, "ERR_OUTOFGROUP", "Command Group Err"),
  10. 2: BxError(2, "ERR_NOCMD", "Not Found"),
  11. 3: BxError(3, "ERR_BUSY", "The Controller is busy now"),
  12. 4: BxError(4, "ERR_MEMORYVOLUME", "Out of the Memory Volume"),
  13. 5: BxError(5, "ERR_CHECKSUM", "CRC16 Checksum Err"),
  14. 6: BxError(6, "ERR_FILENOTEXIST", "File Not Exist"),
  15. 7: BxError(7, "ERR_FLASH", "Flash Access Err"),
  16. 8: BxError(8, "ERR_FILE_DOWNLOAD", "File Download Err"),
  17. 9: BxError(9, "ERR_FILE_NAME", "Filename Err"),
  18. 10: BxError(10, "ERR_FILE_TYPE", "File type Err"),
  19. 11: BxError(11, "ERR_FILE_CRC16", "File CRC16 Err"),
  20. 12: BxError(12, "ERR_FONT_NOT_EXIST", "Font Library Not Exist"),
  21. 13: BxError(13, "ERR_FIRMWARE_TYPE", "Firmware Type Err (Check the controller type)"),
  22. 14: BxError(14, "ERR_DATE_TIME_FORMAT", "Date Time format Err"),
  23. 15: BxError(15, "ERR_FILE_EXIST", "File Exist for File overwrite"),
  24. 16: BxError(16, "ERR_FILE_BLOCK_NUM", "File block number Err"),
  25. }
  26. def GetError(code):
  27. """根据错误码获取错误信息"""
  28. return bxErrors.get(code, BxError(code, "未知错误", "Unknown error code"))