Skip to content

Commit e1ade36

Browse files
author
Pascal Hertleif
committed
Split CONTRIBUTING from README
1 parent 20f23d8 commit e1ade36

File tree

2 files changed

+68
-28
lines changed

2 files changed

+68
-28
lines changed

CONTRIBUTING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Development
2+
3+
Thanks for looking into contributing to this project!
4+
5+
## Quick overview
6+
7+
```bash
8+
# generate messages.rs to look at results
9+
cargo run -p dbc-codegen-cli -- testing/dbc-examples/example.dbc testing/can-messages/src
10+
11+
# build everything
12+
cargo build --all
13+
14+
# run all tests
15+
cargo test --all
16+
17+
# format before committing anything
18+
cargo fmt --all
19+
```
20+
21+
## Testing setup
22+
23+
Please refer to the [testing README file](./testing/README.adoc)
24+
25+
## Generate .kdc from .dbc
26+
27+
Use [canmatrix](https://github.com/ebroecker/canmatrix) if you need to generate a new `.kcd` file from a `.dbc`.
28+
29+
```bash
30+
# https://canmatrix.readthedocs.io/en/latest/installation.html
31+
pip install canmatrix
32+
pip install git+https://github.com/ebroecker/canmatrix#egg=canmatrix[kcd]
33+
34+
# generate .kcd
35+
canconvert testing/dbc-examples/example.dbc testing/dbc-examples/example.kcd
36+
```

README.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1627
For example:
28+
1729
```
1830
VAL_ 512 Five 0 "0Off" 1 "1On" 2 "2Oner" 3 "3Onest";
1931
```
20-
..is generated to:
32+
33+
…is generated as:
34+
2135
```rust
2236
pub enum BarFive {
2337
X0off,
@@ -29,10 +43,13 @@ pub enum BarFive {
2943
```
3044

3145
`Type` here:
46+
3247
```
3348
SG_ 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
3754
pub 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

Comments
 (0)