LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenate strings received from VISA

Solved!
Go to solution

Hello folks,

 

I'm still quite new to LabView, so please bear with me.

 

I am interested in making a subVI which will receive bytes over a VISA serial port and write each line to a larger (concatenated) string, so it can later be stored to a file. In simplest terms, I want to record all data over the serial port until the 8 tests are complete. There are going to be 6 instances of this in the parent VI, so it needs to be modular.

 

I am expecting a series of 8 strings from the serial communication source, each line starts with 'Passed' or 'Failed' then the test. e.g.:

 

Passed test1

Failed test2

Passed test3

Passed test4

.

.

.

 

The current method I'm using is to react when there are bytes present in the serial buffer, then identify a match (currently it only identifies a 'Passed' match).

 

Is there a way to get a match for the substring for 'Passed' OR 'Failed'?

How can I put all of these strings into a larger string? Concatenate Strings won't work because I will have the same string input to the VI... 

 

Any assistance/input would be welcomed, thanks.

0 Kudos
Message 1 of 11
(4,508 Views)

You need to add a shift register to your loop and concatenate the output of the read with the value of the shift register.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 11
(4,502 Views)

Thanks for the reply!

 

Would something like the attached work? I didn't know the Concatenate Strings would work like this.

0 Kudos
Message 3 of 11
(4,495 Views)

Is your loop reading all of the tests or is it reading one test at a time? If it is reading all of the tests then you need to put the concatenate inside the loop, not outside. Also, you need to wire the value from the shift register (on the left) to th etop input on the concatenate. You should also initialize the shift register to an empty string.

 

If you are only reading a single result in the loop you don't necessarily need the shift register on the loop and the concatenate can be outside the loop. However that would imply this is a subVI. In that case you wold have to have a shift in the calling VI and the concatenate would go there.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 11
(4,492 Views)

My loop reads one test/line at a time, I don't know if that is a function of the Bytes at Port or if VISA 'knows' and ends the read buffer at a newline character.

 

How does the attached VI look?

0 Kudos
Message 5 of 11
(4,483 Views)

Your shift register and concatenate string serve no purpose in this VI as you have it written. It would be much more helpful if you could post how you are calling/using this VI. Also, are you aware that you will not track any result that fails? You will read the data at the port and if it is not a pass, you will continue reading data until you get a pass. If you want to save all this data the concatenate MUST be inside the loop.Again though, without seeing how you are actually using this VI it is hard to give specific advice about what you should do.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 11
(4,480 Views)

Because of NDAs, I can't give too much info, sorry.

 

This project is hooked up to a box with six Linux systems.

 

Each serial port is hooked up to one Linux-running piece of hardware. This VI will log in to the Linux user account when the serial port says "xxxxxxxx login:", and will give the password at the "Password:" prompt.

 

Within Linux, the VI will change directory and run a shell script with a fixed name.

 

This script will run some diagnostic which will report 8 tests and send the Pass/Fail data over the serial port, which this VI needs to collect, in the format previously stated.

 

I need to copy over this Pass/Fail data and make decisions regarding the results. The problem is that not all the information is sent over the serial port in the same buffer, it is split up by 1 test per buffer fill.

 

The next step is to take each Linux-running piece of hardware's results and concatenate them further then save to a file.

 

I hope this helps.

 

One of my original post's questions was what to do to get both 'Passed' and 'Failed' to trigger the string storage - any ideas on this?

 

 

0 Kudos
Message 7 of 11
(4,475 Views)
Solution
Accepted by CelerityEDS

Here is a basic example of how to use concatenate strings. Since it is still very difficult to know if you are calling your subVI multiple times or if you are calling it once and want it to read all the results I will not comment much further on that. This example would read all of the results and format an output string which you can write to a file later or do whatever you want with it. The basic constructs of what you will need are illustrated here. How to encorporate them into your application will be difficult to say without any code beyond the bit you posted.

 

Concatenate Strings.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 11
(4,470 Views)

Mark,

 

Thanks for the help thus far. I've been spending some time looking through the Match Regular Expression function you used and the rest for the VI you sent a snapshot of.

 

Please correct me if I'm wrong, but your VI looks like it takes a large string with multiple lines and splits them, looks for a match using regular expressions, and formats a matched string before concatenating it to a string with all results with a newline/carriage return between each result.

 

I receive the results one at a time over the VISA serial port. I do NOT receive a large block of characters with all the results in one string.

 

My goal is to have this subVI run once (at the parent VI level), loop through the VISA serial reads until it gets all the passed/failed results, then put all of those strings into one large string, and output that string.

0 Kudos
Message 9 of 11
(4,455 Views)

Yes, I know you are receiving them over your VISA connection. Read the comment I put in the code. I said replace the "Pick Lines" with your VISA Read (assuming you are reading one line at a time). Everything else will work. You do not specify what exactly you want to do with your Pass/Fail data so I can't be more specific than what I posted. I am willing to help (and what I provided illustrates everything you should need) but I can't write your code for you. I would need to get paid to do that.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 11
(4,448 Views)