LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial control data

Hi all,

 

I have a question about a Serial control RS232 protocol.

First of all, I want to emphasise that I read this information packages from a device that I cannot change, so I can unfortunately not introduce proper ID bytes.

 

This device can sent 5 different information packages.

I will not go into detail of the first 2, because they have ID bytes (0x00 and 0x01), so this is no problem.

 

The remaining 3 packages only have a starting byte (0XFF), and contain the following information:

  • Package 3  ->  0XFF -> 5 data bytes
  • Package 4  -> 0XFF -> 5 data bytes (However, I can identify this packet by the first byte which always has the last 5 bits equal to zero) 

So far so good. With this information I'am able to read all data I need. However, there is one last package, which is a sort of control. It starts with 0xFF and sents than 4 data bytes, and i should check whether byte 1 and 3, and byte 2 and 4 are equal.

  •  Package 5  ->  0xFF  ->  4 data bytes

 

This all happens in the following sequence: 3 - 5 - 3 - 5 ….. (until packet 3 is sent 10 times) - 4 - 5. And then the cycle repeats again.

 

My question is: How can I implement the fifth package? I see 2 acceptable options myself, either using the known sequence or using the fact that package 5 is the only package which is a total of 5 bytes. But I have no clue how I can implement this.

 

Hopefully someone can help me.

 

Thanks in advance.

0 Kudos
Message 1 of 3
(2,182 Views)

Hello Bryan_1995,

 

Maybe I don't get your question right but if you have straight sequence then you can implement simple state machine.

__________________________________________
The best way to thank, is to give KUDOS
0 Kudos
Message 2 of 3
(1,907 Views)
  1. You should be looking at the ID Byte of every packet
  2. Then decide what to do with the rest of the data bytes based on the ID byte.
  3. The order the packets arrive is irrelevant if you do this

 

Here's an example: The fifth byte this device sends is the "ID Byte" this is my sub-vi for decoding. 

idbyte.png

 

Notice there is a case for every ID byte and a default case that does nothing for ID's I don't care about or bad ID data. 

 

 

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 3
(1,893 Views)