LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan from string vi stops program

Hi there.

I've got at problem with my driver. I receives a string with 2 characters and 8 numbers. But sometimes there's a character between the numbers which makes LabVIEW Stops. How do I work around this problem? Do I need to add something to the Scan from string.vi ? I've included a jpq picture. Thank you for a great software...

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

Hi,

 

You could look for an error when scanning the second part of the string and extract the bit you want like this

 

 

Hope this helps

 

David

Message Edited by David Crawford on 11-25-2009 09:23 PM
0 Kudos
Message 2 of 9
(3,909 Views)

What do you mean "makes LabVIEW stop"? Stop as in stops the loop? Stop as in you get some error message? Stop as in it crashes in a blazing inferno?

 

You seem to be reading something off of an instrument, but you are passing in a specific number of bytes to read. Are you saying that the "Bytes Read" is larger than the requested number of bytes you said to read?

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

Hi .

 

Well the whole program stops. The program is running in a while-loop, and yes it's collecting a series of numbers- starting with SL and then eight numbers: [01234567] and then it starts reading again and again. The numbers are from two ADC's from a microcontroller. And the microcontroller keeps sending the data.  "Stop as in it crashes in a blazing inferno?" <--- Yeah great.. That really made my day.. 🐵

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

Do you have automatic error handling enabled? This would make an error dialog appear whenever an error occurs in a function that does not have the error output wired. The program stalls until you dismiss the dialog.

 

If you don't care about the error, you could just wire from the error out to the edge of the case structure, for example (once the error_out is wired, automatic error handling is suppressed).

 

Even better, wire it to a case structure where you can take corrective actions to handle the irregularity, e.g. parse it differently. 😉

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

Hi altenbach.

 

 Well have a look at this picture. The two error indicators helped a lot. BUT when there's a character in the second Scan from String, there's nothing on the chart? Do I have to reset or set something up for the VI or the error thing? When will it come back so I can have a look at the chart?

 

 

<Do you have automatic error handling enabled? This would make an error dialog appear whenever an error occurs in a <function that does not have the error output wired. The program stalls until you dismiss the dialog.

 

-Eh what? Ok is that what I've just have done? Added the two error indicators?

 

 

<If you don't care about the error, you could just wire from the error out to the edge of the case structure, for example <(once the error_out is wired, automatic error handling is suppressed).

 

-Are you referring to the picture with the for- and case-loop?

 

 

<Even better, wire it to a case structure where you can take corrective actions to handle the irregularity, e.g. parse it <differently.

 

- Please help me. How do I do that?

 

 

Thanks 🙂

0 Kudos
Message 6 of 9
(3,820 Views)
In my post above I demonstrated the method to handle the error.
Did you try integrating it into your Vi?
Did it work?
What is the extra character your seeing? Is it always an 's'?
What's it's significance?
0 Kudos
Message 7 of 9
(3,811 Views)
I will suggest that the Scan From String Function is a red herring.  I am very dubious that anything it could do would hang the loop, at worst it sees something which is not a number and returns 0.  I'll wager that characters showing up are a sympton of an error reading the data in the SubVI and the next time you try to read, the bytes aren't there and the program hangs.  One area where I always (and I mean always) use error clusters and error handling is with I/O operations.  At least check that the number of bytes read matches the number requested, but I'll bet whatever is buried in your SubVI can pass out an error cluster.
0 Kudos
Message 8 of 9
(3,802 Views)

Slynge wrote:

Well have a look at this picture. The two error indicators helped a lot. BUT when there's a character in the second Scan from String, there's nothing on the chart?


Yes, if scan form string generates an error, the output will be blank. All you need to do is define a format that successfully scans the string if the extra character is present. Wire the error to a case structure. In the no error case, use the output from the original scan operation. In the error case, scan with the other format.

 

Please attach a collection of possible inputs for the two cases (character present or not) and tell us what output you want. You just need to write a parser that handles both.

 

It will also help if you could attach your VI. It's much easier for us than looking at a picture.

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