#include <stdio.h> #include <visa.h>
/*** FUNCTION PROTOTYPE ***/
void err_handler (ViSession vi, ViStatus x);
void main(void)
{
char buf[512] = {0};
#if defined(_BORLANDC_) && !defined(_WIN32_) _InitEasyWin();
#endif
ViStatus err;
ViSession defaultRM;
ViSession dmm;
/* Open resource manager and multimeter sessions. */ viOpenDefaultRM (&defaultRM);
viOpen(defaultRM,
/* Set the timeout value to 10 seconds. */
viSetAttribute (dmm, VI_ATTR_TMO_VALUE, 10000);
/* Reset the module. */
err = viPrintf (dmm, "*RST/n");
if (err<VI_SUCCESS) err_handler (dmm, err);
/* Query the module identification. */ err = viPrintf(dmm, "*IDN?/n");
if (err<VI_SUCCESS) err_handler (dmm, err); err = viScanf(dmm, "%t", buf);
if (err<VI_SUCCESS) err_handler (dmm, err); printf ("Module ID = %s/n/n", buf);
/* Perform a module
err = viPrintf (dmm, "*TST?/n"); if(err<VI_SUCCESS) err_handler (dmm, err);
err = viScanf (dmm, "%t", buf);
if (err<VI_SUCCESS) err_handler (dmm, err); printf
/* Check for system errors. */
err = viPrintf (dmm, "SYST:ERR?/n");
if (err<VI_SUCCESS) err_handler (dmm, err); err = viScanf (dmm, "%t", buf);
if (err<VI_SUCCESS) err_handler (dmm, err); printf ("System error response = %s/n/n", buf);
}/* end of main */
/*** Error handling function ***/
void err_handler (ViSession dmm, ViStatus err)
{
char buf[1024] = {0};
viStatusDesc (dmm, err, buf); printf ("ERROR = %s/n", buf); return;
}
Chapter 1 | HP E1312A and HP E1412A Multimeter Module Setup 23 |