From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Fatal runtime error 'General Protection Fault' when opening GPIB communication

The viOpen command below results in a fatal error when i run a relatively simple program

        /*- Open instrument session ---------------------------------------------*/
            if ((Connect_status = viOpenDefaultRM (&rmSession)) < 0)
                return Connect_status;

            if ((Connect_status = viOpen (rmSession, "GPIB0::8::INSTR", VI_NULL, VI_NULL, (ViPSession)i_Session)) < 0) {
                viClose (rmSession);
                return Connect_status;
            }

The error is 
FATAL RUN-TIME ERROR:   "gpibrw.c", line 64, col 35, thread id 0x00000588:   The program has caused a 'General Protection' fault at 001B:631431C4.

It was initially causing my own program to crash, but i've since copied those lines into the NI GPIB demo code.  Same result.

Using LabWindows 8.0.1 (356) on Windows XP SP1
Visa drivers are installed - the manufacturer's program has no trouble communicating with the device.  However with the code above (which works fine on older installations i'm assured), i can't open the visa session.

Any help welcome.

Regards,
Andrew
0 Kudos
Message 1 of 6
(4,053 Views)

The last parameter of viOpen() is expecting an address into which the function can write - are you sure that your variable i_Session represents a valid address at this point in your program? How it is declared and initialised?

JR

0 Kudos
Message 2 of 6
(4,037 Views)
It is declared as a global variable at the beginning of the program.
int i_Session = 0;
Then cast to a ViPSession during the call.
0 Kudos
Message 3 of 6
(4,031 Views)
There is your problem, then. Simply casting to a pointer type is not enough - you need to tell the compiler to take the variable's address in the call to viOpen().  Without the address operator, the value 0 is passed to the function, resulting in the GPF when it tries to write to memory location 0. Unfortunately, the use of the cast probably prevented the compiler from giving you a warning about this. Try:

    viOpen (rmSession, "GPIB0::8::INSTR", VI_NULL, VI_NULL, (ViPSession) & i_Session);
JR
Message 4 of 6
(4,027 Views)
That makes sense, my mistake, thanks for the advice.  The situation's now better, but i still get an error, though this time it's not fatal.

NON-FATAL RUN-TIME ERROR:   "Flux Manager.c", line 4495, col 43, thread id 0x00000B2C:   Function viOpen: (return value == -1073807343 [0xbfff0011]). Insufficient location information or the requested device or resource is not present in the system.

The program now knows where to write, but doesn't seem to like opening the visa session.

0 Kudos
Message 5 of 6
(4,025 Views)
aha!
this time it was just that my GPIB address was wrong.  I've got 2 devices on the bus, and i can now communicate with 1 of them, so at least the visa session is working!

0 Kudos
Message 6 of 6
(4,022 Views)