RIGOL
Chapter 3
Programming Examples
Programming Guide for DSA1000A series
3-6
6.
Encapsulate the read and write operations of VISA.
1)
Encapsulate the write to VISA.
bool CDemoForDSADlg::InstrWrite(CString strAddr, CString strContent) //Write
//operation
{
ViSession defaultRM,instr;
ViStatus status;
ViUInt32 retCount;
char * SendBuf = NULL;
char * SendAddr = NULL;
bool bWriteOK = false;
CString str;
//
Change the address's data style from CString to char*
SendAddr = strAddr.GetBuffer(strAddr.GetLength());
strcpy(SendAddr,strAddr);
strAddr.ReleaseBuffer();
//
Change the command's data style from CString to char*
SendBuf = strContent.GetBuffer(strContent.GetLength());
strcpy(SendBuf,strContent);
strContent.ReleaseBuffer();
//open a VISA resource
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS)
{
AfxMessageBox("No VISA resource was opened!");
return false;
}
status = viOpen(defaultRM, SendAddr, VI_NULL, VI_NULL, &instr);
//Write command to the instrument
status = viWrite(instr, (unsigned char *)SendBuf, strlen(SendBuf),
&retCount);
//Close the system
Summary of Contents for DSA1000A Series
Page 1: ...RIGOL Programming Guide DSA1000A Series Spectrum Analyzer May 2011 RIGOL Technologies Inc...
Page 2: ......
Page 14: ......
Page 137: ...Chapter 3 Programming Examples RIGOL Programming Guide for DSA1000A series 3 3...
Page 154: ...RIGOL Chapter 3 Programming Examples Programming Guide for DSA1000A series 3 20 6 Exit code...
Page 158: ...RIGOL Chapter 3 Programming Examples Programming Guide for DSA1000A series 3 24...