Network Operation and Remote Control
R&S
®
SMW200A
839User Manual 1175.6632.02 ─ 30
#include <visa.h>
#include <cvirte.h>
#define MAX_BUFFER_SIZE 200
static ViStatus status;
static ViSession defaultRM, handle;
static void write_command(char *command)
{
char writeBuffer[MAX_BUFFER_SIZE];
char readBuffer[MAX_BUFFER_SIZE];
int length;
int readCount;
strcpy(writeBuffer, command);
//append "*OPC?" to sync
strcat(writeBuffer, ";*OPC?");
length = strlen (writeBuffer);
writeBuffer[length]='\n';
length = length+1;
viWrite (handle, writeBuffer, length, VI_NULL);
//read result
viRead(handle, readBuffer, 100, &readCount);
}
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
//create a VISA session and return a handle to it
viOpenDefaultRM (&defaultRM);
//create a VISA session to the serial port and return a handle to it
viOpen (defaultRM, (ViRsrc)"TCPIP::localhost::INSTR", VI_NULL, VI_NULL,
&handle);
#INIT_CODE_END
#COMMAND_CODE_START
write_command("%COMMAND");
#COMMAND_CODE_END
#NO_COMMAND_CODE_START
//no SCPI command available for parameter %PARAMETER !
#NO_COMMAND_CODE_END
#EXIT_CODE_START
viClose (handle);
viClose (defaultRM);
return 0;
}
#EXIT_CODE_END
References