Syntax and parse error for uint32 values

Issue #14 open
Willy created an issue

First of all, thanks for providing this library.

I have problems with the following dbc file that I created with the Vector CANdb++ Editor.

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_:
VAL_TABLE_ New_Value_Table_123 -1 "not available" -2 "error" -3 "reserved 1" -4 "reserved 2" ;


BO_ 1312 New_Message_62: 4 Vector__XXX
 SG_ New_Signal_388 : 0|32@1+ (1,-36000) [-36000|4294931295] "s" Vector__XXX



BA_DEF_ SG_  "GenSigStartValue" INT 0 0;
BA_DEF_  "BusType" STRING ;
BA_DEF_DEF_  "GenSigStartValue" 0;
BA_DEF_DEF_  "BusType" "CAN";
BA_ "GenSigStartValue" SG_ 1312 New_Signal_388 4294967295;
VAL_ 1312 New_Signal_388 -1 "not available" -2 "error" -3 "reserved 1" -4 "reserved 2" ;

The issues occur when I use the operator>> of the Network class.

First issue:

Parse error at 37.31-32: syntax error, unexpected SIGNED_INTEGER, expecting UNSIGNED_INTEGER or SEMICOLON

Second issue:

terminate called after throwing an instance of 'std::out_of_range'
  what():  stol
Aborted

It looks like that the uin32 values are stored as int32 values in dbc file by Vector CANdb++ Editor.

In the Vector CANdb++ Editor the values are displayed this way:

dbc file CANdb++ Editor
-1 0xFFFFFFFF
-2 0xFFFFFFFE
-3 0xFFFFFFFD
-4 0xFFFFFFFC

Is it a good idea to use int64_t instead of int32_t in the Attribute class? (And std::stoll in Parser class?)

Can the syntax check be disabled (temporarily)?

Comments (6)

  1. WorkerH

    The Vector_DBC grammar does not allow a signed integer there:

    value_encoding_description
            : unsigned_integer char_string { $$ = std::make_pair($1, $2); }
            ;
    

    I think, you could temporary make it work by replacing the above 3 lines in the Parser.yy file at line 322 with this:

    value_encoding_description
            : signed_integer char_string { $$ = std::make_pair($1, $2); }
            ;
    

    And then rebuild Vector_DBC.

  2. Tobias Lorenz repo owner

    First of all, thanks for providing this library.

    I have problems with the following dbc file that I created with the Vector CANdb++ Editor.

    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_:
    VAL_TABLE_ New_Value_Table_123 -1 "not available" -2 "error" -3 "reserved 1" -4 "reserved 2" ;
    
    
    BO_ 1312 New_Message_62: 4 Vector__XXX
     SG_ New_Signal_388 : 0|32@1+ (1,-36000) [-36000|4294931295] "s" Vector__XXX
    
    
    
    BA_DEF_ SG_  "GenSigStartValue" INT 0 0;
    BA_DEF_  "BusType" STRING ;
    BA_DEF_DEF_  "GenSigStartValue" 0;
    BA_DEF_DEF_  "BusType" "CAN";
    BA_ "GenSigStartValue" SG_ 1312 New_Signal_388 4294967295;
    VAL_ 1312 New_Signal_388 -1 "not available" -2 "error" -3 "reserved 1" -4 "reserved 2" ;
    

    The issues occur when I use the operator>> of the Network class.

    First issue:

    Parse error at 37.31-32: syntax error, unexpected SIGNED_INTEGER, expecting UNSIGNED_INTEGER or SEMICOLON
    

    Second issue:

    terminate called after throwing an instance of 'std::out_of_range'
      what():  stol
    Aborted
    

    It looks like that the uin32 values are stored as int32 values in dbc file by Vector CANdb++ Editor.

    In the Vector CANdb++ Editor the values are displayed this way:

    dbc file CANdb++ Editor
    -1 0xFFFFFFFF
    -2 0xFFFFFFFE
    -3 0xFFFFFFFD
    -4 0xFFFFFFFC

    Is it a good idea to use int64_t instead of int32_t in the Attribute class? (And std::stoll in Parser class?)

    Can the syntax check be disabled (temporarily)?

  3. Willy reporter

    Hi,

    your change solves the issue. Thank you very much!

    @WorkerH Thanks for your suggestion. I haven’t tried your solution, sorry.

  4. Tobias Lorenz repo owner

    I missed to work on this topic and integrate the fix.

    So the spec says unsigned_integer. The official implementation uses signed_integer. Maybe it’s proper to have a configuration option / macro to switch between the two behaviors. And I tend that the specification should be the default option.

  5. Log in to comment