Smart Camera Documentation

Creating New TCP Server

22 views October 15, 2018 soliton-support 1

In order to create new TCP server/client connection follow simple steps given below:

Step 1: Create an instance of TCPCommunication class
Navigate to file src >> application >> application.cpp. In the section of the code where class objects are instantiated, create an instance of class TCPCommunication, defining the server port number , buffer size (based on the size of data to be sent/received) and TCP timeout (typically 200 in ms) as shown in image below.

NUERA New TCP Server Class

Step 2 : Start Server in initialize_settings()
Before writing the application code, the server must first be initialized. This is done in the initialize_settings(). This code first checks whether whether any client wants to listen to the server and then, after a small delay, it enters the server application. The code must be added
as shown below:

NUERA New TCP Server Code 1

Step 3: Edit the application() in application.cpp to create a TCP server
Expand the application() in application.cpp . Here, add the code shown in the yellow box in the
image below:

NUERA New TCP Server Code 2

In this code,
1. check_comm_status() – checks for connection requests from clients and establishes the connection.
2. is_client_connected() – is used to find if the client is connected. In this example, the threshold value of the binary threshold function is sent via TCP to a TCP client (a TCP client software for PC is introduced in Step 5).

Step 4: Close TCP Connection. After communicating with the client, the TCP server must be closed. This is done in the manage_application() as shown below:

NUERA New TCP Server Code 3

Step 5:Update NUERA and observe output
Now, once you save this file and build the project, the build will complete successfully. Then you can Upload this project to NUERA and you can observe the corresponding output on Hercules (Refer Section 3.4 of Getting Started with NUERA to know how to upload your
application into NUERA).

Step 6: Set Up TCP Client
We recommend Hercules SETUP utility on Windows platform for this facility. You can download the software here. After installing Hercules , connect the PC to the same network as NUERA.

Step 7: Configure TCP Client and Observe the Result
Now, in Hercules, open the TCP Client tab, enter the IP Address of NUERA in Module IP field and the server port number (used in Step 1) in Port field as shown in image below. In the example code, notice server port number is 7895. Then click Connect button. The threshold values will be received by this client and printed as seen in the image below:

NUERA New TCP Server Termainal Output

For any further assistance, please contact our application engineer at

Was this helpful?