Error tester TCP_MODBUS CLIENT on simulator

Hello,
I download TCP_MODBUS_13 from PLCNext Store and open the example MB_TCP_13_EXA_TCP_Client.pcwex to test communication between PLCNEXt simulator and M340 simulator. I’m using a server TCP (M340 simulator) that has been tested with Modbus doctor with connexion on 127.0.0.1.


When I try the example on PLCnext, I have C410 Error (TimeOut). Can I use simulator as client Modbus TCP or it is impossible ?

Hi!
a. You have to forward ports from qemu PLCNext simulation to connect ports on your host pc. Path to the conf file for my case is " C:\Program Files\PHOENIX CONTACT\PLCnext Engineer Simulation\images\AXCF1152\2023.0.0\sim-axcf1152-image-base-sim-axcf2152.simboot.conf"изображение.pngb. Actually localhost:502 will be used by M340 simulator, so you have to organize tcp bridge with some additional soft or etc. to bind ports of two simulators.
c. You can try to connect PLCNext MB TCP client to 10.0.2.2:502, so PLCNext simulator will access port of your localhost. And this is most preferable way, as for me.
https://wiki.qemu.org/Documentation/Networkingизображение.pngBR

With program modbus TCP client on AXCF 2152 and TCP modbus server on PC (I change the server modRSsim2 : https://www.support.aceautomation.eu/wp-content/uploads/ModRSsim2.zip) connection usign MB_TCP_Client is ok and reading registers on server via FC3 function is OK : it seems that we can’t use simulator AXFC 1152 to test modbus TCP client using 127.0.0.1 address.

Hello, Thanks a lot, problem resolved. I change the address to get localhost via virtual qemu gateway 10.0.2.2.
image.pngThanks a lot.
I also change sim-axcf1152-image-base-sim-axcf2152.simboot.conf but not sure is important ? I add port 502 for linux kernel
{`` "executable": "qemu-system-arm", "arguments": [`` "-machine virt,highmem=off",`` "-cpu cortex-a15", "-smp 2", "-m 512M", "-device virtio-net-pci,netdev=net0,mac=A8:74:1D:12:34:02", "-netdev user,id=net0,hostfwd=tcp::5555-:22,hostfwd=tcp::5050-:443,hostfwd=tcp::41100-:41100,hostfwd=tcp::4840-:4840``**,hostfwd=tcp::502-:502**``",``...

I have an other problem.
I tried to create an FB to communicate with modbus TCP server. I send you my source. And if I try to test one FB (implement a connexion to server and FC3 or FC4 function and FC16 function. Test is if read array = write array test is valid.
I send you 3 programs to show you the problem :
Project simulation_MB_TCP_RWReg.pcwex try to test FC3 or FC4 and FC16, and is ok (data is writen to server, and read is ok and test is ok)


Project simulation_MB_TCP_RWBit.pcwex try to do the same but with bit transfert → test ok
Problem is when I try to use 2 functions blocks (2 x MB_TCP_ReadWriteReg) as in project simulation_MB_TCP_RWAll.pcwex. On server I have 2 instances (2 clients connexion ->OK) and read and write are OK on server. The problem is getting values from server (It’s seem that copy from FC3 or FC4 but same with FC1 or FC2 when reading is done is not working or problem with output data_to_read).
Can you help me resolv this ? I put 3 projects on zip to help.
modbusTCP.zip

modbusTCP.zip

Hi.
First of all iMT_ID should be uniq inside TCP_Client chain , and in your case both FC3 and FC4 has same iMT_ID.
It seems you miss processing xNDR event for FC3 and FC4 separately, or using single pot is good for you?
Make iMT_ID sequentially increase, with no duplicates, and it will be ok.
BR.