目录
3.testWaitForTesterConfirmation
1.testWaitForAnyJoinedEvent
void Util_Setup_WaitForResponse(byte frameId)
{
// The order of the join events below is important! It has to be consistent with the implementation of Util_WaitForValidResponse()!
testJoinMessageEvent(frameId);
testJoinLinReceiveErrorEvent(frameId);
testJoinLinCSErrorEvent(frameId);
testJoinLinTransmErrorEvent(frameId);
}
int SendHeaderAndEvaluateSlaveResponse(byte txFrameID, int64& currentInitializationTimeNs, int64 maxLengthOfResponseInNs, int64 timeOfPowerUpNs, int64 maxInitializationTimeNs)
{
long resultOfWaitForResponse;
linFrame 0x00 receivedFrame;
linFrame 0x37 Frame;
testWaitForTimeout(3);
Util_Setup_WaitForResponse(txFrameID);
Util_SendHeader(txFrameID);
writeEx(-3,1,"%g",timeNowNS()/1000000);
//resultOfWaitForResponse = testWaitForAnyJoinedEvent(maxLengthOfResponseInNs/1000000);
writeEx(-3,1,"%d.",maxLengthOfResponseInNs/1000000);
resultOfWaitForResponse = testWaitForAnyJoinedEvent(20);
currentInitializationTimeNs = timeNowInt64() - timeOfPowerUpNs;
if(resultOfWaitForResponse < 0)
{
testStepFail("Unexpected error: could not evaluate IUT response.");
return 0;
}
else if(resultOfWaitForResponse == 1)
{
if(testGetWaitEventMsgData(receivedFrame) == 0)
{
//IUT has answered correctly
currentInitializationTimeNs = receivedFrame.EOH - timeOfPowerUpNs;
testStep(Util_TestcasePhase, "IUT has responsed to the tx frame header after %5.2f ms", (currentInitializationTimeNs / 1000000.0));
Util_GetWaitEventMsgData(receivedFrame.ID);
if(currentInitializationTimeNs <= maxInitializationTimeNs)
{
testStepPass(Util_TestcasePhase, "IUT has responded within the time limit (%d ms)", (maxInitializationTimeNs / 1000000));
Util_ReportAddTraceData();
}
else
{
// testStepFail(Util_TestcasePhase, "IUT has not responded within the time limit (%d ms)", (maxInitializationTimeNs / 1000000));
// Util_OnTestStepFail();
}
return 0;
}
else
{
testStepFail(Util_TestcasePhase, "Unexpected error: could not access received frame data!");
//Util_OnTestStepFail();
return 1;
}
}
else if(resultOfWaitForResponse == 4 || resultOfWaitForResponse == 0)
{
writeEx(-3,1,"%d resultOfWaitForResponse",resultOfWaitForResponse);
testStep(Util_TestcasePhase, "IUT has not yet responsed to tx frame header. Time passed since power up: %d ms" ,(currentInitializationTimeNs / 1000000));
if(currentInitializationTimeNs > maxInitializationTimeNs)
{
testStepFail(Util_TestcasePhase, "IUT has not responded to the tx frame header after the maximum initialization time has passed (%d ms).", (maxInitializationTimeNs / 1000000));
//Util_OnTestStepFail();
return 2;
}
else
{
return 3;//do nothing and try again in the next iteration of the loop
}
}
else
{
testStepFail(Util_TestcasePhase, "IUT has responded with an invalid response");
Util_OnTestStepFail();
return 2;
}
}
函数以代码运行处开始计时,最小超时时间为一帧总时间
与testjoinxx函数配合使用
2.testWaitForTimeout
timeOfPowerUpNs = timeNowNs();
testWaitForTimeout(50);
testStep(Util_TestcasePhase, "IUT has been powered up again. Send tx frame headers and wait for IUT response.");
空闲时间等待,用于发送间隙或者测试延时
3.testWaitForTesterConfirmation
enum _Bool Util_WakeupSignal_TriggerIUT(char testcaseNr[])
{
testStep(Util_TestcasePhase, "Ask the tester to cause IUT to send wakeup signal in %d seconds", Util_IUTWakeupTimeout);
snprintf(Util_UserMessage, elcount(Util_UserMessage)
,"Test %s;\nPlease stimulate IUT to send wakeup signal;\nPress 'Yes' when IUT is ready to transmit wakeup signal in %d seconds;\nPress 'No' to skip this test."
, testcaseNr, Util_IUTWakeupTimeout);
if (!Util_IsAutoAnswer())
{
if (testWaitForTesterConfirmation(Util_UserMessage) == 2)
{
testStepFail(Util_TestcasePhase, "Test case skipped during execution by user!");
return _False;
}
}
else
{
setTimer(triggerWakeupTimer, 1000);
}
testStepPass(Util_TestcasePhase, "Tester confirmed that IUT will issue wakeup signal in %d seconds", Util_IUTWakeupTimeout);
return _True;
}
{
..
if (_False == Util_WakeupSignal_TriggerIUT(testcaseNr))
{
Util_Get3446_MeasurementOff();
return;
}
// ######## Verification ################
Util_SetTestcasePhase(_phaseVerification);
testStep(Util_TestcasePhase, "IUT shall send the wakeup signal according to [WAKE UP 2.6.2] (250us < t < 5ms)");
testStep(Util_TestcasePhase, "IUT shall transmit a new wakeup signal within 150 ms to 250 ms");
testStep(Util_TestcasePhase, "IUT shall transmit a new block of wakeup signals not before 1,5s after the last wakeup signal");
// wait for 3 retransmissions
for (nRetryIndex=1; nRetryIndex <= 3; ++nRetryIndex)
{
switch ( Util_WakeupSignal_WaitAndValidate(nRetryIndex) )
{
case _wakeupOK:
// wakeup length was OK
// check delay between retransmissions (tolerance of 100us!)
if (nRetryIndex > 1 && (Util_MeasuredWakeupDelay < 149900000 || Util_MeasuredWakeupDelay > 250100000))
{
testStepFail(Util_TestcasePhase,
"Retransm. #%d: IUT has retransmitted wakeup signal with an invalid delay. T[retransm. delay]=%I64d ns",
nRetryIndex, Util_MeasuredWakeupDelay);
Util_OnTestStepFail();
Util_Get3446_MeasurementOff();
return;
}
testStepPass(Util_TestcasePhase,
"Retransm. #%d: IUT has sent wakeup signal correctly. T[wakeup]=%I64d ns. Delay between retransm.: %I64d ns",
nRetryIndex, Util_MeasuredWakeupLength, (nRetryIndex == 1 ? 0 : Util_MeasuredWakeupDelay));
break;
case _wakeupLenFail:
testStepFail(Util_TestcasePhase,
"Retransm. #%d: IUT has sent wakeup signal with an invalid length. T[wakeup]=%I64d ns",
nRetryIndex, Util_MeasuredWakeupLength);
Util_OnTestStepFail();
Util_Get3446_MeasurementOff();
return;
case _wakeupNotExternal:
testStepFail(Util_TestcasePhase, "Retransm. #%d: wakeup signal has been received, but not from the IUT", nRetryIndex);
Util_OnTestStepFail();
Util_Get3446_MeasurementOff();
return;
default:
testStepFail(Util_TestcasePhase, "Retransm. #%d: No wakeup signal has been received", nRetryIndex);
Util_OnTestStepFail();
Util_Get3446_MeasurementOff();
return;
}
}
...
}
留给测试者准备时间,在此时间内触发均可执行下述操作,适用于自测