Loading...
Searching...
No Matches
infrared_error_code.h
1#pragma once
2
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7typedef enum {
8 InfraredErrorCodeNone = 0,
9 InfraredErrorCodeFileOperationFailed = 0x800000,
10 InfraredErrorCodeWrongFileType = 0x80000100,
11 InfraredErrorCodeWrongFileVersion = 0x80000200,
12
13 //Common signal errors
14 InfraredErrorCodeSignalTypeUnknown = 0x80000300,
15 InfraredErrorCodeSignalNameNotFound = 0x80000400,
16 InfraredErrorCodeSignalUnableToReadType = 0x80000500,
17 InfraredErrorCodeSignalUnableToWriteType = 0x80000600,
18
19 //Raw signal errors
20 InfraredErrorCodeSignalRawUnableToReadFrequency = 0x80000700,
21 InfraredErrorCodeSignalRawUnableToReadDutyCycle = 0x80000800,
22 InfraredErrorCodeSignalRawUnableToReadTimingsSize = 0x80000900,
23 InfraredErrorCodeSignalRawUnableToReadTooLongData = 0x80000A00,
24 InfraredErrorCodeSignalRawUnableToReadData = 0x80000B00,
25
26 InfraredErrorCodeSignalRawUnableToWriteFrequency = 0x80000C00,
27 InfraredErrorCodeSignalRawUnableToWriteDutyCycle = 0x80000D00,
28 InfraredErrorCodeSignalRawUnableToWriteData = 0x80000E00,
29
30 //Message signal errors
31 InfraredErrorCodeSignalMessageUnableToReadProtocol = 0x80000F00,
32 InfraredErrorCodeSignalMessageUnableToReadAddress = 0x80001000,
33 InfraredErrorCodeSignalMessageUnableToReadCommand = 0x80001100,
34 InfraredErrorCodeSignalMessageIsInvalid = 0x80001200,
35
36 InfraredErrorCodeSignalMessageUnableToWriteProtocol = 0x80001300,
37 InfraredErrorCodeSignalMessageUnableToWriteAddress = 0x80001400,
38 InfraredErrorCodeSignalMessageUnableToWriteCommand = 0x80001500,
39} InfraredErrorCode;
40
41#define INFRARED_ERROR_CODE_MASK (0xFFFFFF00)
42#define INFRARED_ERROR_INDEX_MASK (0x000000FF)
43
44#define INFRARED_ERROR_GET_CODE(error) ((error) & INFRARED_ERROR_CODE_MASK)
45#define INFRARED_ERROR_GET_INDEX(error) ((error) & INFRARED_ERROR_INDEX_MASK)
46#define INFRARED_ERROR_SET_INDEX(code, index) ((code) |= ((index) & INFRARED_ERROR_INDEX_MASK))
47
48#define INFRARED_ERROR_PRESENT(error) (INFRARED_ERROR_GET_CODE(error) != InfraredErrorCodeNone)
49#define INFRARED_ERROR_CHECK(error, test_code) (INFRARED_ERROR_GET_CODE(error) == (test_code))
50
51#ifdef __cplusplus
52}
53#endif