C/C++ wrapper for Node RED

1,138 views
Skip to first unread message

Panos Oikonomidis

unread,
Jul 1, 2015, 12:42:30 PM7/1/15
to node...@googlegroups.com

Hi guys,


I am implementing a test environment that uses TTEthernet for communication. For this I have created multiple instances of node red on multiple systems with TEE interfaces. I was planning initially to bridge node red through TCP with the C application that utilises the TTE interface, but I was wondering if any of you can suggest a way to wrap the C based TTE API and use it natively inside node red. This will improve the performance and will allow node red to use the TTE interface directly.


I have seen some info regarding C wrapping for node.js but I am a bit lost and I don’t think there will be many similarities with node red. I would really appreciate it if you point me to the right direction or even better if you have done something similar.


Cheers,

Panos

Julian Knight

unread,
Jul 1, 2015, 3:17:16 PM7/1/15
to node...@googlegroups.com
I suspect the first stage will be to produce a Node.JS wrapper. Sorry, not sure how to do that but I'm sure there are plenty of other examples on github.

This might be helpful:

When that is working, you can easily make the Node.JS extension available to Node-Red. Either by creating your own node that "require"s you extension or by requiring it in the settings.js file and passing it as an object to the global variable.

Dave C-J

unread,
Jul 1, 2015, 3:39:27 PM7/1/15
to node...@googlegroups.com
Hi Panos

yes - good links from Julian - and also http://nodejs.org/docs/v0.10.7/api/addons.html
(note there are some breaking changes for node v0.12... which we don't yet support - but will do (hopefully soon) - so... just a heads up.

Of course these would be for extra functions / nodes that you write and would not affect the built in tcp calls inside node.js core libraries itself etc. Not sure if this is a problem - as I've not played with TTE enough to know how "transparent" it is for general packets.

Panos Oikonomidis

unread,
Jul 3, 2015, 8:04:38 AM7/3/15
to node...@googlegroups.com

Thanks guys, these are very interesting links! I will try to do that and if I succeed I will post my findings here.

Dave, can you please clarify what you mean by saying "Of course these would be for extra functions / nodes that you write and would not affect the built in tcp calls inside node.js core libraries itself etc."


Cheers

Panos Oikonomidis

unread,
Sep 18, 2015, 6:44:21 AM9/18/15
to Node-RED

Hey Guys,


I did manage to wrap the C TTE library successfully and I can use the TTE controllers with nodejs. What I used was:

Also I used node-ffi-generate that saved me a lot of time, instead of doing the whole API by hand.

Now the current task is to actually build the node-red nodes. Because the TTE controller needs to be initialised once (load a configuration file in the controller memory), I was thinking to use a config node that initialises an instance of the controller that will be shared with the in-nodes and out-nodes.
  1. Is there an example of a config node that has initialisation code in it?
  2. If I share the same instance of the config node with multiple out-nodes, will all of the out-nodes receive the incoming TTE messages in the same time?
  3. I need to asynchronously check my incoming message function if there are any new messages in the TTE buffer, shall I place this check in the instance of the config node?
Please excuse my ignorance, I am coming from a C background and I am trying to understand how this works.

Cheers

Seb D

unread,
Jun 29, 2017, 5:32:55 PM6/29/17
to Node-RED
https://nodejs.org/api/addons.html

This is a recent node that apparently use Node.js C++ native add-on

I'm currently looking into that
Reply all
Reply to author
Forward
0 new messages