03-10-2016 09:19 PM
why i cannot scan string from read buffer
03-10-2016 11:23 PM
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?
03-10-2016 11:30 PM
yes I using Basic Serial Write and Read example and data sting look like "A,12.0,12.0,12.0 "
03-10-2016 11:41 PM
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
03-11-2016 12:36 AM
03-11-2016 04:32 AM - edited 03-11-2016 04:33 AM
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.
03-11-2016 08:08 AM
I try to use your solution and I receive data from serial port but can't to scan from string
03-11-2016 08:13 AM - edited 03-11-2016 08:15 AM
@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.
03-11-2016 08:19 AM
@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.