Chapter 3 Programming Demos RIGOL
DSA800E Programming Guide 3-9
{
//If the time exceed the limit value, resend the command after a delay of 1s
if (VI_ERROR_TMO == status)
{
Sleep(1000);
status = viWrite(m_SessInstr, (unsigned char *)SendBuf, strlen(SendBuf),
&retCount);
}
else
{
//If another error occurs, reopen the connection after the connection is closed and
resend the command
status = CloseVisaDevice();
Sleep(1000);
status = OpenVisaDevice(m_strInstrAddr);
if (status == 0)
{
status = viWrite(m_SessInstr, (unsigned char *)SendBuf, strlen(SendBuf),
&retCount);
}
}
}
} while (status < 0);
return bWriteOK;
}
bool CDemoForDSADlg::InstrReadEx(CString strAddr, CString *pstrResult) //Read operation with
exception handling
{
ViStatus status;
ViUInt32 retCount;
char * SendAddr = NULL;
unsigned char RecBuf[MAX_REC_SIZE];
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 exceed 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
{