cros_ec_python.constants.COMMON

 1from enum import Enum
 2
 3# Type hints, only for code readability
 4Int8 = int
 5Int16 = int
 6Int32 = int
 7Int64 = int
 8UInt8 = int
 9UInt16 = int
10UInt32 = int
11UInt64 = int
12
13
14# Macros from linux
15def BIT(nr):
16    return 1 << nr
17
18
19class EcStatus(Enum):
20    """
21    Host command response codes (16-bit).
22    """
23    EC_RES_SUCCESS = 0
24    EC_RES_INVALID_COMMAND = 1
25    EC_RES_ERROR = 2
26    EC_RES_INVALID_PARAM = 3
27    EC_RES_ACCESS_DENIED = 4
28    EC_RES_INVALID_RESPONSE = 5
29    EC_RES_INVALID_VERSION = 6
30    EC_RES_INVALID_CHECKSUM = 7
31    EC_RES_IN_PROGRESS = 8
32    "Accepted, command in progress"
33    EC_RES_UNAVAILABLE = 9
34    "No response available"
35    EC_RES_TIMEOUT = 10
36    "We got a timeout"
37    EC_RES_OVERFLOW = 11
38    "Table / data overflow"
39    EC_RES_INVALID_HEADER = 12
40    "Header contains invalid data"
41    EC_RES_REQUEST_TRUNCATED = 13
42    "Didn't get the entire request"
43    EC_RES_RESPONSE_TOO_BIG = 14
44    "Response was too big to handle"
45    EC_RES_BUS_ERROR = 15
46    "Communications bus error"
47    EC_RES_BUSY = 16
48    "Up but too busy.  Should retry"
49    EC_RES_INVALID_HEADER_VERSION = 17
50    "Header version invalid"
51    EC_RES_INVALID_HEADER_CRC = 18
52    "Header CRC invalid"
53    EC_RES_INVALID_DATA_CRC = 19
54    "Data CRC invalid"
55    EC_RES_DUP_UNAVAILABLE = 20
56    "Can't resend response"
Int8 = <class 'int'>
Int16 = <class 'int'>
Int32 = <class 'int'>
Int64 = <class 'int'>
UInt8 = <class 'int'>
UInt16 = <class 'int'>
UInt32 = <class 'int'>
UInt64 = <class 'int'>
def BIT(nr):
16def BIT(nr):
17    return 1 << nr
class EcStatus(enum.Enum):
20class EcStatus(Enum):
21    """
22    Host command response codes (16-bit).
23    """
24    EC_RES_SUCCESS = 0
25    EC_RES_INVALID_COMMAND = 1
26    EC_RES_ERROR = 2
27    EC_RES_INVALID_PARAM = 3
28    EC_RES_ACCESS_DENIED = 4
29    EC_RES_INVALID_RESPONSE = 5
30    EC_RES_INVALID_VERSION = 6
31    EC_RES_INVALID_CHECKSUM = 7
32    EC_RES_IN_PROGRESS = 8
33    "Accepted, command in progress"
34    EC_RES_UNAVAILABLE = 9
35    "No response available"
36    EC_RES_TIMEOUT = 10
37    "We got a timeout"
38    EC_RES_OVERFLOW = 11
39    "Table / data overflow"
40    EC_RES_INVALID_HEADER = 12
41    "Header contains invalid data"
42    EC_RES_REQUEST_TRUNCATED = 13
43    "Didn't get the entire request"
44    EC_RES_RESPONSE_TOO_BIG = 14
45    "Response was too big to handle"
46    EC_RES_BUS_ERROR = 15
47    "Communications bus error"
48    EC_RES_BUSY = 16
49    "Up but too busy.  Should retry"
50    EC_RES_INVALID_HEADER_VERSION = 17
51    "Header version invalid"
52    EC_RES_INVALID_HEADER_CRC = 18
53    "Header CRC invalid"
54    EC_RES_INVALID_DATA_CRC = 19
55    "Data CRC invalid"
56    EC_RES_DUP_UNAVAILABLE = 20
57    "Can't resend response"

Host command response codes (16-bit).

EC_RES_SUCCESS = <EcStatus.EC_RES_SUCCESS: 0>
EC_RES_INVALID_COMMAND = <EcStatus.EC_RES_INVALID_COMMAND: 1>
EC_RES_ERROR = <EcStatus.EC_RES_ERROR: 2>
EC_RES_INVALID_PARAM = <EcStatus.EC_RES_INVALID_PARAM: 3>
EC_RES_ACCESS_DENIED = <EcStatus.EC_RES_ACCESS_DENIED: 4>
EC_RES_INVALID_RESPONSE = <EcStatus.EC_RES_INVALID_RESPONSE: 5>
EC_RES_INVALID_VERSION = <EcStatus.EC_RES_INVALID_VERSION: 6>
EC_RES_INVALID_CHECKSUM = <EcStatus.EC_RES_INVALID_CHECKSUM: 7>
EC_RES_IN_PROGRESS = <EcStatus.EC_RES_IN_PROGRESS: 8>

Accepted, command in progress

EC_RES_UNAVAILABLE = <EcStatus.EC_RES_UNAVAILABLE: 9>

No response available

EC_RES_TIMEOUT = <EcStatus.EC_RES_TIMEOUT: 10>

We got a timeout

EC_RES_OVERFLOW = <EcStatus.EC_RES_OVERFLOW: 11>

Table / data overflow

EC_RES_INVALID_HEADER = <EcStatus.EC_RES_INVALID_HEADER: 12>

Header contains invalid data

EC_RES_REQUEST_TRUNCATED = <EcStatus.EC_RES_REQUEST_TRUNCATED: 13>

Didn't get the entire request

EC_RES_RESPONSE_TOO_BIG = <EcStatus.EC_RES_RESPONSE_TOO_BIG: 14>

Response was too big to handle

EC_RES_BUS_ERROR = <EcStatus.EC_RES_BUS_ERROR: 15>

Communications bus error

EC_RES_BUSY = <EcStatus.EC_RES_BUSY: 16>

Up but too busy. Should retry

EC_RES_INVALID_HEADER_VERSION = <EcStatus.EC_RES_INVALID_HEADER_VERSION: 17>

Header version invalid

EC_RES_INVALID_HEADER_CRC = <EcStatus.EC_RES_INVALID_HEADER_CRC: 18>

Header CRC invalid

EC_RES_INVALID_DATA_CRC = <EcStatus.EC_RES_INVALID_DATA_CRC: 19>

Data CRC invalid

EC_RES_DUP_UNAVAILABLE = <EcStatus.EC_RES_DUP_UNAVAILABLE: 20>

Can't resend response