DSA800 series programming guide - Page 228

For DSA815.

Loading ...
Loading ...
Loading ...
RIGOL Chapter 3 Programming Demos
3-6 DSA800 Programming Guide
5. Add the control variables.
Open the Member Variables tab in View ClassWizard and add the following three variables:
Instrument Address: CString m_strInstrAddr
Command: CString m_strCommand
Return Value: CString m_strResult
6. Encapsulate the read and write operations of VISA.
1) Encapsulate the write operation of VISA for easier operation.
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);
Loading ...
Loading ...
Loading ...