DSA800 series programming guide - Page 248

For DSA815.

Loading ...
Loading ...
Loading ...
RIGOL Chapter 3 Programming Demos
3-26 DSA800 Programming Guide
SendAddr = const_cast<char*>(strAddr.c_str());
//Address conversion, convert the strig type to char*
SendBuf = const_cast<char*>(strContent.c_str());
//Turn on the actual 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 into the device
status = viWrite(instr, (unsigned char *)SendBuf, strlen(SendBuf), &retCount);
//Turn off the device
status = viClose(instr);
status = viClose(defaultRM);
return bWriteOK;
}
bool DemoForDSA::InstrRead(string strAddr, string & pstrResult) //Instrument reads
{
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 strig 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 actual device
status = viOpen(defaultRM, SendAddr, VI_NULL, VI_NULL, &instr);
//Read the device
status = viRead(instr, RecBuf, MAX_REC_SIZE, &retCount);
//Turn off the device
Loading ...
Loading ...
Loading ...