LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ignoring Short Hex Streams

Hi Headtrip,
 
The streams you posted are confusing me a bit......
 
ie  FEFE 0949 2023 5310 237B 5875 9100 004E 004E 0C
 
The spec in the PDF file is:
 
2 Bytes FE header: FEFE
10 Bytes data, all must be <7F: 09 49 20 23 53 10 23 7B 58 75
Maker (sic) byte, must be greater than 0x80: 91
 
Then there should be 4 bytes of spare data < 0x7F, but I see 5 : 00 00 4E 00 4E
 
Then a checksum, which is bytes 1 - 17 added up, the logical and with 0x7F to mask of MSB - 0C
 
So, the checksum adds up, and that could only happen if the extra byte were 0x00 or 0x80 (discounting any transmission error affecting other bytes)
 
May I ask how you are inspecting the bytwise data?  Perhaps dumping the byte of the Maker(sic it think it should be Marker?) byte into an indicatior set to display a long hex?
 
Or perhaps the spec is out of date?  If I try to pass these messages through the state machine they fail due to the extra byte.......Which is a good thing, since it means either the data is wrong or the state machine is wrong.  I wouldn't want to give you something that was broken...Smiley Happy
 
Howard
0 Kudos
Message 11 of 19
(1,183 Views)
So I talked to someone with a little more information on the hex stream, and there best guess is that there is a 5th spare byte. i.e 9100, the 91 is the Marker byte and 00 is the extra spare byte. So there are five instead of four. I guess I never noticed the extra byte before since I was just taking information from the first 8 bytes. Hope this helps! Thanks again for all the help.
0 Kudos
Message 12 of 19
(1,174 Views)

Hi Headtrip,

 

Could you post the vi with it saved exactly as you run it?  With the vi I have from an earlier post, it looks as if the timeout is set to 10 seconds, and you are requesting to read 4096 bytes.....  If this were the case I would expect that you would only see an update every 10 seconds, when the port timed out....

If the buffer is filling up, it would explain why you would eventually be seeing short streams. 

I'll modify my state machine to account for the extra byte, and make it so you can easily change it back if the original spec is ok......

0 Kudos
Message 13 of 19
(1,166 Views)
The most recent VI is attached.
0 Kudos
Message 14 of 19
(1,160 Views)
Hi Headtrip,
Here is a modified VI to demonstrate how to use a state machine to validate the byte stream.
 
The output is a 2D array: it is essentially an array of received messages.  Normally I would not do it this way, I would be running the state machine in a separate loop and use either a notifier or a queue to inform the second loop in incoming messages, but this works to give you an idea.
 
I also simplified the voltage and watt-second calculation a bit........
 
If you find you are not getting any valid messages, try changing the 18 to a 17 in SPARES state.   This has to do with that extra zero we were discussing......
 
If you have any questions just holler.......
 
Best regards,
Howard
0 Kudos
Message 15 of 19
(1,155 Views)
Tartan,

Thank you so much for your help throughout. This is exactly what I was trying to do. It just goes to show you that NI has the best support around! Thanks again.

- Adam
0 Kudos
Message 16 of 19
(1,137 Views)

Hi Headtrip,

No Problem, just let us know if it ends up working for you, that's half the fun of helping!  Even if it doesn't, let me know, perhaps we can "tweak" it.....Smiley Happy

Howard

0 Kudos
Message 17 of 19
(1,117 Views)
Howard/tartan,

It worked perfectly... flawlessly.  I also enjoyed the cleaning up of the calculations, it really makes understanding the VI easier.  Also, if you don't mind, I would like to give you credit in the final documentation of this little project.  A small token of appreciation, I know, but your work has greatly helped me out. If you don't want to be credited or want to be credited as something specific, please let me know. Otherwise, thanks again for making this community of programmers work!
0 Kudos
Message 18 of 19
(1,111 Views)
Hi headtrip,
 
That would be really cool!  You could just put:
 
Howard Bernier
Efjeld Company, Inc
www (dot) efjeld (dot) com
NI User:Tartan5
 
Thanks, and glad it worked out!  Smiley Happy
0 Kudos
Message 19 of 19
(1,102 Views)