Send Json data from a C++ program running on a Raspberry PI

Hallo to everybody.
I’m new to the forum and I introduce myself.
I live in Italy and I’m developing a home automation system
I am using a Raspberry Pi to detect some Canbus messages coming from the temperature sensors. (also sending messages to some actuators).
On the same Raspberry Pi I have the emoncms software running.
I have the necessity to read data from the Can Bus module and send them to the Emoncms via Json messages.
The first routine I wrote was in Python, but it was too slow to cope with the Can Bus messages, so I started rewriting it in C++
At this point I read correctly all the data I need from the Can Bus, and I am stuck trying to send Json messages from a C++ program.
In Python it was very easy (“ … and so on.
Can anybody help me?

Solved in a not elegant way (for the moment)
I partially solved the problem using the cURL linux command.
The syntax is:
sudo curl -s --url "\ &apikey=5dafxxxxxxxxxxxxxxxxxxxxxxxb71e0&json={TEMP_%d:%d.%d,UMID_%d:%d,TARG_\%d:%d.%d}"

And I run it from c program using:

Next I’ll try to install the cURL library for the C++ compiler.
Regards Marco

Edit - Munged API key. Added backslashes to command line. BT, Moderator

1 Like