LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse a string from a serial port.

Hello.

 

I have some sensors connected to a serial port and each minute I have a burst of 216 bytes coming in and then wait for the next burst.

The data have a specific format and I want to parse them and create a *.csv file.

 

I am having problems understanding some things for the VISA drivers and some things about the continuous parsing.

 

Attached is my simplified vi.

 

So, here are my questions:

 

1. What does the timeout in the wait for event function do? I put it 100 randomly. What happens if the timeout occurs while the data are coming in?

 

2. How does the read function knows when to give me the string? When I place an indicator in the count, I read 216, why does it not wait for 300, which is the number I have in there?

 

3. Since every minute I have 216 bytes, how will the parsing mechanism know that it is time to start/stop parsing?

 

4. How can I divide the string into smaller sub strings? Should I do it by using a lot of search/split strings lineary? How can I store it?

 

5. After the parsing of a string, how can I store it in an array of strings and store the next string in the next index of the array?

 

 

I know it's too much but can you point me to an example or a tutorial?

 

Thanks a lot,

Vasileis.

Download All
0 Kudos
Message 1 of 7
(4,338 Views)

Does your device send a Termination Char?

Omar
0 Kudos
Message 2 of 7
(4,327 Views)

It does send CR LF 3 times in the 216 bytes.

0 Kudos
Message 3 of 7
(4,322 Views)

 

I just posted a solution that could work in your case

 

http://forums.ni.com/t5/LabVIEW/Program-Not-Running-Without-Highlight-Execution-Button/m-p/2759786#M...

HERE

 

Take a look at it

Omar
0 Kudos
Message 4 of 7
(4,318 Views)

@vakost wrote:

Hello.

 

I have some sensors connected to a serial port and each minute I have a burst of 216 bytes coming in and then wait for the next burst.

The data have a specific format and I want to parse them and create a *.csv file.

 

I am having problems understanding some things for the VISA drivers and some things about the continuous parsing.

 

Attached is my simplified vi.

 

So, here are my questions:

 

1. What does the timeout in the wait for event function do? I put it 100 randomly. What happens if the timeout occurs while the data are coming in? The event will throw a time out error and VISA Read will not atempt to read any thing

 

2. How does the read function knows when to give me the string? When I place an indicator in the count, I read 216, why does it not wait for 300, which is the number I have in there? 216 I think is the bytes that it read in not the time it waited. The VISA event will only wait until the VERY first byte shows up at the port That could only be 1 sec. As soon as that ONE byte shows up it passes on to your READ.

 

3. Since every minute I have 216 bytes, how will the parsing mechanism know that it is time to start/stop parsing? Use the Termation Char setting

 

4. How can I divide the string into smaller sub strings? Should I do it by using a lot of search/split strings lineary? How can I store it? Use the Termation Char setting

 

5. After the parsing of a string, how can I store it in an array of strings and store the next string in the next index of the array? Build Array function.

 

 

I know it's too much but can you point me to an example or a tutorial?

 

Thanks a lot,

Vasileis.


 

 

 

Omar
0 Kudos
Message 5 of 7
(4,306 Views)

 

I just noticed you had the Enable Termination Char set to FALSE.

Be sure to Enable Termination Char in the example that I posted above.

 

 

VISA Config.png

Omar
0 Kudos
Message 6 of 7
(4,294 Views)

Hello Omar. I will test your solutions today and let you know.

Thanks for your help so far.

 

Vasilis.

0 Kudos
Message 7 of 7
(4,245 Views)