cnode-redn-api

Importing a C project on Node-Red


I have a C project (hex file) and I would like to use in my node-red project. by creating my own node in node-red that's call this project and exchange data with it.

knowing that I don't have the code source .

My questions are:

Is it possible?

If so, How I can do it ? I have read some docs about N-API, but I don't know if it's usefull.


Solution

  • Without knowing a lot more about what your C program does this is hard to answer.

    But you have 2 possible choices here

    1. If your application can receive data from stdin or as command line arguments and output to stdout then you can use the exec or daemon nodes to just run the exe file

    2. You can build a NodeJS node that wraps your C program using the NAPI and then build a Node-RED Node that uses that node and makes method calls against your C library. If you take this path you will need to get the NodeJS module working first.