Open ejrfisher opened 3 months ago
@ejrfisher I'll have to take a deeper look.
Adding/removing handlers at runtime will definitely add a performance overhead, b/c that data structure must now be synchronized whereas before it was read-only after it was initialized.
If you don't hear from me in the next few days please follow up.
Honestly I wouldn't mind stopping the server and starting a new server with an updated device map since I hold on to each modbusUnitID's DeviceMap independently.
But I can't seem to get that logic running either. After the Server Shutdown and Restart Everything on what I would consider the first (as in registered on the first Server Object) ModbusUnitId always ends up erroring out when you try and perform any client side reads. But the Second Server Object can read perfectly fine from the Second modbusUnitID devicemap
I assume this is because im doing something wrong with my deviceMap objects, but any insight you have would be great.
Here is a combination of pseudocode and the actual success/error output I am getting right now, not sure if it is of any help but maybe you can spot an easy issue with my logic
Setup Server and Client for host:port and mobusUnitId#1
Reads/Writes function as expected from client and server
2024-08-06 XX:XX:XX index: 10 value: 5
User requests addition of modbusUnitID#2 to existing server
shutdown server
shutdown client
grab existing Devicemap for modbusUnitId#1, add mobusUnitID#2
startup server
startup new client
2024-08-06 XX:XX:XX error: RESPONSE_TIMEOUT #ModbusUnitID of whichever deviceMapEndpoint was added FIRST.
2024-08-06 XX:XX:XX index: 10 value: 5 #ModbusUnitID of whichever deviceMapEndpoint was added second.
Less of an Issue more of a question regarding the possibility to update a running Server objects deviceMap
From my understanding each Server uses a deviceMap object to map ModbusUnitID(s) to appropriate handlers with .addEndpoint().
Is there any way to have a running modbusServer with lets say an existing deviceMap of modbusUnitId = 1 and its respective handler and then update the deviceMap with another endpoint mapping modbusUnitId = 2 and its respective handlers?
Or is there a way to non-destructively create a new Server Object that replaces the currently running Server?
Currently if I try using two Server objects, I get a bind error (makes a lot of sense) If I try to update the DeviceMap and then shutdown the running Server and create a new Server Object I get
2024-08-05 20:29:38 error: RESPONSE_TIMEOUT
when I try to read/write any value from the first deviceMap (i.e. modbusUnitId = 1) The second deviceMap endpoint where modbusUnitId=2 works just fine.Just wondering if you could share any insight. Happy to provide any and all information.
Thanks!