Instructions

Table Of Contents
RIGOL Chapter 3 Programming Examples
3-6 RSA5000 Programming Guide
status = viOpen(defaultRM, SendAddr, VI_NULL, VI_NULL, &instr);
//Read from the instrument
status = viRead(instr, RecBuf, MAX_REC_SIZE, &retCount);
//Close the system
status = viClose(instr);
status = viClose(defaultRM);
(*pstrResult).Format("%s",RecBuf);
return bReadOK;
}
3) Encapsulate the read operation with exception handling function of VISA.
ViStatus CDemoForRSADlg::OpenVisaDevice(CString strAddr) //Open a VISA device
{
ViStatus status;
char * SendAddr = NULL;
// Change the address's data style from CString to char*
SendAddr = strAddr.GetBuffer(strAddr.GetLength());
strcpy(SendAddr,strAddr);
strAddr.ReleaseBuffer();
//Open a VISA resource
status = viOpenDefaultRM(&m_SessRM);
if (status == 0)
{
//Open the device
status = viOpen(m_SessRM, SendAddr, VI_NULL, VI_NULL, &m_SessInstr);
//If you fail to open the connection, close the resource
if (status != 0)
{
viClose(m_SessRM);
}
}
return status;
}
ViStatus CDemoForRSADlg::CloseVisaDevice() //Close a VISA device
{
ViStatus status;
//Close the device
status = viClose(m_SessInstr);
if (status == 0)
{
//close the resource
status = viClose(m_SessRM);
}
return status;