LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

string formating error (%ld%*t)

Hi,

I'm using a 3rd party driver for an instrument and I get the following error:

"NON-FATAL RUN-TIME ERROR, Error at or near character 6 in the fomat string: Unkown specifier"

The line inside the driver is:

sscanf(temp_str, "%ld%*t", registerValue).
registerValue = 0x028469FC(17468)
temp_str = "+17468"

Anybody can explain what this specifier means?
Why does the error appears? (seems as if CVI does not understand this specifier...)

Thanks
Rafi
0 Kudos
Message 1 of 6
(3,521 Views)
> sscanf(temp_str, "%ld%*t", registerValue).
What is this %* supposed to be ?!?
Do you mean "%ld%%*t" ?
--
Guillaume Dargaud
http://www.gdargaud.net/
"My goal is to be a meteorologist. But since I possess no training in meteorology, I suppose I
should try stock brokerage." - Found in a resume.
0 Kudos
Message 2 of 6
(3,521 Views)
...like I said it appears as :
"%ld%*t" or
"%ld%*t" or
"%lg%*t" or
"%lf%*t"

Anybody?
What do these mean?

Thanks
Rafi
0 Kudos
Message 3 of 6
(3,521 Views)
Hello,
It appears that your problem is that your instrument driver has been written for a specific compiler, which has expanded the ANSI C functionality. There is nothing wrong with the '*' character, it merely tells sscanf to discard that particular piece of information (using "%ld%*d" works fine), the problem is with the 't' character. 't' is not an available option for conversion characters in CVI (or in other ANSI C compilers, see section 106 of the GNU specification at http://www.si.hhs.nl/~bertn/gnu_libc/libc_106.html#SEC106). If I were to guess, the %t conversion is probably an extension of ANSI C to allow these functions to recognize some sort of timestamp. In order to fix it, you'd probably have to figure out exactly what it's doing, dep
ending on the format and whether the time stamp is fixed length (assuming that my guess is right and it is a timestamp), you might be able to throw it out by using %*s or %*[w]t, where [w] is the width of the time stamp.

Regards,
Ryan K.
0 Kudos
Message 4 of 6
(3,522 Views)

Hello Ryank,

 

I know it's been awhile since we discussed this issue...but I happend to face this problem again.

Searching the code of this particular driver I found this..

        /*************************************************************/
        /* In the standard c template, the scan format string is     */
        /*   "%t%*t".  This removes white space from the end of the  */
        /*   returned string, but doesn't work if there are          */
        /*   embedded spaces in the returned string.  I used this    */
        /*   format string and resorted to stripping off spaces and  */
        /*   spaces and trailing non-printing characters below.      */
        /*************************************************************/

since you must be more knowlagable than me int he C language. can you explain how is the best way to modify the code.

The source is ...%*t    it comes if different  ways like

sscanf(temp_str, "%lf%*t", r64Result);

 sscanf(temp_str, "%hd,%hd%*t", i16ResultA, i16ResultB);

 sscanf(temp_str, "%hd,%hd%*t", i16ResultA, i16ResultB);

 

Thanks Very much

Rafi

0 Kudos
Message 5 of 6
(3,452 Views)

Hello Rafi,

If you want to remove trailing whitespace, you can try removing the %*t all together: sscanf(temp_str, "%lf", r64Result);

If instead you want to remove any character that is not a number or a letter, you can try doing something like: sscanf(temp, "%lf%*[^a-zA-Z1-9]", r64result);

Hope that helps.

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 6 of 6
(3,436 Views)