LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

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

One function I do the ncWrite and the other function I do the ncWaitForState() and ncReadMult() functions.

 

The ncWaitForState() causes a General Protection Fault.

 

I just need a delay between the ncWrite() and the ncReadMult() because the UUT doesn't reply fast enough.

 

 

CAN 2.6.3 using a NI PXI-8512/2 .

 

labWindows/CVI 8.1

 

 

======================================= Function 1
if((Status= ncWrite(TXRXHandle, sizeof(Transmit), &Transmit)) < SUCCESS)
{
   state = FAILURE;

}else
    {
        state = SUCCESS;

    }

 ===================================== Function 2

 

 

NCTYPE_STATE_P CurrentState = 0 ;

 

if((Status = ncWaitForState( TXRXHandle, NC_ST_READ_AVAIL ,NC_DURATION_10SEC, CurrentState)) == SUCCESS)
{

    Status = ncReadMult(TXRXHandle, sizeof(ReceiveBuf),(void *)ReceiveBuf, &ActualDataSize);

    ActualDataSize = ActualDataSize/sizeof(NCTYPE_CAN_STRUCT);

}

0 Kudos
Message 1 of 22
(3,633 Views)

Dennisatwork,

 

I'm not sure what your question is, as you have provided a problem, but then stated that putting a delay between the functions would solve it.

 

If you are inquiring as to how to put a delay between those functions, you can find the documentation on the Delay function here: http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/libref/cvidelay/

 

I hope this answers your question!

 

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 2 of 22
(3,618 Views)

I don't want a hard delay because not all responses are the same.

 

But WHY do I get a General Protection Fault?

 

0 Kudos
Message 3 of 22
(3,614 Views)

Dennisatwork,

 

I'm sorry, I was unclear what you were asking.  Off the bat, it's difficult to say why you are recieving the General Protection Fault.  To be clear, when you use a delay, the General Protection Fault doesn't occur right?

 

What happens when you vary the timeout of the ncWaitForState function?  Does the fault occur more quickly with a lower timeout?  Does it occur at all with a longer timout?

 

How long does the delay have to be to prevent the fault?

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 4 of 22
(3,599 Views)

When I use the Delay() and comment out the ncWaitForState() function the GPF (General Protection Fault) does NOT appear.

 

I get the GPF no matter what timeout I put in. The time it takes to get the GPF may vary with the timeout but it's had to tell.

 

I have tried putting the ncWaitForState() in the function with the ncWrite but I still get the GPF.

0 Kudos
Message 5 of 22
(3,585 Views)

Dennisatwork,

 

Thanks for the additional information!  I am still not sure why you are recieving this error at the moment.  A few steps to try:

 

Does the GPF occur when the code is run on a different computer?

 

Does this happen with any hardware attached, or is it specific to a device?

 

You said that the GPF does not occur when you take the ncWaitForState() function out and add a Delay().  Does the GPF still occur if you do not use a delay, or if you add a delay but do not remove the ncWaitForState function?  

 

Have you been able to reproduce this behavior in a simplified application (perhaps just using the functions you describe)? 

 

 

 

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 6 of 22
(3,567 Views)

The GPF does NOT happen without the Delay(). Without the Delay() the ncReadMult() function reads the incorrect response from the UUT.

 

The GPF happens using different UUTs.

 

The CAN init is this:

 

  AttrIdList[0] =         NC_ATTR_BAUD_RATE;  
  AttrValueList[0] =      250000;

  AttrIdList[1] =         NC_ATTR_START_ON_OPEN;
  AttrValueList[1] =      NC_TRUE;

  AttrIdList[2] =         NC_ATTR_READ_Q_LEN;
  AttrValueList[2] =      150;

  AttrIdList[3] =         NC_ATTR_WRITE_Q_LEN;
  AttrValueList[3] =      150;

  AttrIdList[4] =         NC_ATTR_CAN_COMP_STD;
  AttrValueList[4] =      0;

  AttrIdList[5] =         NC_ATTR_CAN_MASK_STD;
  AttrValueList[5] =      NC_CAN_MASK_STD_DONTCARE;

  AttrIdList[6] =         NC_ATTR_CAN_COMP_XTD;
  AttrValueList[6] =      0;

  AttrIdList[7] =         NC_ATTR_CAN_MASK_XTD;
  AttrValueList[7] =      NC_CAN_MASK_XTD_DONTCARE;

 

I wiil try a different computer.

 

 

0 Kudos
Message 7 of 22
(3,558 Views)

Dennisatwork,

 

I want to make sure I am clear on what you are saying here.  As I understand it, the GPF only occurs when the ncWaitForState function is present.  When it is not present, the ncReadMult returns incorrect values unless a Delay is present.

 

With this information, a simple application that solely writes, waits and reads should be able to reproduce this behavior.  Can you reproduce it using a simple application like this?

 

Also, what CAN hardware are you using?  I understand that the GPF occurs with different UUTs, but I want to look into the hardware being used to communicate with the UUT.

 

I'll look for your response regarding the testing on other computers as well.

 

Thanks,

 

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 8 of 22
(3,548 Views)

 Hardware - NI PXI-8512/2 .

 

"I want to make sure I am clear on what you are saying here.  As I understand it,
the GPF only occurs when the ncWaitForState function is present. 
When it is not present, the ncReadMult returns incorrect values unless a Delay is present."-    YES

 


"With this information, a simple application that solely writes,
waits and reads should be able to reproduce this behavior. 
Can you reproduce it using a simple application like this? " --- YES

 

I tried this on another PC and still get a GPF on the ncWaitForState() function.


 

0 Kudos
Message 9 of 22
(3,542 Views)

Dennisatwork,

 

First off, I apologize for missing the hardware you described in your first post.  Thank you for providing it again.

 

Secondly, I'd like to test out what you are seeing on my side.  Would you mind posting the simple application you used to produce this behavior?  If you'd rather, you can also PM it to me.

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 10 of 22
(3,539 Views)