1# i2c_compare_bytes
2
3## Description
4
5Compares device register bytes to an array of expected values. Communicates with
6the device directly using the [I2C interface](i2c_interface.md).
7
8All of the bytes will be read in a single I2C operation.
9
10The bytes must be specified in the same order as they will be received from the
11device. For example, a PMBus device transmits byte values in little-endian order
12(least significant byte first).
13
14## Properties
15
16| Name     | Required | Type             | Description                                                                                                                                                                                                                                                                                                                                     |
17| :------- | :------: | :--------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18| register |   yes    | string           | Device register address expressed in hexadecimal. Must be prefixed with 0x and surrounded by double quotes. This is the location of the first byte.                                                                                                                                                                                             |
19| values   |   yes    | array of strings | One or more expected byte values expressed in hexadecimal. Each value must be prefixed with 0x and surrounded by double quotes.                                                                                                                                                                                                                 |
20| masks    |    no    | array of strings | One or more bit masks expressed in hexadecimal. Each mask must be prefixed with 0x and surrounded by double quotes. The number of bit masks must match the number of expected byte values. Each mask specifies which bits should be compared within the corresponding byte value. Only the bits with a value of 1 in the mask will be compared. |
21
22## Return Value
23
24Returns true if all the register bytes contained the expected values, otherwise
25returns false.
26
27## Examples
28
29```json
30{
31  "comments": [
32    "Check if register 0xA0 contains 0xFF01.",
33    "Device returns bytes in big-endian order."
34  ],
35  "i2c_compare_bytes": {
36    "register": "0xA0",
37    "values": ["0xFF", "0x01"]
38  }
39}
40```
41
42```json
43{
44  "comments": [
45    "Check if register 0x82 contains 0x7302.",
46    "Device returns bytes in little-endian order.",
47    "Ignore the most significant bit in each byte."
48  ],
49  "i2c_compare_bytes": {
50    "register": "0x82",
51    "values": ["0x02", "0x73"],
52    "masks": ["0x7F", "0x7F"]
53  }
54}
55```
56