Instructions

Table Of Contents
RIGOL Chapter 3 Programming Examples
3-8 RSA5000 Programming Guide
bool bReadOK = true;
// Change the address's data style from CString to char*
SendAddr = strAddr.GetBuffer(strAddr.GetLength());
strcpy(SendAddr,strAddr);
strAddr.ReleaseBuffer();
memset(RecBuf,0,MAX_REC_SIZE);
do
{
//Read from the instrument
status = viRead(m_SessInstr, RecBuf, MAX_REC_SIZE, &retCount);
if (status < 0)
{
//If the time exceeds the limit value, read from the instrument after a delay of 1s
if (VI_ERROR_TMO == status)
{
Sleep(1000);
status = viRead(m_SessInstr, RecBuf, MAX_REC_SIZE, &retCount);
}
else
{
//If another error occurs, reopen the connection after the connection is closed and
reread from instrument
status = CloseVisaDevice();
Sleep(1000);
status = OpenVisaDevice(m_strInstrAddr);
if (status == 0)
{
status = viRead(m_SessInstr, RecBuf, MAX_REC_SIZE, &retCount);
}
}
}
} while (status < 0);
(*pstrResult).Format("%s",RecBuf);
return bReadOK;
}
7. Add the control message response codes.
1) Connect to the instrument
void CDemoForRSADlg::OnBtConnectInstr() // Connect to the instrument
{
//TODO: Add your control notification handler code here
ViStatus status;
ViSession defaultRM;
ViString expr = "?*";
ViPFindList findList = new unsigned long;
ViPUInt32 retcnt = new unsigned long;
ViChar instrDesc[1000];
CString strSrc = "";
CString strInstr = "";
unsigned long i = 0;
bool bFindRSA = false;