08-28-2006 06:10 AM
08-28-2006 06:35 AM
Hello,
you could use the scanning function to achieve your goal:
Scan (ch, "%c>%f", &number);
If you're not familiar with formatting and scanning funtions, you can use the formatting wizard. You can find it at the location C:\Program Files\National Instruments\CVI80\bin\fmtwz.exe (note that the name of the CVI80 directory can differ, depending on your CVI version).
08-28-2006 06:37 AM
08-28-2006 08:00 AM - edited 08-28-2006 08:00 AM
If the data you are getting from the serial port is an ascii string, the suggestions above will work for you. But I suspect your data is binary. It is easy to determine what kind of data you have by looking at it in the debugger. If it is binary you can use this to convert 16 bit binary values like 0xFBDC to an unsigned short:
unsigned short intValue;
char yourBuffer[??] // the buffer you loaded with data from the serial port
intValue = *(unsigned short*)yourBuffer;
If you want to step through the array use:
intValue[i] = *(unsigned short*)&yourBuffer[i*sizeof(unsigned short)]; in a loop.
If the data is a signed integer, just drop the "unsigned" part.
If you are getting the data from something other than an Intel based system you may also have to adjust the format a little (the high and low bytes could appear to be swapped). If you need help converting between other formats, post again.
Good Luck
Message Edited by mvr on 08-28-2006 08:00 AM
08-28-2006 08:35 PM