Efficiently Passing Modbus TCP Data to C++ via JSON Configuration

Hello,

I have a question regarding data exchange between Modbus and C++.

I would like to use data that is received via Modbus TCP in a C++ program.
Right now I am using the Modbus_TCP library and work with dynamic ports for the C++ program.
The way it works now is as follows:
The received data is stored in an extra variable, which is used as a GDS port.
The GDS configuration is handled by a JSON file.

image.png
image.pngimage.png

This works fine, however I am looking for a more streamlined way.
Is there a way to maybe use the array that is coming from Modbus directly in the JSON file?
Or any other way to do it?

With the added complication that it would be best if the Modbus server is not used directly in the C++ program.

I am happy for any suggestions.

All the best.

Hi Malte,
thanks for this very interesting request.
There are different ways of implementation, but sometimes the naive approaches are the best, and here I would suggest one of the following:

  1. You can create a direct ports of type array to forwared 1:1 the Modbus coils/reg. They might be quite big, but than you’ve always the complete access of the transfered messages and not the need to create for every reg/coil a single port.
  2. As you mentioned it might be in deed the best to implement the modbus server as nativ cpp lib. In that case please make sure that the used lib does not have a blocking behaviour (or call it directly in a thread).

Normally we analyse the application demands and the best way within a workshop. If you are interested I can arrange I contact to create a specific offer for you.
Take care,
Frank

Hi Frank,
Thanks for your response. I’m glad I didn’t overlook any obvious solutions.
For now, I’ll stick with my current approach.
Thanks again, and take care!
Best,
Malte