How do I create an extended message ID in CAPL?

7k Views Asked by At

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

3

There are 3 best solutions below

0
On BEST ANSWER
  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);
}
2
On

The function mkExtId returns the extended id, which then you assing to the id if the message, here an example:

This function sets the extended id of the message passed:

void setExtId(dword x_id, message* m)
{
  dword ext_id;
  ext_id = mkExtId(0x1FFFFFFF);
  m.id = mkExtId(x_id);
  if(m.id == ext_id)
  {
    write("some stuff");
  }
}
0
On

You can simply declare the message in this way:

message 0x114455x msg;