Public Member Functions | |
| def | __init__ |
| def | closeConnection |
| def | getReadingRegisters |
| def | getWritingRegisters |
| def | readRegisters |
| def | setOutput |
| def | setReadingRegisters |
| def | setWritingRegisters |
| def | startListening |
| def | stopListening |
Public Attributes | |
| client | |
| listener_stopped | |
| post | |
| stop_listener | |
Private Member Functions | |
| def | __reset |
| def | __updateModbusInput |
| def | __updateModbusOutput |
| def | __writeRegisters |
Private Attributes | |
| __input | |
| __last_output_time | |
| __mutex | |
| __num_reading_registers | |
| __num_writing_registers | |
| __output | |
| __pub | |
| __rate | |
| __reading_delay | |
| __reading_register_start | |
| __reset_registers | |
| __sub | |
| __writing_registers_start | |
Wrapper that integrates python modbus into standardized ros msgs.
The wrapper is able to read from and write to a standard modbus tcp/ip server.
Definition at line 57 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.__init__ | ( | self, | |
| host, | |||
port = 502, |
|||
rate = 50, |
|||
reset_registers = True, |
|||
sub_topic = "modbus_wrapper/output", |
|||
pub_topic = "modbus_wrapper/input" |
|||
| ) |
Use subscribers and publisher to communicate with the modbus server. Check the scripts for example code.
:param host: Contains the IP adress of the modbus server
:type host: string
:param port: The port number, where the modbus server is runnning
:type port: integer
:param rate: How often the registers on the modbusserver should be read per second
:type rate: float
:param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
:type reset_registers: bool
Definition at line 62 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.__reset | ( | self, | |
| address, | |||
| timeout | |||
| ) | [private] |
Resets a register to 0 after a specific amount of time
:param address: The register address to reset
:type address: int
:param timeout: The delay after the register is reset
:type timeout: float
Definition at line 277 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.__updateModbusInput | ( | self, | |
delay = 0 |
|||
| ) | [private] |
Loop that is listening to the readable modbus registers and publishes it on a topic
:param delay: The delay time until the loop starts
:type delay: float
Definition at line 157 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.__updateModbusOutput | ( | self, | |
| msg | |||
| ) | [private] |
Callback from the subscriber to update the writeable modbus registers
:param msg: value of the new registers
:type msg: std_msgs.Int32MultiArray
Definition at line 197 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.__writeRegisters | ( | self, | |
| address, | |||
| values | |||
| ) | [private] |
Writes modbus registers
:param address: First address of the values to write
:type address: int
:param values: Values to write
:type values: list
Definition at line 212 of file modbus_wrapper_client.py.
Closes the connection to the modbus
Definition at line 288 of file modbus_wrapper_client.py.
:return: Returns the first address of the readable registers and the number of registers
:rtype: int,int
Definition at line 143 of file modbus_wrapper_client.py.
:return: Returns the first address of the writeable registers and the number of registers
:rtype: int,int
Definition at line 150 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.readRegisters | ( | self, | |
address = None, |
|||
num_registers = None |
|||
| ) |
Reads modbus registers
:param address: First address of the registers to read
:type address: int
:param num_registers: Amount of registers to read
:type num_registers: int
Definition at line 230 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.setOutput | ( | self, | |
| address, | |||
| value, | |||
timeout = 0 |
|||
| ) |
Directly write one register
:param address: The exact register address to write
:type address: int
:param value: What is written in the register
:type value: int
:param timeout: If set, the register is set after this time to 0
:type timeout: float
Definition at line 261 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.setReadingRegisters | ( | self, | |
| start, | |||
| num_registers | |||
| ) |
Sets the start address of the registers which should be read and their number
:param start: First register that is readable
:type start: int
:param num_registers: Amount of readable registers
:type num_registers: int
Definition at line 121 of file modbus_wrapper_client.py.
| def modbus.modbus_wrapper_client.ModbusWrapperClient.setWritingRegisters | ( | self, | |
| start, | |||
| num_registers | |||
| ) |
Sets the start address of the registers which are writeable and their number
:param start: First register that is writeable
:type start: int
:param num_registers: Amount of writeable registers
:type num_registers: int
Definition at line 132 of file modbus_wrapper_client.py.
Non blocking call for starting the listener for the readable modbus server registers
Definition at line 106 of file modbus_wrapper_client.py.
Stops the listener loop
Definition at line 113 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 161 of file modbus_wrapper_client.py.
Definition at line 72 of file modbus_wrapper_client.py.
Definition at line 115 of file modbus_wrapper_client.py.