Specifications

RIGOL Chapter 4 Programming Demos
4-18 M300 Programming Guide
memset(RecBuf,0,MAX_REC_SIZE);
//open the VISA instrument
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS)
{
// Error Initializing VISA...exiting
AfxMessageBox("No VISA instrument was opened !");
return false;
}
//open the instrument
status = viOpen(defaultRM, SendAddr, VI_NULL, VI_NULL, &instr);
//read from the instrument
status = viRead(instr, RecBuf, MAX_REC_SIZE-1, &retCount);
//The operation completed successfully and the END indicator was received (for interfaces that
have END indicators).
if (status == VI_SUCCESS)
{
(*pstrResult).Format("%s",RecBuf);
}
//The specified termination character was read but no END indicator was received. This
completion code is returned regardless of whether the number of bytes read is equal to count.
else if (status == VI_SUCCESS_TERM_CHAR)
{
(*pstrResult).Format("%s",RecBuf);
}
//The number of bytes read is equal to count. No END indicator was received and no termination
character was read.
else if (status == VI_SUCCESS_MAX_CNT)
{
//(*pstrResult).Format("%s",RecBuf);
*pstrResult = RecBuf;
*pstrResult = *pstrResult + "\r\n (!!Warning!!The number of bytes transferred is equal to
the requested input count. More data might be available.)";
}
else
{
*pstrResult = "(!!Warning!! An error occurred!!.)";
}
//close the instrument
status = viClose(instr);
status = viClose(defaultRM);
return bReadOK;
}
7 Add the Button control message response code.
1) Connect the instrument.
void CM300_Demo_VCDlg::OnBnClickedbtnconnect()
{
// TODO: Add your control notification handler code here
ViStatus status;
ViSession defaultRM;
ViString expr = "?*";
ViPFindList findList = new unsigned long;
ViPUInt32 retcnt = new unsigned long;