
Programming Examples
Continuous Measurements (Example #5)
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <
fl
oat.h>
#include <math.h>
#include <assert.h>
#include "visa.h"
// Write a null terminated string (ie, no binary data) to the
// instrument.
unsigned WriteDevice(ViSession Instr, const char *Str, int Line) {
ViStatus Status;
int Length;
ViUInt32 RetLength;
assert(Str != NULL);
Length = strlen(Str);
Status = viWrite(Instr, (unsigned char *)Str, Length, &RetLength);
if (Status != VI_SUCCESS) {
fprintf(stderr, "Write error: %x at line %d\n", (unsigned)Status, Line);
return((unsigned)Status);
}
assert(Length == (int)RetLength);
return((unsigned)Status);
}
// Read data (may be binary) into the buffer.
unsigned ReadDevice(ViSession Instr, char *Buf, int BufLength, ViUInt32
*pActualLength, int Line) {
ViStatus Status;
assert(Buf != NULL);
assert(BufLength > 0);
assert(pActualLength != NULL);
Status = viRead(Instr, (unsigned char *)Buf, BufLength, pActualLength);
if (Status != VI_SUCCESS) {
fprintf(stderr, "Read error: %x at line %d\n", (unsigned)Status, Line);
}
return((unsigned)Status);
}
#de
fi
ne WriteDev(Str) WriteDevice(Instr, Str, __LINE__)
#de
fi
ne ReadDev(Buf, BufLength, pActualLength) ReadDevice(Instr, Buf,
BufLength, pActualLength, __LINE__)
ViSession defaultRM, Instr;
void Quit() {
(void)viClose(Instr);
(void)viClose(defaultRM);
_exit(0);
}
FCA3000, FCA3100, MCA3000 Series Programmer Manual
4-11
Содержание FCA3000 Series
Страница 2: ......
Страница 8: ...Preface iv FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 9: ...Getting Started ...
Страница 10: ......
Страница 14: ...Using the USB Interface 1 4 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 15: ...Syntax and Commands ...
Страница 16: ......
Страница 26: ...Command Syntax 2 10 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 135: ...Status and Events ...
Страница 136: ......
Страница 156: ...Status and Events 3 20 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 157: ...Programming Examples ...
Страница 158: ......
Страница 179: ...Appendices ...
Страница 180: ......
Страница 181: ...Appendix A Character Set FCA3000 FCA3100 MCA3000 Series Programmer Manual A 1 ...
Страница 182: ...Appendix A Character Set A 2 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...
Страница 188: ...Appendix D Reserved Words D 2 FCA3000 FCA3100 MCA3000 Series Programmer Manual ...