TcpOpen - Listen to specific TCP socket

Hi.

I am trying to make a Modbus TCP server run only on IF3 port of a PLC and i face the following:

A part of the code is using the “TcpOpen” function block. When the “pIfAddr” is set to “0” then the Modbus server opens on both PLC ports (IF2&IF3) and i can connect with my client.
image

When i try to use a pointer to the respective port (“ADR(‘IF2’)”) or (ADR(‘IF3.ETH’) then the “TcpOpen” fails to listen to the ports. The function block seems to be running but i am unable to connect.

My setup is the following:
PLC: CP0484
Modbus client: QModMaster.
The IF3 port is configured as “Powerlink V2” with “Ethernet communication” activated.

1 Like

Hi Evangelos,

I know that it’s not intuitive from the parameter name, but I believe that you need to point pIfAddr to IP address of the Ethernet interface, not the interface address:

See: B&R Online Help (br-automation.com)

Can you try that and let us know how it works out?

4 Likes

Hello Evangelos,

The AS Help indicates the pIFAddr should be the IP address of the interface you wish to listen on. So you need to provide it a STRING with ‘192.168.251.10’ and not ‘IF3.ETH.’

I assume you have an X20HB8815 on your PLK network to tunnel your ModbusTCP traffic. Otherwise the ModbusTCP communication will interfere with the PLK network.

Best regards,
Austin

4 Likes

As others have already stated, you need to provide a pointer to a STRING variable containing your interface’s IP address.

Example:
image

Setting the pointer to zero as you have done will open it to every interface, not just IF3.

I believe you could also use a function block from AsARCfg to get the IP address of your device and then pass that into the TCP Open if you prefer to pass the device name rather than a hardcoded string.

4 Likes