Hello,
Using the example project ModbusFB I'm able to run the project as a modbus slave and connect and read just fine if I use port 502. However, if I use an alternate port, it still uses port 502 and I'm unsure why.
If I exclude the uiPort option it uses 502. If I add the uiPort option as below, it shows it is set as 28502, but I cannot connect to that port and can still connect to port 502. Any idea of what's going on?
Found something more that indicates this might be a bug actually. when expanding the object in the watch window I see that the public uiPort variable is set, but the private internal uiPort is still 502. Is this a bug maybe?
Hello kbus,
sorry for the inconvinience, this slipped through all the testing :(
There is an easy workaround:
// Configure the MODBUS TCP server
server(fcsSupported:=fcsSupported, dataModel:=exampleDataModel.tableDefs, xEnable:=FALSE, wsInterfaceName:="Ethernet 2", uiPort:=28502); // uiPort:=28502 doesnt work
// Start the server, set internal variable uiPort prior xEnable := TRUE
{implicit on}
server.uiPort:=28502;
{implicit off}
server(xEnable:=TRUE);
and all works as expected.
The whole problem was: assignement of uiPort at rising edge of xEnable did not happen...
This bug is listed at MODBUS-108 at our end, fixed already and to be released with MODBUS 4.2.0.0 latest.
regards Ullrich
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Using the example project ModbusFB I'm able to run the project as a modbus slave and connect and read just fine if I use port 502. However, if I use an alternate port, it still uses port 502 and I'm unsure why.
If I exclude the uiPort option it uses 502. If I add the uiPort option as below, it shows it is set as 28502, but I cannot connect to that port and can still connect to port 502. Any idea of what's going on?
serverTCP(fcsSupported:=fcsSupported, dataModel:=tableDefs, wsInterfaceName:="", uiPort := 28502);
Found something more that indicates this might be a bug actually. when expanding the object in the watch window I see that the public uiPort variable is set, but the private internal uiPort is still 502. Is this a bug maybe?
Hello kbus,
sorry for the inconvinience, this slipped through all the testing :(
There is an easy workaround:
// Configure the MODBUS TCP server
server(fcsSupported:=fcsSupported, dataModel:=exampleDataModel.tableDefs, xEnable:=FALSE, wsInterfaceName:="Ethernet 2", uiPort:=28502); // uiPort:=28502 doesnt work
// Start the server, set internal variable uiPort prior xEnable := TRUE
{implicit on}
server.uiPort:=28502;
{implicit off}
server(xEnable:=TRUE);
and all works as expected.
The whole problem was: assignement of uiPort at rising edge of xEnable did not happen...
This bug is listed at MODBUS-108 at our end, fixed already and to be released with MODBUS 4.2.0.0 latest.
regards Ullrich
Thank you very much Ullrich. I appreciate the quick turn around. You guys are awesome.
Ken
Quick correction to the workaround code above if anyone needs it.
The line between the implicit on and off should set the internal private variable.
sure ;-)