ModbusFB - Modbus TCP Slave non standard port

kbus
2022-04-13
2022-04-19
  • kbus

    kbus - 2022-04-13

    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);

     
  • kbus

    kbus - 2022-04-14

    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?

     
  • u-meyer - 2022-04-19

    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

     
  • kbus

    kbus - 2022-04-19

    Thank you very much Ullrich. I appreciate the quick turn around. You guys are awesome.

    Ken

     
  • kbus

    kbus - 2022-04-19

    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.

    {implicit on}
    server._uiPort:=28502;
    {implicit off}
    
     
  • u-meyer - 2022-04-19

    sure ;-)

     

Log in to post a comment.