device
— Modbus Device Representation¶
API Documentation¶
Modbus Device Controller¶
These are the device management handlers. They should be maintained in the server context and the various methods should be inserted in the correct locations.
-
class
pymodbus.device.
ModbusAccessControl
[source]¶ This is a simple implementation of a Network Management System table. Its purpose is to control access to the server (if it is used). We assume that if an entry is in the table, it is allowed accesses to resources. However, if the host does not appear in the table (all unknown hosts) its connection will simply be closed.
Since it is a singleton, only one version can possible exist and all instances pull from here.
-
__iter__
()[source]¶ Iterater over the network access table
Returns: An iterator of the network access table
-
__contains__
(host)[source]¶ Check if a host is allowed to access resources
Parameters: host – The host to check
-
-
class
pymodbus.device.
ModbusPlusStatistics
[source]¶ This is used to maintain the current modbus plus statistics count. As of right now this is simply a stub to complete the modbus implementation. For more information, see the modbus implementation guide page 87.
-
class
pymodbus.device.
ModbusDeviceIdentification
(info=None)[source]¶ This is used to supply the device identification for the readDeviceIdentification function
For more information read section 6.21 of the modbus application protocol.
-
__init__
(info=None)[source]¶ Initialize the datastore with the elements you need. (note acceptable range is [0x00-0x06,0x80-0xFF] inclusive)
Parameters: information – A dictionary of {int:string} of values
-
__iter__
()[source]¶ Iterater over the device information
Returns: An iterator of the device information
-
update
(value)[source]¶ Update the values of this identity using another identify as the value
Parameters: value – The value to copy values from
-
__setitem__
(key, value)[source]¶ Wrapper used to access the device information
Parameters: - key – The register to set
- value – The new value for referenced register
-
-
class
pymodbus.device.
DeviceInformationFactory
[source]¶ This is a helper factory that really just hides some of the complexity of processing the device information requests (function code 0x2b 0x0e).
-
classmethod
get
(control, read_code=1, object_id=0)[source]¶ Get the requested device data from the system
Parameters: - control – The control block to pull data from
- read_code – The read code to process
- object_id – The specific object_id to read
Returns: The requested data (id, length, value)
-
classmethod
_DeviceInformationFactory__get
(identity, object_id)¶ Read a single object_id from the device information
Parameters: - identity – The identity block to pull data from
- object_id – The specific object id to read
Returns: The requested data (id, length, value)
-
classmethod
_DeviceInformationFactory__gets
(identity, object_ids)¶ Read multiple object_ids from the device information
Parameters: - identity – The identity block to pull data from
- object_ids – The specific object ids to read
Returns: The requested data (id, length, value)
-
classmethod
-
class
pymodbus.device.
ModbusControlBlock
[source]¶ This is a global singleotn that controls all system information
All activity should be logged here and all diagnostic requests should come from here.
-
__str__
()[source]¶ Build a representation of the control block
Returns: A string representation of the control block
-
addEvent
(event)[source]¶ Adds a new event to the event log
Parameters: event – A new event to add to the log
-
getEvents
()[source]¶ Returns an encoded collection of the event log.
Returns: The encoded events packet
-
_setListenOnly
(value)[source]¶ This toggles the listen only status
Parameters: value – The value to set the listen status to
-
_setMode
(mode)[source]¶ This toggles the current serial mode
Parameters: mode – The data transfer method in (RTU, ASCII)
-
_setDelimiter
(char)[source]¶ This changes the serial delimiter character
Parameters: char – The new serial delimiter character
-
setDiagnostic
(mapping)[source]¶ This sets the value in the diagnostic register
Parameters: mapping – Dictionary of key:value pairs to set
-