Network operation and remote control
R&S
®
SMM100A
651
User Manual 1179.1341.02 ─ 05
Templates are created in ASCII format with file extension
*.expcodetempl
.
Example:
Example to the code generator template
NICVI.expcodetmpl
:
#EXTENSION_START
.c
#EXTENSION_END
#INIT_CODE_START
#include <ansi_c.h>
#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 = 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
References