LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial scan until \r\n

Solved!
Go to solution

A couple of things I see:

 

  1. Get rid of the first case structure. Your already setting the termination character on the Config Serial Port VI, then setting it again in the case structure. Don't do it twice.
  2. I don't see a VISA Write. Is it continiously sending data?
  3. Remove the VISA Open. Don't need it cause you have the Config Serial VI before the While Loop which opens the connection.
  4. Set the Open/Create/Replace File to the outside of the While Loop. Your continiously opening the file which is unccessary.
  5. Where's your Close File? Your keeping the file open after your main VI stops.

Make these changes and then get back with us.

0 Kudos
Message 21 of 34
(1,408 Views)

I have no need to write any data to the module at least as of right now. It is just continuosly reading data from the GPS unit. I made all the suggested changes and I am now back to square one. The only data written to the text file is the LAST data which was present in the text box on the front panel. I need it to continuosly update. Also, the last string which was printed to the text file was only a partial string. 

0 Kudos
Message 22 of 34
(1,404 Views)

This the the sub VI I use to read a serial port ONE line at a time. The specified termination character ("return", "/r", 0xA) is used to terminate the read at the end of one line.

 

If it does not get a termination character, it will return a time out error. Feed that into a case structure and don't write to the file if there was an error 

Omar
0 Kudos
Message 23 of 34
(1,396 Views)

A few things I immediately noticed.

 

  1. You don't need to set the file position.  What you are doing is causing your old data to be written over.  Just remove it.
  2. You need to wire your file reference through all of the cases.
  3. I don't think you should be using the VISA Clear.  That could be causing you to lose data.
  4. Since you are using the termination character for the VISA Read, why do you need to do a search for it?  Check for a timeout error on the VISA Read instead.  If there was a timeout, don't write.  Actually, just let the error cluster do it all for you.  You should wire the error cluster to the file IO anyways.

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 24 of 34
(1,393 Views)
0 Kudos
Message 25 of 34
(1,391 Views)

@Eric1977 wrote:

Try this...


I'm sorry, but I have to point out your Rube.  You get the file position and then immediately set it to the same value.  Why even set the file position?  You don't need to because the position is incremented with every write.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 26 of 34
(1,385 Views)
Solution
Accepted by topic author tayexdrums

Try this with the Read One Line

Omar
0 Kudos
Message 27 of 34
(1,384 Views)

@Eric1977

I believe that did it! There was just one extra $ printed on the very last line, but I think I should be able to handle that. The attached text file is what I have been aiming for.

0 Kudos
Message 28 of 34
(1,382 Views)

@Omar_II

This code seems to run much more quickly and I have yet to get any unwanted characters printed on my text file. Thank you so much!

0 Kudos
Message 29 of 34
(1,376 Views)

Your right. I did a test in another VI and set the file position to end first and then e While Loop handle the rest. Thanks for pointing out my Rube.

0 Kudos
Message 30 of 34
(1,373 Views)