smbus2¶
smbus2 - A drop-in replacement for smbus-cffi/smbus-python
- class smbus2.SMBus(bus=None, force=False)¶
- block_process_call(i2c_addr, register, data, force=None)¶
Executes a SMBus Block Process Call, sending a variable-size data block and receiving another variable-size response
- close()¶
Close the i2c connection.
- enable_pec(enable=True)¶
Enable/Disable PEC (Packet Error Checking) - SMBus 1.1 and later
- Parameters:
enable (Boolean)
- i2c_rdwr(*i2c_msgs)¶
Combine a series of i2c read and write operations in a single transaction (with repeated start bits but no stop bits in between).
This method takes i2c_msg instances as input, which must be created first with
i2c_msg.read()
ori2c_msg.write()
.- Parameters:
i2c_msgs (i2c_msg) – One or more i2c_msg class instances.
- Return type:
None
- open(bus)¶
Open a given i2c bus.
- property pec¶
Get and set SMBus PEC. 0 = disabled (default), 1 = enabled.
- process_call(i2c_addr, register, value, force=None)¶
Executes a SMBus Process Call, sending a 16-bit value and receiving a 16-bit response
- read_block_data(i2c_addr, register, force=None)¶
Read a block of up to 32-bytes from a given register.
- read_byte(i2c_addr, force=None)¶
Read a single byte from a device.
- read_byte_data(i2c_addr, register, force=None)¶
Read a single byte from a designated register.
- read_i2c_block_data(i2c_addr, register, length, force=None)¶
Read a block of byte data from a given register.
- read_word_data(i2c_addr, register, force=None)¶
Read a single word (2 bytes) from a given register.
- write_block_data(i2c_addr, register, data, force=None)¶
Write a block of byte data to a given register.
- write_byte(i2c_addr, value, force=None)¶
Write a single byte to a device.
- write_byte_data(i2c_addr, register, value, force=None)¶
Write a byte to a given register.
- write_i2c_block_data(i2c_addr, register, data, force=None)¶
Write a block of byte data to a given register.
- write_quick(i2c_addr, force=None)¶
Perform quick transaction. Throws IOError if unsuccessful. :param i2c_addr: i2c address :type i2c_addr: int :param force: :type force: Boolean