Struct EthernetPhysicalChannel

Source
pub struct EthernetPhysicalChannel(/* private fields */);
Expand description

The EthernetPhysicalChannel represents a VLAN or untagged traffic

Implementations§

Source§

impl EthernetPhysicalChannel

Source

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);
Source

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);
Source

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
Source

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
Source

pub fn network_endpoints( &self, ) -> impl Iterator<Item = NetworkEndpoint> + Send + 'static

create an iterator over all NetworkEndpoints in this channel

§Example
for network_endpoint in channel.network_endpoints() {
    // ...
}
Source

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
Source

pub fn socket_addresses( &self, ) -> impl Iterator<Item = SocketAddress> + Send + 'static

create an iterator over all SocketAddresses 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);
Source

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)?;
Source

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.

Source

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.

StaticSocketConnections 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)?;
Source

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 if SocketConnectionBundles should be used instead of StaticSocketConnections. This is only relevant if the type can’t be detected automatically.
  • ipdu_identifier_set is contains the IPduIdentifiers that are used in StaticSocketConnections.

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)?;
Source

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

Source§

type CommunicationConnectorType = EthernetCommunicationConnector

the type of communication connector used by this physical channel
Source§

fn pdu_triggerings( &self, ) -> impl Iterator<Item = PduTriggering> + Send + 'static

iterate over all PduTriggerings of this physical channel
Source§

fn signal_triggerings( &self, ) -> impl Iterator<Item = ISignalTriggering> + Send + 'static

iterate over all ISignalTriggerings of this physical channel
Source§

fn connectors( &self, ) -> impl Iterator<Item = Self::CommunicationConnectorType> + Send + 'static

iterate over all connectors between this physical channel and any ECU Read more
Source§

fn ecu_connector( &self, ecu_instance: &EcuInstance, ) -> Option<Self::CommunicationConnectorType>

get the connector element between this channel and an ecu
Source§

impl AbstractionElement for EthernetPhysicalChannel

Source§

fn element(&self) -> &Element

Get the underlying Element from the abstraction element
Source§

impl Clone for EthernetPhysicalChannel

Source§

fn clone(&self) -> EthernetPhysicalChannel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EthernetPhysicalChannel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<EthernetPhysicalChannel> for Element

Source§

fn from(val: EthernetPhysicalChannel) -> Self

Converts to this type from the input type.
Source§

impl From<EthernetPhysicalChannel> for PhysicalChannel

Source§

fn from(channel: EthernetPhysicalChannel) -> Self

Converts to this type from the input type.
Source§

impl Hash for EthernetPhysicalChannel

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IdentifiableAbstractionElement for EthernetPhysicalChannel

Source§

fn name(&self) -> Option<String>

Get the item name of the element
Source§

fn set_name(&self, name: &str) -> Result<(), AutosarAbstractionError>

Set the item name of the element
Source§

impl PartialEq for EthernetPhysicalChannel

Source§

fn eq(&self, other: &EthernetPhysicalChannel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Element> for EthernetPhysicalChannel

Source§

type Error = AutosarAbstractionError

The type returned in the event of a conversion error.
Source§

fn try_from(element: Element) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for EthernetPhysicalChannel

Source§

impl StructuralPartialEq for EthernetPhysicalChannel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.