LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read/assign "buffer" content in C?

Hi,

I am using LabWindows/CVI 6.0 environment (Win XP) to read measurement from an instrument (DMM).

 

I read the measurement using code:    char buffer 100;

                                                               float DMM_meas;

                                                               ibrd(DevID, buffer, 100);

 

DevID is the hander that was defined prviously. With no error, device reading is done and saved in the "buffer" as character. I can see content of buffer=5.0 read from the instrument.

Now I would like to read the measured data out of the buffer (char) in to DMM_meas (float) variable to be used later.

 

What is the best way to do it?

I am new to C environment and I will appreciate your help.

 

Thanks,

-LVLV

0 Kudos
Message 1 of 3
(4,789 Views)

You can use sprintf ( ) function, which is part of standard C environment and on which you can find a lot of documentation on manuals and online; alternatively you can use Scan ( ) function from the Formatting and I/O Library of CVI: CVI help is plenty of good explanations and examples on it.

Finally, if your buffer contains only your measurements you could use atof ( ) function.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(4,780 Views)

roberto meant "sscanf()" instead of "sprintf()". additionally, you may use strtol() or strtod(), as well as any str...() function, which are also part of the C standard library and that i personally find more flexible.

 

(if your CVI is version 8.5 or newer, the standard C library is now documented in the help file. you can get a lot of informations from there, you only have to press F1 to open it)

0 Kudos
Message 3 of 3
(4,770 Views)