I2CPy Façade

class quanser.communications.i2cpy.I2C(id=None, driver=None, freq=400000, auto_init=True)

Bases: object

A python wrapper for the Stream API that emulates the PyPi I2C class from i2cpy.

The Quanser Stream API is recommended when writing code from scratch but the wrapper is provided as a convenience when there is an existing code base using the PyPi I2C class from the i2cpy library.

However, unlike PyPi i2cpy, this wrapper works on Windows with Quanser devices that support I2C, such as the Quanser Mechatronic Sensors Trainer USB device. It is designed to be a plug-in replacement for PyPi i2cpy. Simply change the line:

>>> from i2cpy import I2C

in code using PyPi i2cpy to:

>>> from quanser.communications.i2cpy import I2C

It should be possible to use this python wrapper on Linux systems with the Quanser SDK or QUARC installed as well.

As usual, the I2C(bus) call will need to be adjusted as needed to use the appropriate bus. For example, for Quanser Mechatronic Sensors Trainer USB the call is typically:

>>> i2c = I2C(0)

because it will typically be bus 0 on Windows.

Variables

buffer_size (int) – The buffer size to use for the communications. It defaults to 256 and should generally not be changed.