LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get a case structure to look at only the first two bytes

I am getting a string of data but I only need the case structure to look at the first two bytes.  I am indexing these two to make them in order and easy to read. 

0 Kudos
Message 1 of 9
(3,495 Views)

So what exactly is the issue? The case structure selector will operate on whatever data you provide it. If you wire a string you cannot configure it to only look at the first two characters - it will look at the whole string. If you want it to look at the first two characters then you need to take those two as a subset and feed that to the case selector.

 

Is this related to your other question? If so, are you moving that question here?

0 Kudos
Message 2 of 9
(3,483 Views)

Branch the string wire and insert a "String Subset" function before the case structure's condition terminal:

 

17659iC704330E6CF8F99A

 

Shaun

0 Kudos
Message 3 of 9
(3,474 Views)

Thanks guy my problem still exists and I have tried string subset.  Here is example data:

 

00,10,01,08,00,01,00,04,55,00,88,B8,
01,10,01,08,01,01,00,04,55,00,88,B8,
02,10,02,08,02,01,01,04,55,00,88,B8,
03,10,02,08,03,01,01,04,55,00,88,B8,
04,10,03,08,00,01,00,04,55,00,8C,A0,
05,10,03,08,01,01,00,04,55,00,8C,A0,
06,10,04,08,02,01,00,04,55,00,8C,A0,
07,10,04,08,03,01,00,04,55,00,8C,A0,
08,11,01,03,00,7D,AF,00,00,00,00,00,
09,11,01,03,01,8C,B7,00,00,00,00,00,
10,11,01,03,02,FF,FF,00,00,00,00,00,
11,11,01,03,03,87,8C,00,00,00,00,00,

 

This is an example of the CAN data that i am continuously running thru my VI.  Its 24 lines long and i need it to repeat itself every cycle.  I get the data one time on the indicator inside its specific case inside the case structure but i need it, like i said, to rewrite each time, say 00,..........  comes thru.  The cycle lasts a couple of seconds and then continues. Please let me know if i need to explain any more details and here is my new VI.

0 Kudos
Message 4 of 9
(3,460 Views)

One thing I don't understand, this data you are showing can never be CAN data.

You get it from a VISA channel, not a CAN channel.

 

CAN data is 8 byte long, ours is 12 byte.

 

You are still missing an explanation to what part of the data you what to use, and for what. Your VI doesn't tell much.

 

0 Kudos
Message 5 of 9
(3,447 Views)

This is CAN data from a machine we are testing.  The first 2 numbers are simply an indexing number but the rest is no doubt CAN data.  The data comes in thru a VISA but its CAN format in ASCII HEX.  I havent started the filtering process inside the case structure because I cant get the data to keep coming thru.  I need pieces of each line that tells me something specific to that line, for instance temperature, power on/off, heating, cooling, etc.  I know how to filter what i need out, i just need to get the data to come into the case structure at its repected place. 

0 Kudos
Message 6 of 9
(3,440 Views)

You are still missing an explanation on the data you have showed.

 

Witch column are you looking for to select a case in the case structur ?

Try to describe the data you are showing, what does the different bytes mean ?

 

On a side note:

You got 12 byte of data.

You say 2 bytes are index, then there is still 10 byte of data left.

That is more than a CAN message can contain.

 

( As I can read you data:

Index, ? , module?, datalength, databytes[8] )

0 Kudos
Message 7 of 9
(3,424 Views)

Your problem isn't with the case structure. It's with the way you're performing the read operation.

 

First off, you should not have the Configure VI and Close function inside the loop. It's pointless to configure the serial port and close it each time you loop. These two operations should be outside the loop.

 

Second, you are writing *IDN. Is this even valid? Are you trying to write this every time you loop? Why?

 

Third, your Configure Serial Port is configured to use the default values for ending a read when it sees a termination character, which is true by default, and the termination character is linefeed by default. You've configured VISA Read to read 5 bytes. If the VISA Read sees a linefeed character it will stop.

 

Fourth, I don't know why you're reading 5 bytes. Based on your data you should be reading more than that. If the data you showed as an example is accurate, then does each line end with a linefeed? In other words does the device send exactly what's being shown, with a linefeed at the end? If so, you want to set the bytes to read to a high enough value to get the entire line.

0 Kudos
Message 8 of 9
(3,422 Views)

Smercurio-

 

I keep changing the design trying to figure out the best way to design it and your right about the config and close functions, in the loop. 

My raw data, the data that is coming from the read VI, works perfect and shows the data in order and very fast.

And the settings are different then you may see them, they are:

Baud Rate: 57600

data bits: 8

bytes to read: 37

0 Kudos
Message 9 of 9
(3,416 Views)