LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scan string from read buffer serial

why i cannot scan string from read buffer 

0 Kudos
Message 1 of 9
(5,033 Views)

I have no idea.  You haven't provided any information that could give us a clue as to what is wrong.

 

First, I see you have an IDN? command being sent.  Is that a remnant of the Basic Serial Write and Read example you are using?  What is the actual command you are sending.  (You should have saved that in the control as a default.)

 

What does the string data look like you are getting back from the VISA read?

0 Kudos
Message 2 of 9
(5,000 Views)

yes I using Basic Serial Write and Read example and data sting look like "A,12.0,12.0,12.0 " 

 

 

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

It's having a hard time trying to separate out the initial string from the following numbers.  (By the way, you should use %f instead of %d since they are floating point numbers and not integers.)

 

I would use Match Pattern to look for the first comma so you can break it up into an intial string,  the comma, and the remaining string of numbers.  Then put that string through the Scan from String function

0 Kudos
Message 4 of 9
(4,975 Views)
Can you show a picture to this solve ?
0 Kudos
Message 5 of 9
(4,952 Views)

The problem is that the %s does not know to stop at the comma.  Instead, use "%[^,]" which will parse out a string up to (but not including) the first comma.


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
Message 6 of 9
(4,927 Views)

I try to use your solution and I receive data from serial port but can't to scan from string

 

Download All
0 Kudos
Message 7 of 9
(4,899 Views)

@OATTelecom wrote:
Can you show a picture to this solve ?

You can see it is has easy to wire up as I was describing.
But I like Crossrulz's implementation better.  It uses a little big of regex in there to make the format string smarter.  I just never think to use a regex first because I find the codes difficult to construct and I spend far more time experimenting with the regex to get it right than if I just code it up myself in LabVIEW primitives.
I'll have to remember this one because it is a simple expression, and really makes the Scan from String work the way you really expect it to.
PS:  It feels a little odd to convert from a string to a number, to just convert back to a string again.  But I left that in there.

 

0 Kudos
Message 8 of 9
(4,889 Views)

@OATTelecom wrote:

I try to use your solution and I receive data from serial port but can't to scan from string

 


Crossrulz's code works fine for me.

 

And your images look like you are getting the same data and that you coded it up like he did.

 

Do you have any other hidden codes coming through on that Serial Read?  Turn on \codes or hex display.  Maybe there is something hidden in there that it messing up the parsing.

0 Kudos
Message 9 of 9
(4,882 Views)