Closed GoogleCodeExporter closed 9 years ago
No you are correct. This was a feature I was going to add but I never got
around to
it. It should defiantly be added which I can do when I get some free time
unless
someone else wants to take up the torch ;D.
Original comment by Bashw...@gmail.com
on 17 Apr 2010 at 8:22
I solved this with a simple way some days ago.
I'm instantiating the factory with a dict of contexts. Keys are slaves ids:
ModbusServerFactory(stores)
Then, I modified ModbusProtocol.execute like this:
def execute(self, request):
'''
Executes the request and returns the result
@param request The decoded request message
'''
slave = request.unit_id
try:
ctx = self.factory.stores[slave]
response = request.execute(ctx)
except Exception, ex:
...
Do you think it's a good idea? It works for me. If you want I can provide a
patch.
Original comment by jjconti@gmail.com
on 14 May 2010 at 2:27
Actually yeah that is actually a good solution. I would like it to be
formalized a
bit more though. Maybe the ModbusServerContext could become a
ModbusClientContext
and the ModbusServcerContext could be a wrapper around a dict of
ModbusClientContext.
Regardless, if you have some code I will definately add it.
Original comment by Bashw...@gmail.com
on 14 May 2010 at 4:38
This issue was closed by revision r57.
Original comment by Bashw...@gmail.com
on 16 May 2010 at 1:50
Excelent. I updated my copy of pymodbus, changed ModbusServerContext for
ModbusSlaveContext and all worked just fine.
I may say that ModbusSlaveContext is a much better nama than
ModbusClientContext. In
modbus ip terminology a client is the one that poll a server. And the server
represents many slaves.
Line 316 of datastore.py has a reminisce of this wrong concept. In
ModbusServerContext.__init__ docstring you should change 'clients' for 'slaves'.
Original comment by jjconti@gmail.com
on 19 May 2010 at 4:42
Original issue reported on code.google.com by
jjconti@gmail.com
on 16 Apr 2010 at 4:24