Can this be done in Node-Red?

Newbie here on Node-Red.
I would like to know if these processes can be done in Node-Red.
I have data of 10x16bit to be sent over serial port at 20Mbps by an MCU and received by Node-Red.
This is sent over 100kHz frequency, that means every 10uS, data of 10x16bit are sent.
Basically, I split the 16bit data to 2-8bit data with msb sent first (I have no control over this, the MCU is sending it via DMA).
So total of 20-8bits will received by node red.
I setup the serial node as shown below with fixed input of 20 chars.


I was able to receive the data, but my problem is when I reset the MCU at different time, there is a chance that the whole 20bytes of data are not completely sent and the next packet of 20bytes will be messed up and not alligned anymore.

I can set "split input" into 1 char and parse the data. That parsing portion I still dont know yet how to do in Node-Red.

By the way, my 10-16bit data are:

  1. 0x0000 = start
  2. 0xNNNN = counter, 0 to (2^16 - 1) to trace my data
  3. 0xNNNN = 12bit ADC
  4. 0xNNNN = 12bit ADC
  5. 0xNNNN = 12bit ADC
  6. 0xNNNN = 12bit ADC
  7. 0xNNNN = 12bit ADC (LSB) , 4bit ADC channel (MSB)
  8. 0xNNNN = duty cycle / phase
  9. 0xNNNN = HW fault (combined fault data)
  10. 0xFFFF = stop

What I plan to do by parsing are:

  1. have a counter (not that counter in #2 above) to count up to 20 while receiving the 20 bytes of serial data.
  2. when it is already 20, check first 2 bytes if both are 0x00 AND check last 2bytes if both are also 0xff.
  3. If not, set "sync" to false and wait until next char equal to 0x00, if so, increment counter.
  4. if next char is also 0x00, set "sync" var to true and continue increment counter until 20.
  5. repeat 1-3.

manipuate data:

  1. reconstruct the 8bit data into correct 16bit orientation.
  2. ADC data #3-6 (above), multiply by some scale factor i.e. adc_data x Voltage, show this data via graphs/gauge/text, etc
    3a. ADC data #7 (above), extract 12bit ADC data and 4bit ADC channel.
    3b. depending on which ADC channel it is, display on corresponding graph/gauge
  3. PWM duty cycle/phase data#8 (above), display this data via graphs/gauge
  4. HW fault data#9 (above), extract which HW caused the fault, display this data via switch/button(w color)

Also, if the frequency of 100kHz is very fast for Node Red, just disregard the other data and sample every 10kHz or even 1kHz.

Can 0x0000 or 0xFFFF appear in words 2 to 9?

I see that you are thinking of writing specific logic to detect and handle this misalignment.
I would hope that there is a more easy solution to that.
Is the serial interface not somehow giving an indication when the MCU is resetted that could be exploited ?
Splitting input per 1 character, means that node-red will have to deal with a lot of messages per seconds which might results in bottlenecks.

Maybe following excellent node can do the parsing job for you:

I have a feeling that your data rate is going to be too high for NR to deal with it reliably

Maybe your going to need a pre-processing microcontroller device that reads in the 20 byte packets - does the validation to ignore partial ones and then forward one in 10 or one in 100

yes, possible, especially word#2.
Also possible on 3-7 when the measured voltage is 0V.

Can 3-7 be FFFF? If so then your algorithm may incorrectly identify a buffer. If you have control of the data then I suggest using a different method if encoding the data.
Is there the possibility of having a short gap between buffers? If so then you could use the timeout method of identifying buffers.

may not be, I will try to avoid it. If ADC channel would exceed 16, I will just use 3bits. The other 1-2bits will be inserted on other ADC data ie #3.
Since ADC data is limited to 12bit, it will not be possible to have 0xFFFF.