I2C WRITE
Syntax
I2C WRITE <addr> <reg> <val> [<val> ...]
Description
Writes one or more bytes to a register of an I2C component. All numbers are hexadecimal. Up to 16 bytes can be written in one command. I2C transactions can add noise to the data of a running acquisition; prefer to write while acquisition is stopped.
Parameters
| Parameter | Type | Range | Description |
|---|---|---|---|
<addr> | hex | 0x00–0x7F | 7-bit I2C address (for example 0x48). |
<reg> | hex | 0x00–0xFF | Register address. |
<val> | hex | 0x00–0xFF | Bytes to write (1 to 16). |
Response
OK I2C WRITE bytes=<n>
Errors
| Reply | Condition |
|---|---|
ERR I2C WRITE i2c_error | The component did not acknowledge, or the transaction failed. |
ERR I2C WRITE bad_arg | Missing or malformed arguments, or address out of range. |
Example
Write two bytes to register 0x10 of the component at address 0x48:
i2c_write.py
from hmcls_udp import Board
board = Board("192.168.1.11")
reply = board.request("I2C WRITE 0x48 0x10 0x01 0xFF")
print("bytes written:", reply["bytes"])