-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Hi, I would like to simulate a PLC.
In my case when I read an address, let's say 10 words starting from 0x200, I get some values back (I.E. a string containing the Producer), instead when I read 10 words from 0x201 I will get completely different values.
Which is the proper way to realize this? For what I have understood with app.route I can only define one value at a time. Is there a way to get the lenght of the request at application level?
The workaround that came to my mind was to trigger the modification of regs_word when the first register is requested, like:
@app.route(slave_ids=[1],function_codes=[3], addresses=(0x200,1) ):
def producer(slave_id, function_code, address):
regs_word[0x200] = 0xaabb # first registers
regs_word[0x201] = 0x2231 # prepares other registers
regs_word[0x202] = 0x231a # prepares other registers
# ...
return regs_word[0x200]
@app.route(slave_ids=[1],function_codes=[3], addresses=(0x201,15) ):
def other_regs(slave_id, function_code, address):
return regs_word[address]
Thanks
Metadata
Metadata
Assignees
Labels
No labels