I am currently developing test cases in CANoe using CAPL Language. My objective is to capture and save the entire CAN Frame as it appears on the trace, rather than just the signal it contains. While I understand how to accomplish this in the Network Node using the on message{} event, I am encountering difficulty implementing this within a TestCase. Specifically, I aim for the test case to execute, retrieve the current value of the CAN Frame, and proceed with the intended testing procedures. Any insights or suggestions on achieving this functionality within a TestCase environment would be greatly appreciated.
I initially attempted to utilize CANoe system variables, but found it cumbersome due to the necessity of creating numerous system variables for each CAN Frame. This approach proved to be inefficient for my requirements.
CANoe's test feature set provides functions like testWaitFor...
for waiting for a certain event and functions like testGet...
for retrieving data.
In your case, you could use testWaitForMessage
to wait until a CAN message is seen on the bus, followed by testGetWaitEventMsgData
.
In your question you do not specify, whether you want to act on a certain message or just any message.
Assuming the latter, your code could look like this:
long result;
message * MyMessage
result = testWaitForMessage(10000 /* timeout */);
if(result < 0) {
return;
}
result = testGetWaitEventMsgData(MyMessage);
if(0 != result) {
return;
}
// process MyMessage
If you want to work an a certain message type you can use one of the overloads of the aforementioned functions.