Virtuino Forum
Unit ID of MODBUS response is ignored? - Printable Version

+- Virtuino Forum (https://virtuino.com/forum)
+-- Forum: Virtuino (https://virtuino.com/forum/forumdisplay.php?fid=1)
+--- Forum: Virtuino IoT (https://virtuino.com/forum/forumdisplay.php?fid=2)
+--- Thread: Unit ID of MODBUS response is ignored? (/showthread.php?tid=1190)



Unit ID of MODBUS response is ignored? - azuo_lee - 01-25-2023

It seems that Virtuino is ignoring the Unit ID in the MBAP header of a MODBUS response?

I have 2 units in a MODBUS connection that share some of the same value addresses. However, when Virtuino is unable to read these values from one of the units (e.g. due to some network or hardware failure), it has some probability to read them from a response returned by the other unit containing the same address (but maybe even with a different function code).

If I disable or remove the faulty unit from the MODBUS connection, keeping the other one reading data properly, and then modify the server-side code to hard-code the Unit ID in the response to a different value, but Virtuino could still read the data!

This makes a MODBUS connection with multiple units very unstable. Hope this problem can be solved, thanks.


RE: Unit ID of MODBUS response is ignored? - iliaslamprou - 01-26-2023

Hi,
this is a very interesting issue. 
I want to check it, but it is not so easy.
Go to the Modbus Connection settings. Is the checkbox "Permanent connection" checked? 
Change the state of this checkbox. Then try again.
Please inform me for the results.
Τhis error should not occur with the option unchecked.
I will try to fix it as soon as it possible.


RE: Unit ID of MODBUS response is ignored? - azuo_lee - 01-26-2023

Quote:Go to the Modbus Connection settings. Is the checkbox "Permanent connection" checked?
Change the state of this checkbox. Then try again.

Yes, "Permanent connection" is checked. If I uncheck it and try again, as of now, this error has not occurred.
P.S: But "Alternative URL or IP" will no longer work with the option unckecked.

Quote:I want to check it, but id is not so easy.

Is it possible to utilize the Transaction ID? Generate a unique transaction ID for each request, and cache the request until it is timed out. Whenever a response is received, look for a cached request with the same transaction ID, if found and their Unit IDs also match, process the response and complete the request, otherwise, discard the response.


RE: Unit ID of MODBUS response is ignored? - iliaslamprou - 01-26-2023

Thank you for your suggestion!
I will try to fix this issue on on the next update.
I will check the "Alternative url" too.


RE: Unit ID of MODBUS response is ignored? - iliaslamprou - 01-29-2023

Εventually I will have to remove the permanent connection option. There is no other way to fix this bug.
I have fixed the bug about the "Alternative IP or URL".
The changes will be available on the version 0.4.2