cheap_modbus_rtu
Lightweight control of cheap Modbus RTU components using Python
|
Base class for cheap Modbus IO modules. More...
Public Member Functions | |
def | __init__ (self, int slave_id, str serial_device_name, int baudrate, **kwargs) |
int | get_slave_id (self) |
Sends a broadcast query to all devices on the bus. 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) |
Restore factory default settings. More... | |
Public Attributes | |
master | |
slave_id | |
Base class for cheap Modbus IO modules.
Configuration constants like register values are device-specific and implemented in the derived classes.
def cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.do_factory_reset | ( | self | ) |
Restore factory default settings.
You must cycle the power supply after this command. Expect a CRC mismatch error when invoking this function, I don't know if this is always the case.
Reimplemented in cheap_modbus_rtu.cheap_modbus_io.RelayModule.
int cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.get_slave_id | ( | self | ) |
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.ModbusModuleABC.set_baudrate | ( | self, | |
int | baudrate = 9600 |
||
) |
Set RS485 serial baud rate.
Most devices require cycling the power supply after running this command before the new baud rate applies.
baudrate | Can be 1200, 2400, 4800, 9600 (default) or 19200 |
Reimplemented in cheap_modbus_rtu.cheap_modbus_io.RelayModule.
def cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.set_slave_id | ( | self, | |
int | slave_id_new | ||
) |
Set the slave ID.
slave_id_new | New Modbus slave ID |
Reimplemented in cheap_modbus_rtu.cheap_modbus_io.RelayModule.