In TCP mode you can have multiple slave scripts but they must use different ports (e.g. 502, 503 etc). In RTU mode only one slave is supported at the moment.
(08.08.2022, 13:08)admin Wrote: In TCP mode you can have multiple slave scripts but they must use different ports (e.g. 502, 503 etc). In RTU mode only one slave is supported at the moment.
Hi Admin,
Ok, I understood the principle. But how to decompose the cyclic script which sets the port (eg. 502) and the slave id (eg. 2) into several slave scripts with different ports?
How will the mbetregisters() function find its way?
If you only need read-only values on the modbus side you can simply periodically update the register values in the resident script itself. Modify register mapping in updateregisters() as needed. Each script must use a unique port (502, 503 etc).
09.08.2022, 09:58 (This post was last modified: 09.08.2022, 10:11 by SigmaTec.)
(09.08.2022, 06:27)admin Wrote: If you only need read-only values on the modbus side you can simply periodically update the register values in the resident script itself. Modify register mapping in updateregisters() as needed. Each script must use a unique port (502, 503 etc).
Sorry Admin, using your script (without modify it, except '32/1/1') no communication with Modbus master is possible.
Note : I suspended cyclic "Modbus handler" script and preserved "mbproxy" script in common functions.
Perhaps interesting for you 'timeout ?' > founded by monotoring in log :
First, check the Error log for any errors.
You can use this test script for reading from local TCP slave with port 502 (check Logs tab for the read result or any errors):
(09.08.2022, 10:11)admin Wrote: First, check the Error log for any errors.
You can use this test script for reading from local TCP slave with port 502 (check Logs tab for the read result or any errors):
But to be sure we are on the same subject :
my deal is to use LM as Modbus slave in order to write in it some registers which will be read by a master.
"Connection refused" means that either your slave script is not running or it's not using port 502. The test script is a master that checks if a local slave is running or not.
(09.08.2022, 11:30)admin Wrote: "Connection refused" means that either your slave script is not running or it's not using port 502. The test script is a master that checks if a local slave is running or not.
I use your previous script, that I run. Then I run your test script.
Did I make a mistake ?
(09.08.2022, 12:46)admin Wrote: What do you mean by "no cyclic script"? Each TCP slave runs in a separate resident script with 0 sleep time.
Yes, Admin, that's what I understood from analyzing the scripts.
I discover your answer after everything works in resident script !
Sorry for the response time: I had no Internet for 3 hours (fiber optic installation in progress)
Question : Is there a limit in number of resident scripts with sleep time 0?
Thank you once again for your precious help and your patience...
There's no exact limit on how many scripts can run no matter what the sleep time is set to. All scripts consume some amount of RAM but it's quite hard to hit this limit in normal use cases.
Modbus script is in sleeping state most of time anyway when it's waiting for a client to connect. 0 sleep time should avoided for busy loops which consume all CPU resources.