Replies: 2 comments 1 reply
-
|
See #2967 for a proposed implementation of this feature |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@janiversen do you see any potential problems with adding something like this? I guess this would make it possible to use one instance of |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In older versions of pymodbus, particularly prior to 3.13 where
ModbusServerContextandModbusDeviceContextinternally started usingSimData/SimDevice, it was possible to store server 'state' in theModbusServerContextinstance.After that change, the state of the server is stored internally with the server instance in an instance of
SimCore. This means that if you pass the sameModbusServerContextto a new server as with a previously running server instance, the new server will not retain the values written to the previous server.It could be said that in new versions of pymodbus,
SimCorewithSimRuntimebehave similarly to howModbusServerContextdid withModbusDeviceContext. However,ModbusServerContextandModbusDeviceContextwere intended to be accessible to end users, whileSimCoreandSimRuntimeare pymodbus internals.To replicate this in newer versions of pymodbus, it could be possible to allow Modbus servers to directly accept an instance of
SimCoreas an argument for thecontextparameter.At the moment I have found a workaround in a project I'm working on and it involves manually setting the
contextattribute on a new server after instantiating it, but before starting it.Effectively this means that the lifetime of the
SimCoreinstance is not restricted to that of the server object. It can be observed that insideModbusBaseServerthat theSimCoreinstance is created fromSimDevices or similar. My workaround just does this outside of the__init__ofModbusBaseServer.pymodbus/pymodbus/server/base.py
Lines 48 to 54 in f051adf
Beta Was this translation helpful? Give feedback.
All reactions