marcelbuesing / can-dbc

Rust dbc parser
MIT License
59 stars 22 forks source link

I tried to generate using following dbc file: #7

Closed marcelbuesing closed 2 years ago

marcelbuesing commented 3 years ago

I tried to generate using following dbc file: toyota_corolla_2017_pt_generated.dbc.zip But got error:

Error: Could not parse dbc file: NomError(
Error(
Code(
CompleteByteSlice(
[
67,
77,
95,
32,
34,
65,
85,
84,
79,
71,
69,
78,
69,
82,
65,
84,
69,
68,
...

Originally posted by @andresv in https://github.com/technocreatives/dbc-codegen/issues/7#issuecomment-792576173

andresv commented 3 years ago

It was taken from comma.ai opendbc: https://github.com/commaai/opendbc/blob/master/toyota_corolla_2017_pt_generated.dbc

marcelbuesing commented 3 years ago

The crate is fairly sensitive to order of the elements and white space. It basically needs to be reordered, some whitespace removed and missing semi-colons need to be added. At least some of the stuff should probably be fixed in can-dbc (e.g. unexpected whitespace).

marcelbuesing commented 3 years ago

I just added the cantools dbc test files as an integration test. There a quite a number of files (23/58) not working right now, fixing those should cover more dbc files. Cantools seems to ignore the order of the elements so it probably make sense to ignore it in this crate as well.

abalmos commented 3 years ago

Just adding that I am trying to load a complete j1939 dbc file and hit parsing errors. I imagine many of the same issues as the failing tests you mention @marcelbuesing. Do you by chance have a good resource on the DBC format to help locate some of the errors?

marcelbuesing commented 3 years ago

Since it's a proprietary format all I can tell you is, you might find what you are looking for when searching Baidu.cn for dbc file format.

I think the issues right now are mostly:

So my goal is to finish the migration to nom 6 (nom6 branch) first so there is better error reporting (VerboseError). Help is welcome!

andresv commented 3 years ago

I took another comma dbc file and arranged some fields around to be more compatible to common understanding about dbc files. However there is something still wrong and I am unable to figure out why decoder does not like this file. toyota_prius_2017_pt_generated.dbc.zip

At least python cantools were able to parse it. Error log from parser. I guess PRE_COLLISION_2 is the last message what it was able to parse.

Message {
                message_id: MessageId(
                    836,
                ),
                message_name: "PRE_COLLISION_2",
                message_size: 8,
                transmitter: NodeName(
                    "DSU",
                ),
                signals: [
                    Signal {
                        name: "CHECKSUM",
                        multiplexer_indicator: Plain,
                        start_bit: 63,
                        signal_size: 8,
                        byte_order: BigEndian,
                        value_type: Unsigned,
                        factor: 1.0,
                        offset: 0.0,
                        min: 0.0,
                        max: 0.0,
                        unit: "",
                        receivers: [
                            "XXX",
                        ],
                    },
                ],
            },
        ],
        message_transmitters: [],
        environment_variables: [],
        environment_variable_data: [],
        signal_types: [],
        comments: [],
        attribute_definitions: [],
        attribute_defaults: [],
        attribute_values: [],
        value_descriptions: [],
        signal_type_refs: [],
        signal_groups: [],
        signal_extended_value_type_list: [],
    },
    [
        66,
        79,

EDIT: found the issue: next one was BO_ 869 DSU_CRUISE : 7 DSU which has extra after name.

andresv commented 3 years ago

This particular issue is upstream problem. Comma.ai DBC files do not follow spec: https://github.com/commaai/opendbc/issues/151 https://github.com/commaai/opendbc/issues/329

marcelbuesing commented 2 years ago

I'll close this for now-