Sending message with CAPL and dbc signal values

Raros picture Raros · May 3, 2017 · Viewed 13.2k times · Source

I am using CAPL to simulate a test envirmonet for some small tests and i am having problems sending messages or more specific setting up the values.

I am able to read Signal Values with $SignalName, also i am able to set signal values like that.

If i am using this code to send a message the message data is always 0:

on key 't'
{
  message MessageName msg;
  setSignal(SignalName,i);
  write("Value: %d",i);
  outport(msg);
}

Witch makes kinda sence becouse i think the message objects are intended to be used to send bytes witch you can access through msg.byte()

I know that i can set signals in messages by msg.SignalName, but again this seems not the right way. I think there should be a way to send a message and all the signals contained in the message are set to the values set by SetSignal() function. Otherwise the SetSignal Funktion is a bit useless

Maybe somebody has an idea. Thank you

Answer

BruceWayne picture BruceWayne · Sep 29, 2017

I am using CANalyzer version 8.2 and I do not have the option to use SetSignal(signal, value) function. Setting the signal values by accessing the message selectors seems to be a reasonable approach. However you used the function outport! You need to use the output function to transmit messages.

on key 't' {
  message MessageName msg;
  msg.signal1 = value1;
  output(msg);
}

For this method the database has to be configured so that the message msg contains all the necessary signals (signal1).

If you want to set all signal values to the start values configured in the database use the function:

setSignalStartValues(message msg);