This is a question related to Node-RED, but I'm asking here because I couldn't find an answer in the Node-RED forum. Maybe someone here can help me out.
I am importing a C++ addon into my Node-RED to send samples from my Analog Discovery 2 device into Node-RED using NAPI. The C++ code basically sends samples from the device to Node-RED using event emitter for each sample sent. The sampling rate is 500 samples/seconds. I can see in the Node-RED window the metric info that the function acutally sends messages upon receiving from the addon each second to Node-RED, but later on after all the samples has been sent (2mins) can see the debug node starting to receive those messages and showing them. I am interested in signal real-time analysis so that's why I would like that the messages get received by the debug node instantaneously upon sedning from the preceding function node and shown in the debug node (or sent to another node for further simultaneous processing) I read about the Asynchronous behaviour of Node-RED and expected it to work the way I want. Is there a way to let this work simultaneously? Thanks so much for any helpers.
const EventEmitter = require('events');
const test = require('C:/directory/build/Release/addon');
const emitter = new EventEmitter();
var a;
emitter.on('something',(evt)=>{ a=(evt);msg.payload=a;node.send(msg);node.done();})
test.Hello(emitter.emit.bind(emitter));
function.js
FDwfAnalogInStatusData(hdwf, 0, &rgdSamples[cSamples], cAvailable); //registering new available samples instantaneously into rgdSamples[]
for (int i = cSamples; i < cSamples + cAvailable; i++) {
napi_create_double(env, rgdSamples[i], &myNumber);
emit.Call({ Napi::String::New(env,"something"), myNumber });
}
addon.node