diff --git a/.ci/docker/edgar/configurations/peer_descriptor_leader.yaml b/.ci/docker/edgar/configurations/peer_descriptor_leader.yaml index 4dc1229b..a9e15019 100644 --- a/.ci/docker/edgar/configurations/peer_descriptor_leader.yaml +++ b/.ci/docker/edgar/configurations/peer_descriptor_leader.yaml @@ -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: diff --git a/.ci/docker/edgar/configurations/peer_descriptor_peer-1.yaml b/.ci/docker/edgar/configurations/peer_descriptor_peer-1.yaml index f055ae68..bb005fcd 100644 --- a/.ci/docker/edgar/configurations/peer_descriptor_peer-1.yaml +++ b/.ci/docker/edgar/configurations/peer_descriptor_peer-1.yaml @@ -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: diff --git a/.ci/docker/edgar/configurations/peer_descriptor_peer-2.yaml b/.ci/docker/edgar/configurations/peer_descriptor_peer-2.yaml index c08a1446..0d972bc4 100644 --- a/.ci/docker/edgar/configurations/peer_descriptor_peer-2.yaml +++ b/.ci/docker/edgar/configurations/peer_descriptor_peer-2.yaml @@ -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: diff --git a/.ci/docker/edgar/configurations/peer_descriptor_peer-3.yaml b/.ci/docker/edgar/configurations/peer_descriptor_peer-3.yaml index 82d753ab..0a2c84df 100644 --- a/.ci/docker/edgar/configurations/peer_descriptor_peer-3.yaml +++ b/.ci/docker/edgar/configurations/peer_descriptor_peer-3.yaml @@ -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: diff --git a/.ci/docker/edgar/configurations/peer_descriptor_peer-4.yaml b/.ci/docker/edgar/configurations/peer_descriptor_peer-4.yaml index a669657e..e3d32d10 100644 --- a/.ci/docker/edgar/configurations/peer_descriptor_peer-4.yaml +++ b/.ci/docker/edgar/configurations/peer_descriptor_peer-4.yaml @@ -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: diff --git a/doc/src/user-manual/cleo/commands.md b/doc/src/user-manual/cleo/commands.md index 650da766..3d12405b 100644 --- a/doc/src/user-manual/cleo/commands.md +++ b/doc/src/user-manual/cleo/commands.md @@ -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: diff --git a/opendut-cleo/src/commands/peer/apply.rs b/opendut-cleo/src/commands/peer/apply.rs index 08b7158b..59977311 100644 --- a/opendut-cleo/src/commands/peer/apply.rs +++ b/opendut-cleo/src/commands/peer/apply.rs @@ -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))?, } @@ -274,15 +274,15 @@ 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())?, @@ -290,7 +290,7 @@ mod tests { 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)?, }, }; diff --git a/opendut-types/src/specs/peer.rs b/opendut-types/src/specs/peer.rs index b918a9d5..4f14f9b4 100644 --- a/opendut-types/src/specs/peer.rs +++ b/opendut-types/src/specs/peer.rs @@ -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, } diff --git a/opendut-types/src/util/net.rs b/opendut-types/src/util/net.rs index e151b0ef..a876b947 100644 --- a/opendut-types/src/util/net.rs +++ b/opendut-types/src/util/net.rs @@ -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, }, }