-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error generating multiplexed signals #42
Comments
As far as I know fractional |
This should be a valid message: BO_ 200 MultiplexTest: 8 SENSOR
SG_ Multiplexor M : 0|4@1+ (1,0) [0|2] "" Vector__XXX
SG_ UnmultiplexedSignal : 4|8@1+ (1,0) [0|4] "" Vector__XXX
- SG_ MultiplexedSignalZeroA m0 : 12|8@1+ (0.1,0) [0|3] "" Vector__XXX
+ SG_ MultiplexedSignalZeroA m0 : 12|8@1+ (1.0,0.0) [0.0|3.0] "" Vector__XXX
SG_ MultiplexedSignalZeroB m0 : 20|8@1+ (0.1,0) [0|3] "" Vector__XXX
- SG_ MultiplexedSignalOneA m1 : 12|8@1+ (0.1,0) [0|6] "" Vector__XXX
+ SG_ MultiplexedSignalOneA m1 : 12|8@1+ (1.0,0.0) [0.0|6.0] "" Vector__XXX
SG_ MultiplexedSignalOneB m1 : 20|8@1+ (0.1,0) [0|6] "" Vector__XXX But this is treated as
Here is a good overview about generated types: pub const MULTIPLEXOR_MIN: u8 = 0_u8;
pub const MULTIPLEXOR_MAX: u8 = 2_u8;
pub const UNMULTIPLEXED_SIGNAL_MIN: u8 = 0_u8;
pub const UNMULTIPLEXED_SIGNAL_MAX: u8 = 4_u8;
pub const MULTIPLEXED_SIGNAL_ZERO_A_MIN: u8 = 0_u8;
pub const MULTIPLEXED_SIGNAL_ZERO_A_MAX: u8 = 3_u8;
pub const MULTIPLEXED_SIGNAL_ZERO_B_MIN: f32 = 0_f32;
pub const MULTIPLEXED_SIGNAL_ZERO_B_MAX: f32 = 3_f32;
pub const MULTIPLEXED_SIGNAL_ONE_A_MIN: u8 = 0_u8;
pub const MULTIPLEXED_SIGNAL_ONE_A_MAX: u8 = 6_u8;
pub const MULTIPLEXED_SIGNAL_ONE_B_MIN: f32 = 0_f32;
pub const MULTIPLEXED_SIGNAL_ONE_B_MAX: f32 = 6_f32; |
Okay so parser always uses |
Original issue about floats came from such signal:
So this signal itself must be wrong, max cannot be |
However this seems to be a valid signal to define multiplexer
So it seems
https://github.com/technocreatives/dbc-codegen/blob/main/src/lib.rs#L550 |
I tried to fix it in code generation side, it is doable, however it seems that maybe it would be better to treat |
Yes I agree it's probably better to basically make sure multiplexor fns in this case |
Maybe just a fn signal_to_rust_type(signal: &Signal) -> String {
if signal.signal_size == 1 && *signal.multiplexer_indicator() != MultiplexIndicator::Multiplexor {
String::from("bool")
} else if signal_is_float_in_rust(signal) {
// If there is any scaling needed, go for float
String::from("f32")
} else {
signal_to_rust_int(signal)
}
} |
@marcelbuesing I tried multiplexed signal parsing on one of the opendbc files and got some errors.
Offending message: https://github.com/commaai/opendbc/blob/master/hyundai_kia_generic.dbc#L1061-L1080
There seems to be problem with floats:
Also barks about this signal: https://github.com/commaai/opendbc/blob/master/hyundai_kia_generic.dbc#L476
PS: this file also needs this patch: #41
The text was updated successfully, but these errors were encountered: