1

I'm wondering if it is possible to create a CAPL code in which, by using "on key" feature, the user may: - activate a replay mode (.asc file) - activate a filter on it - activate additionally a specific signal (not present in asc files) - deactivate the replay mode - deactivate the specific signal - activate or deactivate alternatively specific messages and/or trace

In detail, for the moment I am using this one:

/*@!Encoding:1252*/
variables // declaration of the specific messages I need
{
    message MESSAGE01 msg_MESSAGE01 ; 
    message MESSAGE02 msg_MESSAGE02 ;
}

on key 't' // here I'd need the activation of a replay block in .asc format with a filter on a specific message
{
// Really don't know how to insert here
}

on key 'd' // here I'd need the deactivation of a replay block in .asc format
{
// Really don't know how to insert here
}

on key 'p' // specific signals deactivation 
{
  msg_MESSAGE01.SIGNAL01= 0; // assign the value to the message
  msg_MESSAGE02.SIGNAL02 = 1; // assign the value to the message
  output(msg_MESSAGE01); //send the message to the CAN bus
  output(msg_MESSAGE02); //send the message to the CAN bus
  // output(output of the asc file); // if activated, I'd like to see in output all the messages of the .asc; if not, I'd like to see just those specific signals.
}

on key 'u' // specific signals deactivation
{
 // msg_MESSAGE01.SIGNAL01 = none; // here, I'd like to "unset" the value
  msg_MESSAGE02.SIGNAL02= 0;
  output(msg_MESSAGE01); 
  output (msg_MESSAGE02);
  // output(output of the asc file); // if activated, I'd like to see in output all the messages of the .asc; if not, I'd like to see just those specific signals.
}

If not clear, I'm available to explain better my request :)

Thank you in advance ^^ Cheers

dan1st
  • 12,568
  • 8
  • 34
  • 67
Serena
  • 11
  • 1
  • 2
  • Currently there is no CAPL mechanism for enabling/disabling Compiled sources, like network nodes. Only disabling output of nodes through IL. There is no direct access from CAPL to enable/disable Measurement Setup elements either. Disabling/enabling messages (Not signals) is possible, but with considering IL, dlls in place, database settings, or in lack of all of these, the implemented CAPL hard code to dictate the sending of (cyclic/on event) messages. – VioletVynil Mar 06 '19 at 08:15
  • @VioletVynil, there is actually a function named canOnline / canOffline. The help for canOnline reads: `Restores the connection of the node to the bus. Messages send from the node are passed through to the bus. If the node is set to offline, output instructions for sending messages in CAPL or NodeLayer DLL are ignored (refers to a node locally only).` I agree: disabling a signal is not possible, afaik, yet probably what she is asking is to toggle signal from 0 to 1 where 0 is "don't send". – Daemon Painter Mar 06 '19 at 15:10
  • @Daemon Painter Indeed, canOnline() would do the trick in CAN communication. – VioletVynil Mar 06 '19 at 15:41

2 Answers2

1

Welcome to StackOverflow!

You can actually activate a replay block (at least on CANoe, please have a look for compatibility on CANalyzer).

I'd need the activation/deactivation of a replay block in .asc format

variables
{
    char replayName[32] = "ibus_data";
}

on key 'b'
{
    replayStart( replayName);
}

on key 'e'
{
    replayStop( replayName);
}

on key 's'
{
    replaySuspend( replayName);
}

on key 'r'
{
    replayResume( replayName);
}

on key 'w'
{
    writeReplayState( replayName);
}

void writeReplayState( char name[])
{
    switch ( replayState( name))
    {
        case 0:
            write( "Replay Block %s is stopped", replayName);
            break;

        case 1:
            write( "Replay Block %s is running", replayName);
            break;
        case 2:
            write( "Replay Block %s is suspended", replayName);
            break;
        default:
            write( "Error: Replay Block %s has an unknown state!", replayName);
            break;
    };
}

You'll have to configure the replay file beforehands, and the filter part requires a different solution. For more information, check the reference and this example: ReplayStart, ReplayStop, ReplaySuspend, ReplayResume, ReplayState

From: CAPL Function Overview » General » Example: ReplayStart, ReplayStop, ReplaySuspend, ReplayResume, ReplayState

specific signals activation/deactivation

One "hacky" solution that pops into my mind, it to have a flag system in place. Of course, ugly solution, probably there is something better at hand. Try something like:

on message myMessage
{
    if (flag)
         output(myMessage)
}

on key 'u'
{
   flag ? 0 : 1  // short for: toggle the status of the flag
}

Please let me know if this helped.


Regarding this piece of code:

on key 'p' // specific signals deactivation 
{
  msg_MESSAGE01.SIGNAL01= 0; // assign the value to the message
  msg_MESSAGE02.SIGNAL02 = 1; // assign the value to the message
  output(msg_MESSAGE01); //send the message to the CAN bus
  output(msg_MESSAGE02); //send the message to the CAN bus
}

Please note that it won't do what you expect. You are asking to send the message on user keyboard action. If the message was already set for cyclic output, it will continue to go with the clock and an extra publish will be made on keyboard. Otherwise, message will only be published once.

The proposed solution works with a flag in the on message *, that, in turn, works as a filter, blocking the message and repeating it only if the flag is set.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
0

You can just add Replay Block to the bus, and in configuration type specified start/stop key. Specified signals activation/deactivation can stay as you wrote it.

Replay block configuration

BBart
  • 94
  • 4