caplmessageid

How do I create an extended message ID in CAPL?


CAPL does accept message definitions like the following

message 100x mymsg

It does not however accept long message IDs, which is the case of extended payloads. In other words, this is what I would like to do (and CAPL does not accept):

message 18FEF889x mymsg

I know there is the function mkExtId(), though I haven't still figured out how it works. I tried something like

message 18FEF889x mymsg

mkExtId(mymsg.id)

but it still doesn't work. Does anybody have any ideas?

Thanks


Solution

    1. First declare a message without ID

      message *ExtMsg; // Declaration without Id

    2. Use CAPl Function mkExtId() to return an extended ID
    3. assign that id to the message.
    variables
    {
      timer T1 = 1;
      message 0x100 stdMsg;
      dword ext_id ;
      message *ExtMsg;  // Declaration without Id
    }
    
    on start
    {
      setTimer(T1,1);
      ext_id = mkExtId(0x34444);
      ExtMsg.id = ext_id;
      ExtMsg.dlc = 2;
    }
    
    on Timer T1
    {
     ExtMsg.byte(0) = 99;
     stdMsg.stdSignal =2;
     output(stdMsg);
     output(ExtMsg);
     setTimer(T1,1);
    }