S03: ARP PING Demo (C++)
This example describes an ARP and PING client.
Download
Download the sample: https://github.com/Beckhoff/TF6311_Samples/tree/main/S03-PingClient
- 1. Get the sample from GitHub, unzip the downloaded ZIP file if necessary
- 2. Open the project with TwinCAT XAE
- 3. Select your target system
- 4. Configure the network card (see below) for the target system
- 5. Build the sample on your local machine (e.g. Build->Build Solution)
- 6. Activate the configuration
Description
The interface ARP/Ping: ITcIoArpPingProtocol(Recv) is implemented and a pointer to a ARP/Ping: ITcIoArpPingProtocol(Recv) is used analogous to the Quick Start in this example.
Using "RegisterReceiver" in the Transition SO ensures that the module is registered for receiving Arp and Ping messages. A corresponding unregistration takes place in the Transition OS.
The "CheckReceived" method is called in the "CycleUpdate" method. In this way the TCP/UDP RT module is enabled to process incoming packets and transmit callbacks on the "ArpReply" und "PingReply" methods to the module.
Understanding
The procedure is carried out once when the program starts.
If "m_bSendRequest" is set to TRUE (e.g. through TwinCAT Live Watch), a new request (ARP and Ping) is sent to the IP address defined here:
The output is in the messages:
To output these messages the "Tracelevel" can be configured (via Info).
Preparing the network card
For the TCP/UDP RT module, make sure that the RT Ethernet adapter in the TwinCAT solution is connected with the correct network card (with TwinCAT driver).
Local configuration only Installation of the driver on compatible network cards via the button "Compatible Devices" always takes place locally. On a controller with TwinCAT XAR, the program TcRteInstall.exe can be used. It is included in the installation (usually under C:TwinCAT\3.1\System). |