'How to use "On Message" event to check specific message availability over different CAN using Message ID

I am having measurement log data file offline running in CANoe with more than 15 CANS. I want to check the specific CAN message availability from different CAN bus while running the offline logfile. I tried to use “on Message * “event, executing only once as I want to save that result in to text file. Problem is every time its executing else condition. Is there any easy solution for the given problem?

Thank you

Variable
     dword CANFD_01= 0x1A55549B 
       int MessageExecuted = 0;
     dword readHandle = 0;
     dword readHandle_01 = 0;
      
    
    on start
    {
      setFilePath(path, 1);
      readHandle = openFileWrite("Result.txt",0);
      readHandle_01 = openFileWrite("Result_02.txt",0);
    }
    
    on message *
    {
      
      if(MessageExecuted == 1) return;
      {
      if(this.id == CANFD_01)
          {  
            i = snprintf(buffer, elcount(buffer),"CANFD_01 is there  \n");
            filePutString(buffer, elcount(buffer), readHandle);         
          }
       else 
          {
          i = snprintf(buffer, elcount(buffer),"CANFD_01s not there with ID: %d\n",this.id);
              filePutString(buffer, elcount(buffer), readHandle_01);
          }
          MessageExecuted = 1; 
      } 
}


Solution 1:[1]

You want to confirm a specific frame ID across 15 different CAN networks. Does the following work for you?

variables
{
  dword frame_of_interest = 0x1A55549B; /* CANFD_01 */
  dword channel_hits[16];
}
  
on message *
{
  if( 16 > this.can )
  {
    channel_hits[this.can]++;
  }
  else
  {
    write("Channel ID out of range: %d", this.can);
  }
}

on stopMeasurement
{
  byte i;
  
  for(i=0; i<16; i++)
  {
    if( 0 < channel_hits[i] )
    {
      write("Channel ID: %d (hits=%d)", i, channel_hits[i]);
    }
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris