Hi guys,
I see that many node developers calls Python from Node-Red.
But JavaScript has the possibilities to call C++ functions directly.
Some parts of JavaScript are written in C++.
This has advantages and disadvantages for node developer.
But if you familiar with C++, this make easy to write binary nodes that calls from JavaScript (Node-Red).
All my nodes are witten with this technique for the raspberry pi.
I plan to write a short instructions how you write code in C++ for Node-Red for my friends here.
But I have two problems:
My english is not so good.
I have no idea for examples
Can you help me and make suggestions for hardware or library that we call from C++ ?
I add your suggestions in my instructions.
Thanks you in advance.
Ocean
Hi @iiot2k,
Very interesting. Looking forward to read your instructions!!
Have been experimenting recently to draw lines and (filled) polygons on images from my IP cams. But using Javascript this was horrible slow. So at the end I gave up. But I assume c++ is much faster for such use cases, since you can address pixels in memory directly.
Although that would be a more "advanced" example, it could be useful to demonstrate WHY it would be useful to implement some nodes partly in c++. And of course I might even use your example in real life. Although I don't know any fast algorithms by head to solve this. So perhaps calling a lib like OpenCv is faster. Not sure...
Hi,
I see that other Node-Red user don't give suggestions for examples. Therefore I select for hardware max7219 led driver example in C++ with call from Node-Red. Later we can use the C++ interface of SQLite for using with Node-Red.
To show the principle of interfacing node-red with C++ a non-hardware problem would be better. Something that can be installed and tested on any node-red system. Even just a Hello World example where the text is generated in C++. The important aspect of your work is how to interface between node-red and C++, not how to interface C++ to some hardware.
The first thing that comes into my mind is to make use of the Node-API of Node js. As far as I can recall, you can create node-api node modules (see previous link) and NR is capable of loading node modules: Writing Functions : Node-RED