11-20-2008 06:48 PM
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
11-20-2008 11:47 PM
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.
11-21-2008 06:09 AM
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)