Long signal value generates invalid C code.
Closed this issue · 5 comments
FZGabriel commented
The code generated from this following signal value is broken:
VAL_ 2147483938 IVT_SleepAck 15 "reserved 15" 14 "reserved 14" 13 "reserved 13" 12 "reserved 12" 11 "reserved 11" 10 "reserved 10" 9 "reserved 9" 8 "reserved 8" 7 "reserved 7" 6 "reserved 6" 5 "reserved 5" 4 "reserved 4" 3 "reserved 3" 2 "reserved 2" 1 "Sleep request acknowledged" 0 "Sleep request not acknowledged" ;
The broken code (look at the whitespaces)
typedef enum {
IVT_SleepAck_Sleep request not acknowledged_e = 0,
IVT_SleepAck_Sleep request acknowledged_e = 1,
IVT_SleepAck_reserved 2_e = 2,
IVT_SleepAck_reserved 3_e = 3,
IVT_SleepAck_reserved 4_e = 4,
IVT_SleepAck_reserved 5_e = 5,
IVT_SleepAck_reserved 6_e = 6,
IVT_SleepAck_reserved 7_e = 7,
IVT_SleepAck_reserved 8_e = 8,
IVT_SleepAck_reserved 9_e = 9,
IVT_SleepAck_reserved 10_e = 10,
IVT_SleepAck_reserved 11_e = 11,
IVT_SleepAck_reserved 12_e = 12,
IVT_SleepAck_reserved 13_e = 13,
IVT_SleepAck_reserved 14_e = 14,
IVT_SleepAck_reserved 15_e = 15,
} IVT_SleepAck_e;
Thanks for the tool.
Compiling and using it was straightforward and intuitive :)
FZGabriel commented
Additional comments:
I just noticed that signal values with the +
and -
characters are not handled properly.
VAL_ 2147483920 IVT_Ctrl_Fuse_State 1 "Fuse+ AND Fuse- closed" 0 "Fuse+ OR Fuse- open" ;
The generated code:
typedef enum {
IVT_Ctrl_Fuse_State_Fuse+ OR Fuse- open_e = 0,
IVT_Ctrl_Fuse_State_Fuse+ AND Fuse- closed_e = 1,
} IVT_Ctrl_Fuse_State_e;
howerj commented
Looks like a problem! It should be a fairly easy fix though.
howerj commented
Do you have an example DBC file with these in?
FZGabriel commented
Hi Richard,
Thanks for your answer.
Do you have an example DBC file with these in?
Of course.
The following dbc will produce the broken enum
.
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_: Destination IVT_30_Node
BO_ 2147483938 IVT_SleepAck: 1 IVT_30_Node
SG_ IVT_SleepAck : 0|4@1- (1,0) [0|0] "" Destination
BO_ 2147483920 IVT_Ctrl: 8 Destination
SG_ IVT_Ctrl_Fuse_State : 13|1@1+ (1,0) [0|0] "" IVT_30_Node
CM_ BO_ 2147483938 "Control message 1.";
CM_ SG_ 2147483938 IVT_SleepAck "cm 1";
CM_ BO_ 2147483920 "Control messave 2.";
CM_ SG_ 2147483920 IVT_Ctrl_Fuse_State "cm 1";
BA_DEF_ "Version" STRING ;
BA_DEF_ "SyncJumpWidthMin" INT 1 4;
BA_DEF_ "SyncJumpWidthMax" INT 1 4;
BA_DEF_ "SamplePointMin" INT 1 100;
BA_DEF_ "SamplePointMax" INT 1 100;
BA_DEF_ SG_ "GenSigStartValue" INT -2147483648 2147483647;
BA_DEF_ "Baudrate" INT 250000 1000000;
BA_DEF_ "BusType" STRING ;
BA_DEF_ BO_ "GenMsgCycleTime" INT 0 65535;
BA_DEF_DEF_ "Version" "1_1_0_Released";
BA_DEF_DEF_ "SyncJumpWidthMin" 1;
BA_DEF_DEF_ "SyncJumpWidthMax" 1;
BA_DEF_DEF_ "SamplePointMin" 1;
BA_DEF_DEF_ "SamplePointMax" 1;
BA_DEF_DEF_ "GenSigStartValue" 0;
BA_DEF_DEF_ "Baudrate" 500000;
BA_DEF_DEF_ "BusType" "CAN";
BA_DEF_DEF_ "GenMsgCycleTime" 0;
BA_ "SyncJumpWidthMin" 2;
BA_ "SyncJumpWidthMax" 4;
BA_ "SamplePointMin" 80;
BA_ "SamplePointMax" 84;
BA_ "Baudrate" 500000;
BA_ "BusType" "CAN";
BA_ "GenMsgCycleTime" BO_ 2147483920 100;
VAL_ 2147483938 IVT_SleepAck 15 "reserved 15" 14 "reserved 14" 13 "reserved 13" 12 "reserved 12" 11 "reserved 11" 10 "reserved 10" 9 "reserved 9" 8 "reserved 8" 7 "reserved 7" 6 "reserved 6" 5 "reserved 5" 4 "reserved 4" 3 "reserved 3" 2 "reserved 2" 1 "Sleep request acknowledged" 0 "Sleep request not acknowledged" ;
VAL_ 2147483920 IVT_Ctrl_Fuse_State 1 "Fuse+ AND Fuse- closed" 0 "Fuse+ OR Fuse- open" ;
Thanks for your work.
howerj commented
This should be fixed now