March 2019 AN4502 Rev 3 1/74 AN4502 Application note STM32 SMBus/PMBusTM Expansion Package for STM32CubeTM Introduction This document describes the X-CUBE-SMBUS, STM32 SMBus/PMBus™ (system. Smbus2 - A drop-in replacement for smbus-cffi/smbus-python. Class smbus2.SMBus (bus=None, force=False) ¶. Blockprocesscall (i2caddr, register, data, force=None) ¶. Executes a SMBus Block Process Call, sending a variable-size data block and receiving another variable-size response. Drivers Library. To find the latest driver for your computer we recommend running our Free Driver Scan. SM Bus Controller - Driver Download. Vendor:. Product: SM Bus Controller. Hardware Class: Net.
smbus2 - A drop-in replacement for smbus-cffi/smbus-python
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 datablock and receiving another variable-size response
Parameters: |
|
---|---|
Returns: | List of bytes |
Return type: | list |
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 singletransaction (with repeated start bits but no stop bits in between).
This method takes i2c_msg instances as input, which must be createdfirst with i2c_msg.read()
or i2c_msg.write()
.
Python Smbus Library
Parameters: | i2c_msgs (i2c_msg) – One or more i2c_msg class instances. |
---|---|
Return type: | None |
open
(bus)¶Open a given i2c bus.
Parameters: | bus (int or str) – i2c bus number (e.g. 0 or 1)or an absolute file path (e.g. ‘/dev/i2c-42’). |
---|---|
Raises: | TypeError – if type(bus) is not in (int, str) |
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
Parameters: |
|
---|---|
Return type: |
read_block_data
(i2c_addr, register, force=None)¶Read a block of up to 32-bytes from a given register.
Parameters: |
|
---|---|
Returns: | List of bytes |
Return type: | list |
Micropython Smbus Library
read_byte
(i2c_addr, force=None)¶Read a single byte from a device.
Return type: | |
---|---|
Parameters: |
|
Returns: | Read byte value |
read_byte_data
(i2c_addr, register, force=None)¶Read a single byte from a designated register.
Parameters: |
|
---|---|
Returns: | Read byte value |
Return type: |
read_i2c_block_data
(i2c_addr, register, length, force=None)¶Read a block of byte data from a given register.
Parameters: |
|
---|---|
Returns: | List of bytes |
Return type: | list |
read_word_data
(i2c_addr, register, force=None)¶Read a single word (2 bytes) from a given register.
Parameters: |
|
---|---|
Returns: | 2-byte word |
Return type: |
write_block_data
(i2c_addr, register, data, force=None)¶Write a block of byte data to a given register.
Parameters: |
|
---|---|
Return type: |
write_byte
(i2c_addr, value, force=None)¶Write a single byte to a device.
Parameters: |
|
---|
write_byte_data
(i2c_addr, register, value, force=None)¶Write a byte to a given register.
Parameters: |
|
---|---|
Return type: |
write_i2c_block_data
(i2c_addr, register, data, force=None)¶Write a block of byte data to a given register.
Parameters: |
|
---|---|
Return type: |
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
write_word_data
(i2c_addr, register, value, force=None)¶Write a single word (2 bytes) to a given register.
Parameters: |
|
---|---|
Return type: |
smbus2.
i2c_msg
¶As defined in i2c.h
.
addr
¶Structure/Union member
buf
¶Structure/Union member
flags
¶Structure/Union member
len
¶Structure/Union member
read
(address, length)¶Prepares an i2c read transaction.
Parameters: |
|
---|---|
Type: | address: int |
Type: | length: int |
Returns: | New |
Return type: |
write
(address, buf)¶Prepares an i2c write transaction.
Parameters: |
|
---|---|
Returns: | New |
Return type: |
Released:
smbus2 is a drop-in replacement for smbus-cffi/smbus-python in pure Python
Project description
A drop-in replacement for smbus-cffi/smbus-python in pure Python
smbus2 is (yet another) pure Python implementation of of the python-smbus package.
It was designed from the ground up with two goals in mind:
- It should be a drop-in replacement of smbus. The syntax shall be the same.
- Use the inherent i2c structs and unions to a greater extent than other pure Python implementations like pysmbus does. By doing so, it will be more feature complete and easier to extend.
Currently supported features are:
- Get i2c capabilities (I2C_FUNCS)
- SMBus Packet Error Checking (PEC) support
- read_byte
- write_byte
- read_byte_data
- write_byte_data
- read_word_data
- write_word_data
- read_i2c_block_data
- write_i2c_block_data
- write_quick
- process_call
- read_block_data
- write_block_data
- block_process_call
- i2c_rdwr - combined write/read transactions with repeated start
It is developed on Python 2.7 but works without any modifications in Python 3.X too.
More information about updates and general changes are recorded in the change log.
smbus2 installs next to smbus as the package, so it's not really a 100% replacement. You must change the module name.
Example 1a: Read a byte
Example 1b: Read a byte using 'with'
This is the very same example but safer to use since the smbus will be closed automatically when exiting the with block.
Example 1c: Read a byte with PEC enabled
Same example with Packet Error Checking enabled.
Example 2: Read a block of data
You can read up to 32 bytes at once.
Example 3: Write a byte
Example 4: Write a block of data
It is possible to write 32 bytes at the time, but I have found that error-prone. Write less and add a delay in between if you run into trouble.
Starting with v0.2, the smbus2 library also has support for combined read and write transactions. i2c_rdwr is not really a SMBus feature but comes in handy when the master needs to:
- read or write bulks of data larger than SMBus' 32 bytes limit.
- write some data and then read from the slave with a repeated start and no stop bit between.
Each operation is represented by a i2c_msg message object.
Example 5: Single i2c_rdwr
Example 6: Dual i2c_rdwr
To perform dual operations just add more i2c_msg instances to the bus call:
Example 7: Access i2c_msg data
All data is contained in the i2c_msg instances. Here are some data access alternatives.
From PyPi with pip
:
From conda-forge using conda
:
Installation from source code is straight forward:
Release historyRelease notifications | RSS feed
0.4.1
0.4.0
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size smbus2-0.4.1-py2.py3-none-any.whl (11.5 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes |
Filename, size smbus2-0.4.1.tar.gz (16.8 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for smbus2-0.4.1-py2.py3-none-any.whl
Algorithm | Hash digest |
---|---|
SHA256 | 8b1e70cda011b6fb3caf8377a1084f73a5aa99392b78529f140b0a3f06468f6c |
MD5 | 47c994cf8cb7207a922c748fdedfd91c |
BLAKE2-256 | c8bf62ef029fb7077fc87c3539f7365859bccc6cedb2bb20796b737b788c8d09 |
Hashes for smbus2-0.4.1.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | 6276eb599b76c4e74372f2582d2282f03b4398f0da16bc996608e4f21557ca9b |
MD5 | ea4bba25b43863aecd6ec33b2252fdae |
BLAKE2-256 | d933787448c69603eec96af07d36f7ae3a7e3fce4020632eddb55152dc903233 |