@@ -4,20 +4,34 @@ Generates Rust messages from a `dbc` file.
44
55⚠️ This is experimental - use with caution. Breaking changes will happen when you least expect it. ⚠️
66
7+ ## Installation
8+
9+ With cargo:
10+
11+ ``` bash
12+ cargo install dbc-codegen --git https://github.com/technocreatives/dbc-codegen --branch main
13+ ```
14+
715## Usage
816
9- Generate ` messages.rs ` from ` example.dbc ` .
17+ Generate ` messages.rs ` from ` example.dbc ` :
18+
1019``` bash
11- cargo run -- testing/dbc-examples/example.dbc dir/where/messages_rs/file/is/written
20+ dbc-codegen testing/dbc-examples/example.dbc dir/where/messages_rs/file/is/written
1221```
1322
14- If some field name starts with a non-alphabetic character or is a Rust keyword then it is prepended with ` x ` .
23+ ### Field/variant rename rules
24+
25+ If some field name starts with a non-alphabetic character or is a Rust keyword then it is prefixed with ` x ` .
1526
1627For example:
28+
1729```
1830VAL_ 512 Five 0 "0Off" 1 "1On" 2 "2Oner" 3 "3Onest";
1931```
20- ..is generated to:
32+
33+ …is generated as:
34+
2135``` rust
2236pub enum BarFive {
2337 X0off ,
@@ -29,10 +43,13 @@ pub enum BarFive {
2943```
3044
3145` Type ` here:
46+
3247```
3348SG_ Type : 30|1@0+ (1,0) [0|1] "boolean" Dolor
3449```
35- ..would become Rust keyword ` type ` therefore it is prepended with ` x ` :
50+
51+ …conflicts with the Rust keyword ` type ` . Therefore we prefix it with ` x ` :
52+
3653``` rust
3754pub fn xtype (& self ) -> BarType {
3855 match self . xtype_raw () {
@@ -43,31 +60,18 @@ pub fn xtype(&self) -> BarType {
4360}
4461```
4562
46- ## Development
47-
48- ``` bash
49- # generate messages.rs
50- cargo run -- testing/dbc-examples/example.dbc testing/can-messages/src
51-
52- # build all binaries
53- cargo build --all
63+ ## License
5464
55- # run all tests
56- cargo test --all
65+ Licensed under either of
5766
58- # format before commiting anything
59- cargo fmt --all
60- ```
67+ - Apache License, Version 2.0, ([ LICENSE-APACHE] ( LICENSE-APACHE ) or http://www.apache.org/licenses/LICENSE-2.0 )
68+ - MIT license ([ LICENSE-MIT] ( LICENSE-MIT ) or http://opensource.org/licenses/MIT )
6169
62- ### Generate .kdc from .dbc
70+ at your option.
6371
64- Use [ canmatrix ] ( https://github.com/ebroecker/canmatrix ) if you need to generate a new ` .kcd ` file from a ` .dbc ` .
72+ ### Contribution
6573
66- ``` bash
67- # https://canmatrix.readthedocs.io/en/latest/installation.html
68- pip install canmatrix
69- pip install git+https://github.com/ebroecker/canmatrix#egg=canmatrix[kcd]
70-
71- # generate .kcd
72- canconvert testing/dbc-examples/example.dbc testing/dbc-examples/example.kcd
73- ```
74+ Unless you explicitly state otherwise, any contribution intentionally
75+ submitted for inclusion in the work by you, as defined in the Apache-2.0
76+ license, shall be dual licensed as above, without any additional terms or
77+ conditions.
0 commit comments