pub struct EthernetPhysicalChannel(/* private fields */);
Expand description
The EthernetPhysicalChannel
represents a VLAN or untagged traffic
Implementations§
Source§impl EthernetPhysicalChannel
impl EthernetPhysicalChannel
Sourcepub fn set_vlan_info(
&self,
vlan_info: Option<&EthernetVlanInfo>,
) -> Result<(), AutosarAbstractionError>
pub fn set_vlan_info( &self, vlan_info: Option<&EthernetVlanInfo>, ) -> Result<(), AutosarAbstractionError>
set the VLAN information for this channel
The supplied VLAN info must be unique - there cannot be two VLANs with the same vlan identifier. One channel may be created without VLAN information; it carries untagged traffic.
§Example
let vlan_info = EthernetVlanInfo {
vlan_name: "VLAN_2".to_string(),
vlan_id: 2,
};
channel.set_vlan_info(Some(&vlan_info))?;
let info = channel.vlan_info().unwrap();
assert_eq!(info.vlan_id, 2);
Sourcepub fn vlan_info(&self) -> Option<EthernetVlanInfo>
pub fn vlan_info(&self) -> Option<EthernetVlanInfo>
Retrieves the VLAN information from a channel
An ethernet physical channel that represents untagged traffic has no VLAN information and returns None.
§Example
let vlan_info = EthernetVlanInfo {
vlan_name: "VLAN_1".to_string(),
vlan_id: 1,
};
let channel = cluster.create_physical_channel("Channel", Some(&vlan_info))?;
let info = channel.vlan_info().unwrap();
assert_eq!(info.vlan_id, 1);
Sourcepub fn cluster(&self) -> Result<EthernetCluster, AutosarAbstractionError>
pub fn cluster(&self) -> Result<EthernetCluster, AutosarAbstractionError>
get the cluster containing this physical channel
§Example
let channel = cluster.create_physical_channel("Channel", None)?;
let cluster_2 = channel.cluster()?;
assert_eq!(cluster, cluster_2);
§Errors
AutosarAbstractionError::ModelError
An error occurred in the Autosar model
Sourcepub fn create_network_endpoint(
&self,
name: &str,
address: NetworkEndpointAddress,
ecu: Option<&EcuInstance>,
) -> Result<NetworkEndpoint, AutosarAbstractionError>
pub fn create_network_endpoint( &self, name: &str, address: NetworkEndpointAddress, ecu: Option<&EcuInstance>, ) -> Result<NetworkEndpoint, AutosarAbstractionError>
create a network endpoint - IPv4 or IPv6 address - for this channel
In older versions of the Autosar standard, up to version 4.4.0, the NetworkEndpoint
could be linked to an Ecu.
The parameter ecu
specifies the target.
The link is obsoleted in newer versions, and will only be created if the file version allows it.
§Example
let endpoint_address = NetworkEndpointAddress::IPv4 {
address: Some("192.168.0.1".to_string()),
address_source: Some(IPv4AddressSource::Fixed),
default_gateway: Some("192.168.0.2".to_string()),
network_mask: Some("255.255.255.0".to_string()),
};
let network_endpoint = channel.create_network_endpoint("Address1", endpoint_address, None)?;
§Errors
AutosarAbstractionError::ModelError
An error occurred in the Autosar model
Sourcepub fn network_endpoints(
&self,
) -> impl Iterator<Item = NetworkEndpoint> + Send + 'static
pub fn network_endpoints( &self, ) -> impl Iterator<Item = NetworkEndpoint> + Send + 'static
create an iterator over all NetworkEndpoint
s in this channel
§Example
for network_endpoint in channel.network_endpoints() {
// ...
}
Sourcepub fn create_socket_address(
&self,
name: &str,
network_endpoint: &NetworkEndpoint,
tp_config: &TpConfig,
sa_type: SocketAddressType,
) -> Result<SocketAddress, AutosarAbstractionError>
pub fn create_socket_address( &self, name: &str, network_endpoint: &NetworkEndpoint, tp_config: &TpConfig, sa_type: SocketAddressType, ) -> Result<SocketAddress, AutosarAbstractionError>
create a socket address in the ethernet channel
It contains the settings of the TCP/UDP port and links to a NetworkEndpoint
which contains the IP address.
The socket address can either be a unicast adress which is associated with a single ECU, or a multicast address
§Example
let tcp_port = TpConfig::TcpTp {
port_number: Some(1234),
port_dynamically_assigned: None,
};
let socket_type = SocketAddressType::Unicast(Some(ecu_instance));
channel.create_socket_address("SocketName", &network_endpoint, &tcp_port, socket_type)?;
§Errors
AutosarAbstractionError::InvalidParameter
sa_type
contains a reference to anEcuInstance
which is not connected to this channelAutosarAbstractionError::ModelError
An error occurred in the Autosar model
Sourcepub fn socket_addresses(
&self,
) -> impl Iterator<Item = SocketAddress> + Send + 'static
pub fn socket_addresses( &self, ) -> impl Iterator<Item = SocketAddress> + Send + 'static
create an iterator over all SocketAddress
es in this channel
§Example
let tcp_port = TpConfig::TcpTp {
port_number: Some(1234),
port_dynamically_assigned: None,
};
let socket_type = SocketAddressType::Unicast(Some(ecu_instance));
channel.create_socket_address("SocketName", &network_endpoint, &tcp_port, socket_type)?;
assert_eq!(channel.socket_addresses().count(), 1);
Sourcepub fn create_socket_connection_bundle(
&self,
name: &str,
server_port: &SocketAddress,
) -> Result<SocketConnectionBundle, AutosarAbstractionError>
pub fn create_socket_connection_bundle( &self, name: &str, server_port: &SocketAddress, ) -> Result<SocketConnectionBundle, AutosarAbstractionError>
create a socket connection bundle
The SocketConnectionBundle
is the “old” way to establish a connection between two sockets.
It is deprecated in newer versions of the Autosar standard, but remains available for compatibility.
§Example
let bundle = channel.create_socket_connection_bundle("Bundle", &server_socket)?;
Sourcepub fn socket_connection_bundles(
&self,
) -> impl Iterator<Item = SocketConnectionBundle> + Send + 'static
pub fn socket_connection_bundles( &self, ) -> impl Iterator<Item = SocketConnectionBundle> + Send + 'static
iterate over all socket connection bundles in this channel
The SocketConnectionBundle
is the “old” way to establish a connection between two sockets.
It is deprecated in newer versions of the Autosar standard, but remains available for compatibility.
Sourcepub fn create_static_socket_connection_pair(
&self,
name: &str,
port_1: &SocketAddress,
port_2: &SocketAddress,
tcp_connect_timeout: Option<f64>,
) -> Result<(StaticSocketConnection, StaticSocketConnection), AutosarAbstractionError>
pub fn create_static_socket_connection_pair( &self, name: &str, port_1: &SocketAddress, port_2: &SocketAddress, tcp_connect_timeout: Option<f64>, ) -> Result<(StaticSocketConnection, StaticSocketConnection), AutosarAbstractionError>
create a pair of static socket connections
Static socket connections are usually created as a pair, one on each socket involved on the connection.
This helper function creates both at once. To create a single connection, use SocketAddress::create_static_socket_connection
.
If the connection is a TCP connection, the first port connects to the second port, and the second port listens for incoming connection.
The ordering of port_1
and port_2
has no impact on the direction of the transported PDUs. This is defined in the PduTriggering
.
StaticSocketConnection
s are the “new” way to establish a connection between two sockets.
It was introduced in Autosar 4.5.0 (AUTOSAR_00048
) and is the recommended way to create connections.
SocketConnectionBundles
(old) and StaticSocketConnections
(new) may never be used in the same file.
§Example
let (connection_a, connection_b) = channel.create_static_socket_connection_pair("Connection", &server_socket, &client_socket, None)?;
Sourcepub fn configure_service_discovery_for_ecu(
&self,
ecu: &EcuInstance,
unicast_socket: &SocketAddress,
unicast_rx_pdu: &GeneralPurposePdu,
unicast_tx_pdu: &GeneralPurposePdu,
common_config: &CommonServiceDiscoveryConfig<'_>,
) -> Result<(), AutosarAbstractionError>
pub fn configure_service_discovery_for_ecu( &self, ecu: &EcuInstance, unicast_socket: &SocketAddress, unicast_rx_pdu: &GeneralPurposePdu, unicast_tx_pdu: &GeneralPurposePdu, common_config: &CommonServiceDiscoveryConfig<'_>, ) -> Result<(), AutosarAbstractionError>
configure SOME/IP service discovery (SD) for an ECU connected to this channel
SD is used to broadcast service offers on the network and subscribe to services offered by other ECUs. This function configures the ECU to use the SOME/IP SD protocol.
SD uses either socket connection bundles or static socket connections to communicate.
ecu
is the ECU that should be configured for SD.
unicast_socket
is the socket address used for unicast rx/tx communication by the ECU.
unicast_rx_pdu
and unicast_tx_pdu
are the GeneralPurposePdus
used for the unicast communication.
common_config
contains common configuration settings that can be used for all SD ECUs.
multicast_rx_socket
is the socket address used for multicast communication by all SD ECUs.remote_socket
is a socket whose IP is set to ANY with UDP port 0, acting as the remote address in the SD communication.name_prefix
is an optional prefix for the names of the created elements.prefer_static_socket_connections
is a flag that determines ifSocketConnectionBundles
should be used instead ofStaticSocketConnections
. This is only relevant if the type can’t be detected automatically.ipdu_identifier_set
is contains theIPduIdentifiers
that are used inStaticSocketConnections
.
Note:
Usually SomeIP
SD is expected to use port 30490, but this is not mandatory.
The port number is set in the sockets, and must be the same for all SD sockets.
§Example
let unicast_endpoint = channel.create_network_endpoint("UnicastEndpoint", NetworkEndpointAddress::IPv4 {
address: Some("192.168.0.1".to_string()),
address_source: Some(IPv4AddressSource::Fixed),
default_gateway: None,
network_mask: None
}, None)?;
let unicast_socket = channel.create_socket_address("UnicastSocket", &unicast_endpoint, &TpConfig::UdpTp {
port_number: Some(30490),
port_dynamically_assigned: None
}, SocketAddressType::Unicast(Some(ecu_instance.clone())))?;
let multicast_rx_endpoint = channel.create_network_endpoint("MulticastEndpoint", NetworkEndpointAddress::IPv4 {
address: Some("239.0.0.1".to_string()),
address_source: Some(IPv4AddressSource::Fixed),
default_gateway: None,
network_mask: None
}, None)?;
let multicast_rx_socket = channel.create_socket_address("MulticastSocket", &multicast_rx_endpoint, &TpConfig::UdpTp {
port_number: Some(30490),
port_dynamically_assigned: None
}, SocketAddressType::Multicast(vec![ecu_instance.clone()]))?;
let remote_endpoint = channel.create_network_endpoint("RemoteEndpoint", NetworkEndpointAddress::IPv4 {
address: Some("ANY".to_string()),
address_source: None,
default_gateway: None,
network_mask: None
}, None)?;
let remote_socket = channel.create_socket_address("RemoteSocket", &remote_endpoint, &TpConfig::UdpTp {
port_number: Some(0),
port_dynamically_assigned: None
}, SocketAddressType::Unicast(None))?;
let unicast_rx_pdu = system.create_general_purpose_pdu("UnicastRxPdu", &package, 0, GeneralPurposePduCategory::Sd)?;
let unicast_tx_pdu = system.create_general_purpose_pdu("UnicastTxPdu", &package, 0, GeneralPurposePduCategory::Sd)?;
let multicast_rx_pdu = system.create_general_purpose_pdu("MulticastRxPdu", &package, 0, GeneralPurposePduCategory::Sd)?;
let common_config = CommonServiceDiscoveryConfig {
multicast_rx_socket: &multicast_rx_socket,
multicast_rx_pdu: &multicast_rx_pdu,
remote_socket: &remote_socket,
name_prefix: None,
prefer_static_socket_connections: false,
ipdu_identifier_set: None,
};
channel.configure_service_discovery_for_ecu(&ecu_instance, &unicast_socket, &unicast_rx_pdu, &unicast_tx_pdu, &common_config)?;
Sourcepub fn has_socket_connections(&self) -> bool
pub fn has_socket_connections(&self) -> bool
check if the channel contains any SocketConnectionBundles
(old) or SocketConnections
(very old)
Trait Implementations§
Source§impl AbstractPhysicalChannel for EthernetPhysicalChannel
impl AbstractPhysicalChannel for EthernetPhysicalChannel
Source§type CommunicationConnectorType = EthernetCommunicationConnector
type CommunicationConnectorType = EthernetCommunicationConnector
Source§fn pdu_triggerings(
&self,
) -> impl Iterator<Item = PduTriggering> + Send + 'static
fn pdu_triggerings( &self, ) -> impl Iterator<Item = PduTriggering> + Send + 'static
PduTriggerings
of this physical channelSource§fn signal_triggerings(
&self,
) -> impl Iterator<Item = ISignalTriggering> + Send + 'static
fn signal_triggerings( &self, ) -> impl Iterator<Item = ISignalTriggering> + Send + 'static
ISignalTriggerings
of this physical channelSource§fn connectors(
&self,
) -> impl Iterator<Item = Self::CommunicationConnectorType> + Send + 'static
fn connectors( &self, ) -> impl Iterator<Item = Self::CommunicationConnectorType> + Send + 'static
Source§fn ecu_connector(
&self,
ecu_instance: &EcuInstance,
) -> Option<Self::CommunicationConnectorType>
fn ecu_connector( &self, ecu_instance: &EcuInstance, ) -> Option<Self::CommunicationConnectorType>
Source§impl Clone for EthernetPhysicalChannel
impl Clone for EthernetPhysicalChannel
Source§fn clone(&self) -> EthernetPhysicalChannel
fn clone(&self) -> EthernetPhysicalChannel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for EthernetPhysicalChannel
impl Debug for EthernetPhysicalChannel
Source§impl From<EthernetPhysicalChannel> for Element
impl From<EthernetPhysicalChannel> for Element
Source§fn from(val: EthernetPhysicalChannel) -> Self
fn from(val: EthernetPhysicalChannel) -> Self
Source§impl From<EthernetPhysicalChannel> for PhysicalChannel
impl From<EthernetPhysicalChannel> for PhysicalChannel
Source§fn from(channel: EthernetPhysicalChannel) -> Self
fn from(channel: EthernetPhysicalChannel) -> Self
Source§impl Hash for EthernetPhysicalChannel
impl Hash for EthernetPhysicalChannel
Source§impl PartialEq for EthernetPhysicalChannel
impl PartialEq for EthernetPhysicalChannel
Source§impl TryFrom<Element> for EthernetPhysicalChannel
impl TryFrom<Element> for EthernetPhysicalChannel
impl Eq for EthernetPhysicalChannel
impl StructuralPartialEq for EthernetPhysicalChannel
Auto Trait Implementations§
impl Freeze for EthernetPhysicalChannel
impl !RefUnwindSafe for EthernetPhysicalChannel
impl Send for EthernetPhysicalChannel
impl Sync for EthernetPhysicalChannel
impl Unpin for EthernetPhysicalChannel
impl !UnwindSafe for EthernetPhysicalChannel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.