Search code examples
c++ccan-buscapl

How to monitor a CAN signal continuously using CAPL?


There is a signal named 'A' which counts from 0 to 20 of a specified occurrence. The signal will reset to 0 after it counts 20. The time interval between each occurrence is 20 ms. I need to monitor this signal A for 200 times. Whenever the counter skips a value ,say for example: 0,1,4,5..20 ,I need to to store that particular instance. Is there anyway to do this? Is there any commands in CAPL to catch the value of the counter signal A whenever it changes.?


Solution

  • When running in a test node there are several methods available for reacting on signals.

    Their names all start with testWaitForSignal. You can simply check CANoe's documentation for details.

    For your particular use case, you could use

    testWaitForSignalMatch(<signal>, <expectedValue>, 20)
    

    The call will return latest after 20ms. The return value will either be 1, which means the signal had the expected value within 20ms or 0, which means the signal did not have the expected value within 20ms.


    When running in a simulation/measurement node, there is no possibility to wait, as that would block the simulation.

    What you can do in these nodes is to create an event handler like

    on signal_change <signal>
    

    In this event handler you can access the value of the signal by using $<signal>.

    The current timestamp can be gotten with a call to timeNowNS().

    Using this information you could implement your logic in a simulation node.