When you say it doesn't look like it's reading the actual data, what kind of data do you get? Have you tried stepping through your code in a debugger to see where the failure is occuring? I read through your code, and overall it looked reasonable. I noticed that when you actually start pulling in the data and scaling it, you're doing a cast from each character to a double. Is the data actually coming back as a single byte per point? Also, you might consider using the %b scan specifier to read the binary data - this specifier recognizes the definite length block data format, and handles parsing the header information and determining how many bytes are in the buffer automatically. You can find more info about how to use it in the NI-VISA online reference. If yo
u can provide a little more info about the kind of curve data you expect to be getting and what you're actually getting, that would help in figuring out what's going wrong. Also, if you could give me an idea of the values you're seeing for the yOffset, yMult, and the actualy byte values, that would help too.
I noticed in this section:
// Read waveform into allocated storage
ptr = (double*) malloc(*elements*sizeof(double));
double e;
for (i = 0; i < *elements; i++) {
status = viScanf(*vi, "%c", &c);
if (status < VI_SUCCESS) goto error;
ptr[i] = (((double) c) - yoffset) * ymult;
}