NUERA project template offers readily available data server, command server, PLC server, image server in
order to exchange different type of information through TCP Communication.
For the purpose of communicating data with a PC, a data_server has been created in the NUERA project template. As shown in the following steps, by simply enabling the data server and calling the send_data(), you can program NUERA to send data to PC.
Step 1: Enable Data Server (if not already enabled)
The data server can be enabled or disabled by defining DATA_SERVER_ENABLED as true or false respectively in sys_constants.hpp.
Step 2: Configure Data Server (if needed)
In TCP, the server listens for connection requests from clients at a specific port. By default, the Port Number for the Data server is given in sys_constants.hpp. Navigate to file src >> system_configurations >> sys_constants.hpp. Many constants are defined in this header file. Find DATA_SERVER_PORT. By default, it is defined as 7892. This can be changed as per your requirement. Remember that in Step 4, we
will use this port number as the TCP client end to connect to this data server. The Buffer Size and Data Timeout of the data server can also be changed in this file.
Step 3: Add code to Send Data
Navigate to file src >> application >> application.cpp. Goto manage_data_srvr() . Add the message you want to send through TCP to a character array. An example is shown in image below:
Call the send_data(), passing the character array as first parameter and number of characters as second parameter, to send this message through the network to the other device using TCP. The code needs to be added at the location shown below:
Step 4: Observe output (on Hercules)
Connect a Windows System to the same network as NUERA. Open Hercules on the Windows System. Go to the TCP Client pane. Set the Module IP as the IP address of the NUERA camera. Set the Port field according to the data port as set in Step 2. Then, click Connect button. After a “Connected” message, the data we are sending from the Nuera camera will be received by the TCP client and displayed on the screen as shown below:
For any further assistance, please contact our application engineer at [email protected]