Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exclude: |
(?x)^(
.+\.(dbc|DBC)
| docs/diagram\.svg
)$

repos:
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ ref_option = "allow" # required by derive-getters
redundant_feature_names = "allow" # remove once with-serde feature is removed
needless_doctest_main = "allow" # README code block contains main function
# TODO: fix these if it makes sense
#doc_markdown = "allow" # 36
enum_variant_names = "allow" # 20
must_use_candidate = "allow" # 12
struct_field_names = "allow" # 10
missing_errors_doc = "allow" # 8
similar_names = "allow" # 4
needless_pass_by_value = "allow" # 4
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {

let mut scope = Scope::new();
for msg in dbc.messages() {
let msg_struct = scope.new_struct(msg.message_name());
let msg_struct = scope.new_struct(msg.name());
for signal in msg.signals() {
msg_struct.field(signal.name().to_lowercase().as_str(), "f64");
}
Expand All @@ -45,6 +45,10 @@ The file parser simply parses a dbc input file and prints the parsed content.
cargo run --example file_parser -- --input examples/sample.dbc
```

# Structure

![Diagram](./docs/diagram.svg)

## Implemented DBC parts

- [x] `version`
Expand Down
193 changes: 193 additions & 0 deletions docs/diagram.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
erDiagram
DBC {
version Version(str)
new_symbols[] Symbol(str)
bit_timing Optional[Baudrate(u64)[]]
nodes[] Node(str[])
value_tables[] ValueTable
messages[] Message
message_transmitters[] MessageTransmitter
environment_variables[] EnvironmentVariable
environment_variable_data[] EnvironmentVariableData(env_var_name(str)-data_size(u64))
signal_types[] SignalType
comments[] Comment
attribute_definitions[] AttributeDefinition
attribute_defaults[] AttributeDefault(name(str)-value(AttributeValue))
attribute_values[] AttributeValueForObject(name(str)-value(AttributeValuedForObjectType))
value_descriptions[] ValueDescription
signal_type_refs[] SignalTypeRef
signal_groups[] SignalGroups
signal_extended_value_type_list[] SignalExtendedValueTypeList
extended_multiplex[] ExtendedMultiplex
}

Signal {
name str
multiplexer_indicator MultiplexIndicator
start_bit u64
size u64
byte_order ByteOrder[LittleEndian-BigEndian]
value_type ValueType[Signed-Unsigned]
factor f64
offset f64
min f64
max f64
unit str
receivers[] str
}

MessageId {
Standard enum(u16)
Extended enum(u32)
}

MessageTransmitter {
message_id MessageId
transmitter[] Transmitter[NodeName-VectorXXX]
}

MultiplexIndicator {
Multiplexor enum
MultiplexedSignal enum(u64)
MultiplexorAndMultiplexedSignal enum(u64)
Plain enum
}

SignalType {
name str
signal_size u64
byte_order ByteOrder[LittleEndian-BigEndian]
value_type ValueType[Signed-Unsigned]
factor f64
offset f64
min f64
max f64
unit str
default_value f64
value_table str
}

AttributeValuedForObjectType {
Raw enum(AttributeValue)
NetworkNode enum(str-AttributeValue)
MessageDefinition enum(MessageId-Option[AttributeValue])
Signal enum(MessageId-str-AttributeValue)
EnvVariable enum(str-AttributeValue)
}

AttributeValue {
U64 enum(u64)
I64 enum(i64)
Double enum(f64)
String enum(str)
}

ValueTable {
name str
descriptions[] ValDescription(id(f64)-description(str))
}

ExtendedMultiplex {
message_id MessageId
signal_name str
multiplexor_signal_name str
mappings[] ExtendedMultiplexMapping(min_value(u64)-max_value(u64))
}

Comment {
Node enum(name(str)-comment(str))
Message enum(message_id(MessageId)-comment(str))
Signal enum(message_id(MessageId)-signal_name(str)-comment(str))
EnvVar enum(name(str)-comment(str))
Plain enum(comment(str))
}

Message {
id MessageId
name str
size u64
transmitter Transmitter[NodeName-VectorXXX]
signals[] Signal
}

EnvironmentVariable {
name str
typ EnvType[Float-U64-Data]
min i64
max i64
unit str
initial_value f64
ev_id i64
access_type AccessType[DummyNodeVector-0-1-2-3]
access_nodes[] AccessNode[VectorXXX-Name(String)]
}

AttributeDefinition {
Message enum(str)
Node enum(str)
Signal enum(str)
EnvironmentVariable enum(str)
Plain enum(str)
}

ValueDescription {
type str
message_id MessageId
name str
value_descriptions[] ValDescription(id(f64)-description(str))
}

SignalTypeRef {
message_id MessageId
signal_name str
signal_type_name str
}

SignalGroups {
message_id MessageId
name str
repetitions u64
signal_names[] str
}

SignalExtendedValueTypeList {
message_id MessageId
signal_name str
signal_extended_value_type SignalExtendedValueType[SignedOrUnsignedInteger-IEEEfloat32Bit-IEEEdouble64bit]
}

%% Relationships
DBC ||--o{ ValueTable : ""
DBC ||--o{ Message : ""
DBC ||--o{ MessageTransmitter : ""
DBC ||--o{ EnvironmentVariable : ""
DBC ||--o{ SignalType : ""
DBC ||--o{ Comment : ""
DBC ||--o{ AttributeDefinition : ""
DBC ||--o{ AttributeValue : ""
DBC ||--o{ AttributeValuedForObjectType : ""
DBC ||--o{ ValueDescription : ""
DBC ||--o{ SignalTypeRef : ""
DBC ||--o{ SignalGroups : ""
DBC ||--o{ SignalExtendedValueTypeList : ""
DBC ||--o{ ExtendedMultiplex : ""

Signal ||--|| MultiplexIndicator : ""

MessageTransmitter ||--|| MessageId : ""

Message ||--o{ Signal : ""
Message ||--|| MessageId : ""

ExtendedMultiplex ||--|| MessageId : ""

Comment ||--o| MessageId : ""

SignalExtendedValueTypeList ||--|| MessageId : ""

SignalTypeRef ||--|| MessageId : ""

SignalGroups ||--|| MessageId : ""

AttributeValuedForObjectType ||--o| MessageId : ""
AttributeValuedForObjectType ||--o| AttributeValue : ""
1 change: 1 addition & 0 deletions docs/diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ bless *args: (cargo-install 'cargo-insta')
build:
cargo build {{packages}} {{features}} {{targets}}

build-diagram:
@echo "Generating docs/diagram.svg using Mermaid CLI. Make sure you have it:"
@echo " npm install -g @mermaid-js/mermaid-cli"
mmdc -i docs/diagram.mmd -o docs/diagram.svg

# Quick compile without building a binary
check:
cargo check {{packages}} {{features}} {{targets}}
Expand Down
Loading