Skip to content
Open
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
52 changes: 36 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ exclude = ["codegen-tests/*", "data/*"]

[dependencies]
anyhow = "1"
can-dbc = "8.0.0"
can-dbc = "10.0.0"
embedded-can = "0.4"
prettyplease = "0.2"
prettyplease = "0.3"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
syn = { version = "3", features = ["full"] }
clap = { version = "4", features = ["derive"] }
heck = "0.5"
11 changes: 5 additions & 6 deletions src/ir/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::ir::signal::{MultiplexIndicator, Signal};
use crate::ir::{Identifier, MessageLayoutIdx, SignalIdx};
use can_dbc::MessageId as ParsedMessageId;
use can_dbc::Transmitter as ParsedTransmitter;
use std::collections::BTreeMap;

#[derive(Debug, Clone)]
Expand All @@ -21,7 +20,7 @@ impl Message {
id: ParsedMessageId,
name: String,
size: u64,
transmitter: ParsedTransmitter,
transmitter: Option<String>,
signals: Vec<SignalIdx>,
layout: MessageLayoutIdx,
comment: Option<String>,
Expand Down Expand Up @@ -92,11 +91,11 @@ pub enum Transmitter {
Node(Identifier),
VectorXXX,
}
impl From<ParsedTransmitter> for Transmitter {
fn from(value: ParsedTransmitter) -> Self {
impl From<Option<String>> for Transmitter {
fn from(value: Option<String>) -> Self {
match value {
ParsedTransmitter::NodeName(s) => Transmitter::Node(Identifier::from_raw(s)),
ParsedTransmitter::VectorXXX => Transmitter::VectorXXX,
Some(s) => Transmitter::Node(Identifier::from_raw(s)),
None => Transmitter::VectorXXX,
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/ir/signal_layout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use can_dbc::ByteOrder as ParsedByteOrder;
use can_dbc::NumericValue;
use can_dbc::Signal as ParsedSignal;
use can_dbc::ValueType as ParsedValueType;

Expand Down Expand Up @@ -30,14 +31,22 @@ impl From<&ParsedSignal> for SignalLayout {
value_type: ValueType::from(value.value_type),
factor: value.factor,
offset: value.offset,
min: value.min,
max: value.max,
min: numeric_value_to_float(value.min),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can change the types of min/max to NumericValue instead and perhaps simplify code elsewhere? Pretty sure there is some detection for int / float somewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started doing that, but can_dbc::NumericValue does not implement Hash. It probably should though... So the next steps to fix that looked like a rabbit hole... which I didn't want to go for a version bump :)

Feel free to close this if you prefer a proper solution.

max: numeric_value_to_float(value.max),
bitvec_start: 0,
bitvec_end: 0,
}
}
}

fn numeric_value_to_float(value: NumericValue) -> f64 {
match value {
NumericValue::Uint(v) => v as f64,
NumericValue::Int(v) => v as f64,
NumericValue::Double(v) => v,
}
}

use std::hash::{Hash, Hasher};

impl PartialEq for SignalLayout {
Expand Down