cheap_modbus_rtu
Lightweight control of cheap Modbus RTU components using Python
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
cheap_modbus_rtu.cheap_modbus_io.CheapModbusRelayIOModule Class Reference

Control affordable Modbus relay PCBs via RS-485 Modbus RTU. More...

Public Member Functions

def __init__ (self, str serial_device_name=None, int slave_id=255, **kwargs)
 
def set_output (self, int output_no, bool active=True)
 Set specified output. More...
 
def clear_output (self, int output_no)
 Disable specified output. More...
 
bool get_input (self, int input_no)
 Return the state of the specified digital input. More...
 
def set_slave_id (self, int slave_id_new)
 Set the slave ID. More...
 
int get_broadcast_slave_id (self)
 Sends a broadcast query to all devices on the bus. More...
 

Public Attributes

 master
 
 slave_id
 

Static Public Attributes

int DI_REGISTER = 10001
 
int SLAVE_ID_REGISTER = 40001
 

Detailed Description

Control affordable Modbus relay PCBs via RS-485 Modbus RTU.

These come in one, two, four, eight or more channel variants and feature different numbers of additional digital IO pins.

While the relay outputs are insulated for mains voltage application, the digital IO pins are only featuring functional or low-voltage isolation, some variants do not have isolated inputs at all.

The detailed implementation varies slightly between variants, the difference (for the time being) is the number of input state values contained in the tuple returned from the "get_inputs()" method.

All other methods are identical.

==> Please see documentation of the derived classes for details:

Brand name is "bestep" among others.

Member Function Documentation

◆ clear_output()

def cheap_modbus_rtu.cheap_modbus_io.CheapModbusRelayIOModule.clear_output (   self,
int  output_no 
)

Disable specified output.

Parameters
output_noOutput number, starts counting at 1

◆ get_broadcast_slave_id()

int cheap_modbus_rtu.cheap_modbus_io.CheapModbusRelayIOModule.get_broadcast_slave_id (   self)

Sends a broadcast query to all devices on the bus.

   This likely only works when only one device is attached to the bus
Returns
The first found slave ID.

◆ get_input()

bool cheap_modbus_rtu.cheap_modbus_io.CheapModbusRelayIOModule.get_input (   self,
int  input_no 
)

Return the state of the specified digital input.

Parameters
input_noInput number, starts counting at 1
Returns
True if input is enabled, False if disabled

◆ set_output()

def cheap_modbus_rtu.cheap_modbus_io.CheapModbusRelayIOModule.set_output (   self,
int  output_no,
bool   active = True 
)

Set specified output.

Parameters
output_noOutput number, starts counting at 1
activeEnable output if active == True (default) Disable output if active == False

◆ set_slave_id()

def cheap_modbus_rtu.cheap_modbus_io.CheapModbusRelayIOModule.set_slave_id (   self,
int  slave_id_new 
)

Set the slave ID.

Warning
This sets a configuration value, possibly writing directly to FLASH. So this should not be called repeatedly!
Parameters
slave_id_newNew Modbus slave ID

The documentation for this class was generated from the following file: