Search code examples
embeddedcan-buscaplcanoeautomotive

CAPL Signal value assignment and read use physical or raw data?


I am new to CAPL and Canoe, my question is when assign value to signal in CAN message should you assign using physical signal like this: MSG.Signal_A = raw_data * scale + offset; Or just assign the raw_data: MSG.Signal_A = raw_data; I am learning using demo version and simulation without real HW so i do not know how to check.

I was expecting to use physical value because CAPL kind of look like C++ to me. I think the message ID object is a wraper for a raw CAN frame and it has internal method to convert between raw and physical.


Solution

  • Both options are available. However, by default, setting/reading a signal gives you the physical value. That is, the scale and offset defined in the .dbc are applied automatically. If you want access to the raw value, then you can use the ".raw" property on the signal.

    MSG.Signal_A = raw_data * scale + offset; //this is OK. Calculate + set physical value
    MSG.Signal_A = phys_value; //this is OK. Set physical value directly
    MSG.Signal_A.phys = phys_value; //equivalent to above
    MSG.Signal_A = raw_data; //this will not yield the expected result. you are using raw value to set phyical
    MSG.Signal_A.raw = raw_data; //this is OK