Hi I am using two external devices connected to two COM ports.
The data coming to COM 1 is at 50Hz rate. The data coming to COM2 is at 10Hz rate
I am parsing the data from COM1 and I have:
msg.payload = {"timestamp":1234, "P1":123} //This is at 50Hz
from COM2 I have:
msg.payload = {"P2":456}// This is at 10Hz
I need to include P2 into the COM1 data when there is new value. So I save it value to flow.set("P2",p2)
then into COM1 data I am doing this:
let p2 = flow.get("P2");
let dataFrom1 = {
{"timestamp":1234, "P1":123, "P2":p2}
}
flow.set("P2",'')
msg.payload = dataFrom1
as the data from COM2 is at 10Hz and the data from COM1 is at 50Hz, I must have p2 value on every 10-th COM1 data. Unfortunately this is not consistent. Vary between 6th and 12th. Does anyone have idea why the data is not updated at every 10th data vale from COM1?
Hard to say for sure but I suspect that you are hitting the same problem as in another recent thread. You are relying on exact timing in node-red and that does not work because not only is node-red not a realtime system neither is its underlying OS.
Therefore, you will never get exact timings on any input data. If you need realtime processing, you need to do it on a realtime system not a general purpose system.