AnsweredAssumed Answered

Programming Examples 33120A

Question asked by Stuttgart21 on Nov 23, 2010
I want to communicate with a 33120A waveform generator in Visual Studio 2008.

I found these examples:
http://www.home.agilent.com/agilent/edi ... SR.General

I've downloaded the example for C++ (no C# example is available ).

I want to test "SimpleSine". I have included visa.h and visa32.lib from IVI Foundation (C:\Programme\IVI Foundation\VISA\WinNT...).

This is the main program of the example:
void main()
{
     ViSession   viDefaultRM, Instrument;
     ViRsrc      TxtAddress = DEFAULT_LOGICAL_ADDRESS;
     ViUInt32     actual;
     char SCPIcmd[128];

     CHECK(viOpenDefaultRM(&viDefaultRM));
     CHECK(viOpen(viDefaultRM, TxtAddress, VI_NULL, 2500, &Instrument));
     /*
          ' This program is an example program intended for use with
          ' Microsoft Visual C++ 6.0 and requires the VISA installed
      */
     /*
          ' This program sets up a waveform by selecting the waveshape
          ' and adjusting the frequency, amplitude, and offset.
      */
     strcpy(SCPIcmd,"*RST\n");  /* Reset the function generator */
     CHECK(viWrite(Instrument, SCPIcmd, (ViUInt32)strlen(SCPIcmd), &actual));
     ...


When I debug this program the last two lines after the big comment (strcpy...) will NEVER be executed. There are no warnings or errors within Visual Studio.

What's wrong?
I can communicate with the 33120A with the Agilent Connection Expert.


I've done a debugging in detail ... maybe it is useful for solving my problem:
After running through every line of all files I've found a error message in the command line:
"
Error: viOpen(viDefaultRM, TxtAddress, VI_NULL, 2500, &Instrument) returned -1073807195
"

This error first occurs within the string variable "p" (and is then copied to "lfbuf") in these lines of codes in "write.c":
                p = (char *)buf;        /* start at beginning of buffer */
                while ( (unsigned)(p - (char *)buf) < cnt ) {
                    ...

After returning to "void main" the following method is executed (in crt0dat.c) instead of the last two lines in the main code above:
void __cdecl exit (
        int code
        )
{
        doexit(code, 0, 0); * full term, kill process */
}

Outcomes