:mod:`odbus` --- control slave modules on a PLC board ========================================================== .. module:: odbus :synopsis: pyb.I2C wrapper to control slave modules on a PLC board This module provides methods to list, read and write OD slave devices connected via I2C bus class ODBUS ------------- The ODBUS class provides a wrapper to I2C bus Usage example:: import odbus bus = odbus.ODBUS() odbus.list() bus.write(odbus.RELAY,odbus.CH1,1) # Switch the relay on Constructors ------------ .. class:: ODBUS() Construct an ODBUS object. The I2C bus is hard-coded. No additional parameters are required. Query devices -------------- .. method:: ODBUS.list() Query all devices currently on the bus. .. method:: ODBUS.read(device, address) Read the value, currently stored in the *address* location of the EEPROM of the device with the address *device*. Predefined locations are: * *ID* - the device ID * *ADDR* - the device address (i.e. *device*) * *RST* - restart the device * *CH1* - channel 1 (if present) * *CH2* - channel 2 (if present) * *ALRM* - alarm condition Predefined device IDs: * ``RELAY`` - 0x08 * ``IO`` - 0x09 .. method:: ODBUS.write(device, address, value) Write a value (must be an integer in the range of [0:255]) to the *address* location of the EEPROM of the device with the address *device*. Constants --------- .. data:: ID ADDR RST CH1 CH2 ALRM Predefined EEPROM locations. .. data:: RELAY IO Predefined device IDs.