138
&m_nCount, instrDescriptor);
if (status < 0L)
{
PviClose_usb(m_defaultRM_usbtmc);
hUSBTMCLIB = NULL;
m_defaultRM_usbtmc = 0;
}
else
{
PviOpen_usb(m_defaultRM_usbtmc, instrDescriptor, 0, 0, &m_instr_usbtmc);
status = PviSetAttribute_usb(m_instr_usbtmc, VI_ATTR_TMO_VALUE, m_Timeout);
}
}
else
{
PviOpen_usb(m_defaultRM_usbtmc, instrDescriptor, 0, 0, &m_instr_usbtmc);
status = PviSetAttribute_usb(m_instr_usbtmc, VI_ATTR_TMO_VALUE, m_Timeout);
}
}
if (!hUSBTMCLIB)
{
printf("DL-1060 device connect failed.\n");
return;
}
// Write command "*IDN?" and read the DL-1060 identification string
len = 64;
pStrout = new char[len];
ZeroMemory(pStrout, len);
strcpy(pStrout, "*idn?");
status = PviWrite_usb(m_instr_usbtmc, (unsigned char *)pStrout, 6, &nWritten);
Sleep(30);
if (status != VI_SUCCESS)
{
MessageBox(NULL, "Write to device error.", "DL-1060 multimeter device test", MB_OK);
PviClose_usb(m_defaultRM_usbtmc);
hUSBTMCLIB = NULL;
m_defaultRM_usbtmc = 0;
return;
}
else
{
printf(" output : *IDN?\n");
}
Sleep(1000);
// Read data from device
len = 64;
if (hUSBTMCLIB)
{
status = PviRead_usb(m_instr_usbtmc, pStrin, len, &nRead);
if (nRead > 0)
{
for (len=0; len < (long) nRead; len++)
{
buffer[len] = pStrin[len];
}
}
buffer[nRead] = '\0';
printf(" input : %s\n\n",buffer);
}
// Set sample count to 1
strcpy(pStrout, "SAMP:COUN 1");