Instructions

Table Of Contents
RIGOL Chapter 3 Programming Examples
3-24 RSA5000 Programming Guide
string str;
//Address conversion, convert the string type to char*
SendAddr = const_cast<char*>(strAddr.c_str());
//Address conversion, convert the string type to char*
SendBuf = const_cast<char*>(strContent.c_str());
//Turn on the specified device
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS)
{
cout<<"No VISA equipment!"<<endl;
return false;
}
status = viOpen(defaultRM, SendAddr, VI_NULL, VI_NULL, &instr);
//Write command to the device
status = viWrite(instr, (unsigned char *)SendBuf, strlen(SendBuf), &retCount);
//Turn off the device
status = viClose(instr);
status = viClose(defaultRM);
return bWriteOK;
}
bool DemoForRSA::InstrRead(string strAddr, string & pstrResult) //Read operation
{
ViSession defaultRM,instr;
ViStatus status;
ViUInt32 retCount;
char* SendAddr = NULL;
char * result = NULL;
bool bReadOK = false;
unsigned char RecBuf[MAX_REC_SIZE];
string str;
memset(RecBuf,0,MAX_REC_SIZE);
result=char*)malloc(MAX_REC_SIZE*sizeof(char));
memset(result,0,MAX_REC_SIZE);
//Address conversion, convert the string type to char*
SendAddr=const_cast<char*>(strAddr.c_str());
//Turn on the VISA device
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS)
{
// Error Initializing VISA...exiting
cout<<"No VISA equipment!"<<endl;
return false;
}
//Turn on the specified device
status = viOpen(defaultRM, SendAddr, VI_NULL, VI_NULL, &instr);
//Read from the device