testcase tcWaitForOneOfDTCs(dword sourceAddress)
{
long eventIndex;
dword sa = 0x1;
pg DM12 pgDM12;
// All DTCs are transmitted with the message DM12 (pgn = 0xFED4).
// DTC Condition 1: spn = 111, fmi = 12, oc to be ignored
TestJoinJ1939DTCEvent (sourceAddress, DM12.pgn, 111, 12, 0xFFFF);
// DTC Condition 2: spn = 222, fmi to be ignored, oc = 5
TestJoinJ1939DTCEvent (sourceAddress, DM12.pgn, 222, 0xFFFF, 5);
// DTC Condition 3: spn = 333, fmi and oc to be ignored
TestJoinJ1939DTCEvent (sourceAddress, DM12.pgn, 333, 0xFFFF, 0xFFFF);
eventIndex = testWaitForAnyJoinedEvent(5000);
switch (eventIndex)
{
case 1:
testStepPass("Validation", "DTC with spn=111 and fmi=12 occurred");
if (testGetWaitJ1939PGData(eventIndex, pgDM12) == 0)
{
// validate data of received DM12 via pgDM12
}
break;
case 2:
testStepPass("Validation", "DTC with spn=222 and oc=5 occurred");
if (testGetWaitJ1939PGData(eventIndex, pgDM12) == 0)
{
// validate data of received DM12 via pgDM12
}
break;
case 3:
testStepPass("Validation", "DTC with spn=333 occurred");
if (testGetWaitJ1939PGData(eventIndex, pgDM12) == 0)
{
// validate data of received DM12 via pgDM12
}
break;
default:
testStepFail("Validation", "Unexpected event or timeout (return code of testWaitForAnyJoinedEvent: %d)", eventIndex);
break;
}
}