LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ncWaitForState() function causes a General Protection fault in labWindows/CVI 8.1

Attached is a slimmed down version of my code.

0 Kudos
Message 11 of 22
(1,088 Views)

Dennisatwork,

 

I'm sorry its taken so long for me to get back to you.  I took a look through your code, and ran into a lot of problems.  First off, the common_head.h file was not included so I had a bunch of broken items when I went to compile.

 

The biggest things however, were:

 

1) These declarations of functions are inside another function.  This may have been part of your issue:

 

int CAN_init(void);

int write_CAN_cmd(int);

int read_CAN_cmd(int);

 

void set_Tx_data(const char* Tx_msg);

void Clear_data(void);    

 

2) It seems like you try to pass two variables to the set_TX_data() when its definition only specifies one.

 

The second point is probably not related to your GPF, but is a problem.  However, the GPF may be caused by the first one.

 

Check these things out and let us know how it goes.

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 12 of 22
(1,073 Views)

1. The NI CAN example: "Transmit Receive same Port.prj"  has all of these functions separate.

 

2. Typo - I forgot to remove "panelHandle". If that was there then I would get a compile error.

 

3. I will try to insert the following into the "Transmit Receive same Port.prj" -  Timer10CallBack( ) function to see if the GPF happens:

     Maybe you could try the same.

 

NCTYPE_STATE_P CurrentState = 0 ;

Status = ncWaitForState( TXRXHandle, NC_ST_WRITE_SUCCESS ,NC_DURATION_NONE, CurrentState);

0 Kudos
Message 13 of 22
(1,068 Views)

Hi Dennisatwork,

 

Could you re-post your code, with the header file and any changes that you've made so far, so that we can try to reproduce this here?

Cheers!

TJ G
0 Kudos
Message 14 of 22
(1,057 Views)

I get a GPF using the example project "Transmit Receive same Port.prj" with

 

NCTYPE_STATE_P CurrentState = 0 ;

 

Status = ncWaitForState( TXRXHandle, NC_ST_WRITE_SUCCESS ,NC_DURATION_NONE, CurrentState);

 

inserted into Timer10CallBack( ) function.

 

0 Kudos
Message 15 of 22
(1,054 Views)

Hi Dennisatwork,

 

Thanks for the additional info.  It's hard to say why that's not working properly with the example either.  As TJ mentioned above, if you could attach your missing header file and updated code, we'll try it on our end to see if we're able to reproduce that general protection fault that you're seeing.

 

 

Regards,
Austin S.

National Instruments
Academic Field Engineer
0 Kudos
Message 16 of 22
(1,040 Views)

The GPF can be reproduced with the example project.

 

0 Kudos
Message 17 of 22
(1,037 Views)

Hello Dennisatwork,

 

I am running CVI 2010, but I could not reproduce the GPF that you are referring to from the example you referrenced. I don't actually have a CAN device to receive from, but I am using a USB-8473. Here is where I insterted the code as you specified:

 

...

int CVICALLBACK Timer10CallBack (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{

    NCTYPE_CAN_STRUCT        ReceiveBuf[150];
    NCTYPE_UINT32            ActualDataSize=0;
    u16                        i=0;
    u16                        j=0;
    char                    output[15];
    char                    CharBuff[26];
   
    NCTYPE_STATE_P CurrentState = 0 ;
    Status = ncWaitForState( TXRXHandle, NC_ST_WRITE_SUCCESS ,NC_DURATION_NONE, CurrentState);

    switch (event)
        {
        case EVENT_TIMER_TICK:

...

 

I can run and send without any error. Exactly when does the GPF occur on your end?

Cheers!

TJ G
0 Kudos
Message 18 of 22
(1,023 Views)

The GPF happens when the program  executes the ncWaitForState() function.

0 Kudos
Message 19 of 22
(1,021 Views)

Dennisatwork,

 

Ok, so it happens every single time ncWaitForState() executes. I am not seeing this behavior.

 

Here is my setup:

  • CVI 2010
  • NI-USB 8473
  • NI-CAN 2.7.2

What kind of hardware are you using, and what driver version do you have?

Cheers!

TJ G
0 Kudos
Message 20 of 22
(1,017 Views)