Skip to content

Commit

Permalink
CLEO Apply -> Fix bitrates wrongly labeled as Hz.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfm committed Feb 6, 2025
1 parent 58115a6 commit f1ff9af
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .ci/docker/edgar/configurations/peer_descriptor_leader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ spec:
name: vcan0
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7
- id: 850d6dff-8a98-430c-bfcb-fcba19d543be
name: vcan1
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7

topology:
Expand Down
8 changes: 4 additions & 4 deletions .ci/docker/edgar/configurations/peer_descriptor_peer-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ spec:
name: vcan0
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7
- id: 21f0b8f1-4297-466b-b210-c5dc22d22a76
name: vcan1
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7

topology:
Expand Down
8 changes: 4 additions & 4 deletions .ci/docker/edgar/configurations/peer_descriptor_peer-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ spec:
name: vcan0
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7
- id: 1aad3ce5-0e84-41c3-98b2-3e4055b4727d
name: vcan1
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7

topology:
Expand Down
8 changes: 4 additions & 4 deletions .ci/docker/edgar/configurations/peer_descriptor_peer-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ spec:
name: vcan0
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7
- id: fc47ccd8-0dfc-4eb6-a3de-aff43b88b568
name: vcan1
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7

topology:
Expand Down
8 changes: 4 additions & 4 deletions .ci/docker/edgar/configurations/peer_descriptor_peer-4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ spec:
name: vcan0
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7
- id: c65d46f8-e465-4632-92a5-87fd3e9e5204
name: vcan1
kind: can
parameters:
bitrate-hz: 500000
bitrate-kbps: 500
sample-point: 0.7
fd: false
data-bitrate-hz: 2000000
data-bitrate-kbps: 2000
data-sample-point: 0.7

topology:
Expand Down
4 changes: 2 additions & 2 deletions doc/src/user-manual/cleo/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ spec:
name: can0
kind: can
parameters:
bitrate-hz: 250000
bitrate-kbps: 250
sample-point: 0.8
fd: true
data-bitrate-hz: 500000
data-bitrate-kbps: 500
data-sample-point: 0.8
topology:
devices:
Expand Down
12 changes: 6 additions & 6 deletions opendut-cleo/src/commands/peer/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ fn convert_network_specification_to_descriptor(specification: NetworkInterfaceDe
match specification.parameters {
Some(parameters) => {
NetworkInterfaceConfiguration::Can {
bitrate: parameters.bitrate_hz,
bitrate: parameters.bitrate_kbps * 1000,
sample_point: CanSamplePoint::try_from(parameters.sample_point)
.map_err(|error| format!("Could not use the provided sample point parameter for network interface <{}>: {}", specification.id, error))?,
fd: parameters.fd,
data_bitrate: parameters.data_bitrate_hz,
data_bitrate: parameters.data_bitrate_kbps * 1000,
data_sample_point: CanSamplePoint::try_from(parameters.data_sample_point)
.map_err(|error| format!("Could not use the provided data sample point parameter for network interface <{}>: {}", specification.id, error))?,
}
Expand Down Expand Up @@ -274,23 +274,23 @@ mod tests {
kind: NetworkInterfaceKind::Can,
parameters: Some(
NetworkInterfaceConfigurationSpecification {
bitrate_hz: 500000,
bitrate_kbps: 500,
sample_point: 0.7,
fd: true,
data_bitrate_hz: 200000,
data_bitrate_kbps: 2000,
data_sample_point: 0.7,
}
),
};

let descriptor = NetworkInterfaceDescriptor {
id: NetworkInterfaceId::from(specification.id),
name: NetworkInterfaceName::try_from(specification.name.clone())?,
configuration: NetworkInterfaceConfiguration::Can {
bitrate: 500000,
sample_point: CanSamplePoint::try_from(0.7)?,
fd: true,
data_bitrate: 200000,
data_bitrate: 2000000,
data_sample_point: CanSamplePoint::try_from(0.7)?,
},
};
Expand Down
4 changes: 2 additions & 2 deletions opendut-types/src/specs/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ pub enum NetworkInterfaceKind {
#[derive(Debug, Deserialize)]
#[serde(rename_all="kebab-case")]
pub struct NetworkInterfaceConfigurationSpecification {
pub bitrate_hz: u32,
pub bitrate_kbps: u32,
pub sample_point: f32,
pub fd: bool,
pub data_bitrate_hz: u32,
pub data_bitrate_kbps: u32,
pub data_sample_point: f32,
}

Expand Down
5 changes: 5 additions & 0 deletions opendut-types/src/util/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ pub enum CanSamplePointError {
pub enum NetworkInterfaceConfiguration {
Ethernet,
Can {
/// CAN 2.0 Bitrate in Baud
bitrate: u32,
/// CAN 2.0 Sample Point between 0.0 and 1.0
sample_point: CanSamplePoint,
/// Whether CAN FD should be used
fd: bool,
/// CAN FD bitrate in Baud
data_bitrate: u32,
/// CAN FD Sample Point between 0.0 and 1.0
data_sample_point: CanSamplePoint,
},
}
Expand Down

0 comments on commit f1ff9af

Please sign in to comment.