commaai / cabana

CAN visualizer and DBC maker
https://my.comma.ai/cabana/
MIT License
173 stars 95 forks source link

Show message frequency instead of count #95

Open martinl opened 6 years ago

martinl commented 6 years ago

I think the message rate display in Hz (for example, next to Bytes field) would somewhat simplify CAN reverse-engineering and porting related activities

dzid26 commented 6 years ago

What if it is not sent periodically ?

ngbrown commented 6 years ago

Then the rate is 0 or not set. Rate is set through a "well known" attribute in the dbc file

dzid26 commented 6 years ago

Which attribute specifies that? Do you have an example?

ngbrown commented 6 years ago

From the Vector CANdb++ help file on Cycle Type and Transmission Type:

The cycle time and transmission type of the messages are determined from the user-defined attributes GenMsgSendType and GenSigSendType, GenMsgCycleTime and GenSigCycleTime of the Vector Tool Chain and cannot be edited.

So a minimal .dbc file would look something like this:

VERSION ""

NS_ : 
    NS_DESC_
    CM_
    BA_DEF_
    BA_
    VAL_
    CAT_DEF_
    CAT_
    FILTER
    BA_DEF_DEF_
    EV_DATA_
    ENVVAR_DATA_
    SGTYPE_
    SGTYPE_VAL_
    BA_DEF_SGTYPE_
    BA_SGTYPE_
    SIG_TYPE_REF_
    VAL_TABLE_
    SIG_GROUP_
    SIG_VALTYPE_
    SIGTYPE_VALTYPE_
    BO_TX_BU_
    BA_DEF_REL_
    BA_REL_
    BA_DEF_DEF_REL_
    BU_SG_REL_
    BU_EV_REL_
    BU_BO_REL_
    SG_MUL_VAL_

BS_:

BU_: PCM EON XXX
VAL_TABLE_ GEAR_SHIFTER_enum 32 "D" 8 "R" 4 "P" ;

BO_ 419 GEARBOX: 4 PCM
 SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" XXX
 SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" XXX
 SG_ GEAR : 15|8@0+ (1,0) [0|255] "" XXX
 SG_ GEAR_SHIFTER : 7|6@0+ (1,0) [0|63] "" XXX

CM_ BU_ EON "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0";
BA_DEF_  "BusType" STRING ;
BA_DEF_ SG_  "GenSigStartValue" INT 0 2147483647;
BA_DEF_ BO_  "GenMsgSendType" ENUM  "cyclic","NotUsed","IfActive","NotUsed","NotUsed","NotUsed","NotUsed","NotUsed","noMsgSendType";
BA_DEF_ BO_  "GenMsgCycleTime" INT 0 3600000;
BA_DEF_DEF_  "BusType" "CAN";
BA_DEF_DEF_  "GenSigStartValue" 0;
BA_DEF_DEF_  "GenMsgSendType" "noMsgSendType";
BA_DEF_DEF_  "GenMsgCycleTime" 0;
BA_ "GenMsgCycleTime" BO_ 419 100;
BA_ "GenMsgSendType" BO_ 419 0;
VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ;

This isn't exactly what the files in opendbc look like because those actually incorrectly use the CM_ field and violates some ordering requirements of loading into the Vector CANdb++ editor.

And cycle time is in the units of ms between messages, not Hz.