Hello all,
I have been beating my head against this problem for nearly 3 hours now and just can't come up with a competent solution. My VI is receiving a hex stream from an external USB device, picking out some bytes, doing some number manipulation and kicking the number to an NI touch panel connected through a different serial port. Where I am stumped is that my external USB does not always kick out a perfect 19 byte stream, as it should. Sometimes I will only get partial streams, which screw up my stream by jumbling around the header (xFEFE). So, what I am trying to do is figure out a way for the VI to just ignore the stream if it's less than 19 bytes in length. Some of my ideas include either:
(1) Taking the partial stream and filling in the missing bytes with a hex x00.
(2) Ignoring the short stream, and instead, resending the last full 19 byte stream.
(3) Finding a way to parse through the stream everytime for my header (xFEFE) and restarting the stream there.
The problem with #1 is that it briefly messes up the numbers calculated. But, I can deal with it since it's only for a second, just not sure how to concanate a variable number of strings.
The problem with #2 is finding an easy way to do this in Labview for a relatively new user.
The problem with #3 is that the short stream isn't really always long enough to get all my data, as I need bytes 2,3,4,5,6,7.
I've attached my VI to this post and below is an example of a good stream, a bad stream and what happens to the stream after a bad read.
Good stream: FEFE 0945 163D 2279 1A16 2F0D 1234 5678 2343 02
Bad stream: FEFE 0945 163D 2279 1A16
Result of bad stream: 2F0D 1234 5678 2343 02FE FE09 4598 7698 5476 98
xFEFE should always start the stream.
Thank you for any suggestions on ways to do my current ideas or any ideas on your own.