odbus — 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.ODBUS

Construct an ODBUS object. The I2C bus is hard-coded. No additional parameters are required.

Query devices

ODBUS.list()

Query all devices currently on the bus.

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

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

odbus.ID
odbus.ADDR
odbus.RST
odbus.CH1
odbus.CH2
odbus.ALRM

Predefined EEPROM locations.

odbus.RELAY
odbus.IO

Predefined device IDs.