LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String Output

You are STILL not wiring the Spreadsheet String to Array function correctly! You do not have the array type input wired. This has been said numerous times, yet it's clear you have not read this, or you have simply ignored this little bit of important information. 

 

The reason why the Match Regular Expression did not work is that you did not mention that you're trying to build the string along the way.  We have all been working on the assumption that you have the string in full as you had originally shown it. The Read Bytes at Serial Port will NEVER give you the full string. It will only give you whatever is available at the serial port. This means you have to concatenate a string buffer with whatever you've read and test the buffer, not the output of the read. You have a shift register in place, but you are not using it correctly. You also seem to have some sort of counter for the number of lines. This will not work either, because you cannot be guaranteed that you will be reading a full line at a time. Serial communication does not work the same way as reading files. You also do not have it wired on the left side. You also need to initialize the shift registers. If you don't they will "remember" what the value was the next time you run the VI (unless you close it and remove it from memory).

 

A more correct way to do it is this way:

 

Note: The above will stop reading once it sees a match, meaning the remaining characters may continue to come in. You have not indicated what to do with the rest of the string. In fact, you have not indicated how you know that you've gotten the end of the full transmission.

Message 21 of 59
(1,657 Views)
I solved it with a regular expression search with "A[A-Z0-9]+[^<]$" as parameters, see picture.
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 22 of 59
(1,658 Views)

Hi Smercurio,

  Thanks for your detailed reply. I will take in to account your points and try it with my system.

 

Regards,

Senthil

0 Kudos
Message 23 of 59
(1,629 Views)

Hi Yameda,

 Thanks for the reply. I tried the seperator on 'match expression.vi' and it extracts the speciifed string. My source data has several empty and return carriers like { A<, { ! = etc. How can I specifically remove this characters from source data string set? I wish to remove those characters from source data before passing in to 'Match expression.vi' to search for my required string?

 

Regards,

Senthil

0 Kudos
Message 24 of 59
(1,627 Views)

Hi smercurio,

  I am following your explanation and trying out with my experiemntal setup. Before concanenating the current string buffer (read from serial port), I wish to remove the unwanted characters i.e. return carriages '{ A<}', empty strings from the buffer. Because this could make an unnecessary repeatation while using match expression.vi and while using shift register for returning 'before substring'.  How could I filter those characters from the current string? Still I need to use an additonal 'match expression.vi?

 

Thanks & Regards,

Senthil

 

 

 

0 Kudos
Message 25 of 59
(1,597 Views)

You dont need to clean the string, the Match pattern with regular expression is your cleaning! 🙂

 

If you look at my parameters (and the data you posted) the line you're after starts with an 'A' and doesn't end with '<'.

 

My regular expression specifically chooses a text which begins with 'A' has one or more characters in between '[a-z0-9]+' but doesn't end the line with < '[^<]$'

 

From the data you posted it only results in 1 line. 🙂

 

/Y

Message Edited by Yamaeda on 09-08-2009 04:36 PM
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 26 of 59
(1,586 Views)

To be honest, I have no idea what you're doing at this point. The example I gave doesn't care about carriage returns so I'm not sure why you want to strip carriage returns. I also don't understand what you mean by "unnecessary repetiotion". Repetition of what? 

 

A trivial way to strip carriage returns is to simply use the Search and Replace String function.

Message Edited by smercurio_fc on 09-08-2009 09:38 AM
0 Kudos
Message 27 of 59
(1,576 Views)

Yamaeda wrote: My regular expression specifically chooses a text which begins with 'A' has one or more characters in between '[a-z0-9]+' but doesn't end the line with < '[^<]$'

 

From the data you posted it only results in 1 line. 🙂


Actually, the line begins with "{ A", so your expression didn't work. I tested it with the lines posted, and it did not find the string. Unfortunately, I'm not an expert of regex, so I can't say what's wrong without digging through the gibberish of the syntax for regex. 

0 Kudos
Message 28 of 59
(1,568 Views)

Hi Smercurio,

  The problem is as same as you mentioned in your previous post that the string output from serial port read.vi is not uniform. I agree with your point "Read Bytes at Serial Port will NEVER give the full string". Apologise for the confusion arised because of me posting a sample string output (in my previuos post) which is not guranteed one for all time. 

 

Let me provide some samples of strig output at different instants below:

 

Sample 1 

{ A<
{ A<
{!A=
{ A0294546442952374410500044116124500000000099000044235000453000004410000043X

{ A081201045530000C42330004300000000200510453170004412880045317000442000004560000045\

 

Sample 2 

{ A<
{!A=
{ A1294542442952374410500044
120799500000000010000043240000453000004410000043L

{ A181201045530000C42330004300000000200510453180004412880045317000442000004560000045^

 

 

 Sample 3

{ A<
{!A=
{ A2294546442951404410500044   -------------------------------------------------Line 1
146043500000000010000043240000453000004410000043@ ----------------- Line 2
{ A281201045530000C42330004300000000200510453180004412880045317000442000004560000045_ ------------- Line 3

 

The red highlighted string is need to get extracted.  I used 'match expression.vi' with different regular expression matches like '{ [A-Z0-9] {75}' "A[A-Z0-9]+[^<]$".. etc.  But as seen from above e.g the required string pattern is not uniform and broken some time. Hence the 'match string' output of 'match expression.vi' could not guarantee the required string all time.  Moreover there are lot of return carriages ('{ A<' ) and empty strings get included in before string output of 'match expression.vi'.

 

Hence I wish to remove all unnecesary return carriages and empty strings from source output of  'serial port read.vi' and I may have a chance to play with only two (or) three lines of strings (shown as line 1, 2 and 3 in Sample 3).

 

Hope I did not confuse.

 

Thanks

 

Senthil



 

 

0 Kudos
Message 29 of 59
(1,553 Views)

Well, if the line has a chance of being chopped up over multiple lines by having a carriage return inserted in the middle of the string then this obviously makes things more difficult. Are there any more little tidbits like this that you would like to let us know ahead of time?

 

Additional questions:

  1. Do you read the entire response, or do you intend to stop reading the serial port once you've found your "line"? If you stop, does the device just keep sending information? Do you have  means to stop it?
  2. When the line gets chopped up like you've shown is it a carriage return, a linefeed, or a carriage return/linefeed combo that gets inserted?
  3. Does the line you're interested in always end with a non-numeric character? In Sample 1 it ends with "X". In Sample 2 it ends with "L" and in Sample 3 it ends with "@".
0 Kudos
Message 30 of 59
(1,539 Views)