05-11-2011 02:05 PM
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);
}
05-12-2011 01:11 PM
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!
05-12-2011 01:40 PM
I don't want a hard delay because not all responses are the same.
But WHY do I get a General Protection Fault?
05-13-2011 10:52 AM
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?
05-16-2011 09:21 AM
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.
05-17-2011 05:36 PM
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)?
05-18-2011 07:52 AM
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.
05-19-2011 11:03 AM
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,
05-20-2011 07:52 AM
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.
05-20-2011 10:37 AM
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.