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
¶ 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.
-
__contains__
(host)¶ Check if a host is allowed to access resources
Parameters: host – The host to check
-
__iter__
()¶ Iterater over the network access table
Returns: An iterator of the network access table
-
add
(host)¶ Add allowed host(s) from the NMS table
Parameters: host – The host to add
-
check
(host)¶ Check if a host is allowed to access resources
Parameters: host – The host to check
-
remove
(host)¶ Remove allowed host(s) from the NMS table
Parameters: host – The host to remove
-
-
class
pymodbus.device.
ModbusPlusStatistics
¶ 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.
-
__init__
()¶ Initialize the modbus plus statistics with the default information.
-
__iter__
()¶ Iterater over the statistics
Returns: An iterator of the modbus plus statistics
-
encode
()¶ Returns a summary of the modbus plus statistics
Returns: 54 16-bit words representing the status
-
reset
()¶ This clears all of the modbus plus statistics
-
summary
()¶ Returns a summary of the modbus plus statistics
Returns: 54 16-bit words representing the status
-
-
class
pymodbus.device.
ModbusDeviceIdentification
(info=None)¶ This is used to supply the device identification for the readDeviceIdentification function
For more information read section 6.21 of the modbus application protocol.
-
__getitem__
(key)¶ Wrapper used to access the device information
Parameters: key – The register to read
-
__init__
(info=None)¶ 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__
()¶ Iterater over the device information
Returns: An iterator of the device information
-
__setitem__
(key, value)¶ Wrapper used to access the device information
Parameters: - key – The register to set
- value – The new value for referenced register
-
__str__
()¶ Build a representation of the device
Returns: A string representation of the device
-
summary
()¶ Return a summary of the main items
Returns: An dictionary of the main items
-
update
(value)¶ Update the values of this identity using another identify as the value
Parameters: value – The value to copy values from
-
-
class
pymodbus.device.
DeviceInformationFactory
¶ This is a helper factory that really just hides some of the complexity of processing the device information requests (function code 0x2b 0x0e).
-
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
get
(control, read_code=1, object_id=0)¶ 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
-
class
pymodbus.device.
ModbusControlBlock
¶ This is a global singleotn that controls all system information
All activity should be logged here and all diagnostic requests should come from here.
-
__iter__
()¶ Iterater over the device counters
Returns: An iterator of the device counters
-
__str__
()¶ Build a representation of the control block
Returns: A string representation of the control block
-
_setDelimiter
(char)¶ This changes the serial delimiter character
Parameters: char – The new serial delimiter character
-
_setListenOnly
(value)¶ This toggles the listen only status
Parameters: value – The value to set the listen status to
-
_setMode
(mode)¶ This toggles the current serial mode
Parameters: mode – The data transfer method in (RTU, ASCII)
-
addEvent
(event)¶ Adds a new event to the event log
Parameters: event – A new event to add to the log
-
clearEvents
()¶ Clears the current list of events
-
getDiagnostic
(bit)¶ This gets the value in the diagnostic register
Parameters: bit – The bit to get Returns: The current value of the requested bit
-
getDiagnosticRegister
()¶ This gets the entire diagnostic register
Returns: The diagnostic register collection
-
getEvents
()¶ Returns an encoded collection of the event log.
Returns: The encoded events packet
-
reset
()¶ This clears all of the system counters and the diagnostic register
-
setDiagnostic
(mapping)¶ This sets the value in the diagnostic register
Parameters: mapping – Dictionary of key:value pairs to set
-