VectorStar™ MS4640A SeriesMicrowave Vector Network Analyzer : Appendix B — Programming with LabWindows/CVI : Example 4 ─ LIST Command – Send to a File
 
Example 4 ─ LIST Command – Send to a File
Here we send the Lightning commands “FMT1;LIST” to get the full list of commands supported by VectorStar. The sting returned is an ASCII arbitrary block so we use the au464x_readArbitraryBlock() function to strip off the arbitrary block header. Results are sent to a file. The code snippet is below.
 
//==============================================================================
//
// Title: Example 4
// Purpose: LIST
//
// Created on: 11/30/2011 by David Judge.
// Copyright: Anritsu. All Rights Reserved.
//
//==============================================================================
 
//==============================================================================
// Include files
#include <ansi_c.h>
#include <visa.h>
#include <userint.h>
#include <formatio.h>
#include "au464x.h"
 
ViSession session;
ViStatus checkErr (ViStatus status);
#define CHECKERR(fCal) \
if (au464x_status = checkErr((fCal)), au464x_status < VI_SUCCESS) \
goto Error; else
 
int main (int argc, char *argv[])
{
ViInt32 retCount;
ViStatus status;
ViUInt32 read_count;
ViStatus au464x_status = VI_SUCCESS;
int fileHandle;
static ViChar readBuffer[100000];
// For these large buffers, we define them as static so
// the memory is on the heap and not the stack.
// Otherwise the stack may overflow
// (unless you increase the stack size using Options | Build Options).
CHECKERR(au464x_init ("VectorStar_Test", VI_TRUE, VI_FALSE, &session));
CHECKERR(au464x_writeInstrData(session,"FMT1;LIST"));
au464x_readArbitraryBlock(session, readBuffer, 1, 100000, VI_TRUE, &retCount);
au464x_close(session);
fileHandle = OpenFile (".\\commands.txt", VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
WriteFile (fileHandle, readBuffer, retCount);
CloseFile (fileHandle);
 
Error:
printf("\n\nHit return to exit:");
getc(stdin);
return 0;
}
 
 
ViStatus checkErr (ViStatus status)
{
ViChar error_message [256];
ViUInt32 read_count;
ViChar error_buffer [1024];
ViInt32 my_error_code = 0;
ViInt32* error_code = &my_error_code;
ViUInt16 stb;
ViUInt16 VNA_ERROR = 4; //This means there is an error
ViUInt16 VNA_ERROR_MSG = 16; //This means there is a message in the error buffer (4+16)
if (status >= 0)
viReadSTB (session, &stb);
//check if stb & VNA_ERROR is set
if (status < VI_SUCCESS | | (((stb & VNA_ERROR) > 0) && ((stb & VNA_ERROR_MSG) > 0)))
{
au464x_writeInstrData (session, ":SYST:ERR?");
viRead (session, (ViPBuf)error_message, 256, &read_count);
SetWaitCursor (0);
sprintf (error_buffer, "Instrument Error: %s\n", error_message);
printf ("%s\n", error_buffer);
au464x_writeInstrData (session, "*CLS");
}
return status;
}
 
 
VectorStar Supported Command List
The List of all commands supported by VectorStar.
 
WGPIB Help
Use WGPIB to get more help on any command. Help will tell you what type of command (Lightning, Native, 8510) you're asking about and provides syntax.