Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5565

Visual Studio C++ 2017 communicatiin with Agilent 34410A via USB

$
0
0

Hello there,

I'm currently developing a windows console application on VS C++ 2017 to communicate with a digital multi-meter but when I try to run the code, I get the errors attached to this post.

 

The code used is following:

#include "stdafx.h"

#include "visa.h"

#include "stdio.h"

#include "stdlib.h"

int _tmain(int argc, _TCHAR* argv[])

{

ViSession         vi;             // Session identifier of devices

ViSession         videfaultRM;     // Resource manager session returned by viOpenDefaultRM(videfaultRM)

ViStatus            errorStatus;    // VISA function status return code

char buf[256] = { 0 };

//ViSession defaultRM, vi;

/* Open session to instrument */

errorStatus = viOpenDefaultRM(&videfaultRM);

errorStatus = viOpen(videfaultRM, " USB0::0x0957::0x0607::MY49002367::0::INSTR", VI_NULL, VI_NULL, &vi);


// If an error occurs, give a message

if (errorStatus < VI_SUCCESS)

{

printf("Unable to Open port; check address! %s\n", buf);

printf("Press Any Key to Continue\n");

getchar();

exit(0);

// Close the session

viClose(vi);

viClose(videfaultRM);

}

/* Send an *IDN? string to the device */

errorStatus = viPrintf(vi, "*IDN?\n");



/* Read results */

errorStatus = viScanf(vi, "%t", &buf);



// If an error occurs, give a message

if (errorStatus < VI_SUCCESS)

{

printf("Connected to instrument but unable to getID string... %s\n", buf);

printf("Press Any Key to Continue\n");

getchar();

// Close the session

viClose(vi);

viClose(videfaultRM);

}

else

{

/* Print results */

printf("Instrument identification string: %s\n", buf);

printf("Press Any Key to Continue\n");

getchar();

}


/* Close session */

viClose(vi);

viClose(videfaultRM);

}

 

Any idea how I can address these errors? Any feedback would be greatly appreciated!

 

Thank you in advance much for the attention


Viewing all articles
Browse latest Browse all 5565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>