cheap_modbus_rtu
Lightweight control of cheap Modbus RTU components using Python
|
Control affordable Modbus relay PCBs via RS-485 Modbus RTU. More...
Public Member Functions | |
def | __init__ (self, int slave_id=255, str serial_device_name=None, int baudrate=9600, **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... | |
tuple[bool,...] | get_inputs (self) |
Returns the state of the digital inputs. More... | |
def | set_slave_id (self, int slave_id_new) |
Set the slave ID. More... | |
def | set_baudrate (self, int baudrate=9600) |
Set RS485 serial baud rate. More... | |
def | do_factory_reset (self) |
Factory reset not implemented for the relay modules. | |
int | get_slave_id (self) |
Sends a broadcast query to all devices on the bus. More... | |
Public Attributes | |
slave_id | |
master | |
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.
def cheap_modbus_rtu.cheap_modbus_io.RelayModule.clear_output | ( | self, | |
int | output_no | ||
) |
Disable specified output.
output_no | Output number, starts counting at 1 |
bool cheap_modbus_rtu.cheap_modbus_io.RelayModule.get_input | ( | self, | |
int | input_no | ||
) |
Return the state of the specified digital input.
input_no | Input number, starts counting at 1 |
tuple[bool, ...] cheap_modbus_rtu.cheap_modbus_io.RelayModule.get_inputs | ( | self | ) |
Returns the state of the digital inputs.
|
inherited |
Sends a broadcast query to all devices on the bus.
This only works when only one device is attached to the bus
def cheap_modbus_rtu.cheap_modbus_io.RelayModule.set_baudrate | ( | self, | |
int | baudrate = 9600 |
||
) |
Set RS485 serial baud rate.
FIXME | 1200 and 2400 are undocumented. Really possible? |
baudrate | Can be 1200, 2400, 4800, 9600 (default) or 19200 |
Reimplemented from cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.
def cheap_modbus_rtu.cheap_modbus_io.RelayModule.set_output | ( | self, | |
int | output_no, | ||
bool | active = True |
||
) |
Set specified output.
output_no | Output number, starts counting at 1 |
active | Enable output if active == True (default) Disable output if active == False |
def cheap_modbus_rtu.cheap_modbus_io.RelayModule.set_slave_id | ( | self, | |
int | slave_id_new | ||
) |
Set the slave ID.
slave_id_new | New Modbus slave ID |
Reimplemented from cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.