# 10/17 Autosar
###### tags: `專題`
* 本週進度:閱讀 Specification of CAN Network Management(classic) 以及 尋找問題答案
## Specification of CAN Network Management(classic)
* AUTOSAR CAN Network Management's main purpose is to **coordinate the transition between normal operation and bus-sleep mode of the network**.
* AUTOSAR CAN Network Management provides **implement a service to detect all present nodes or to detect if all other nodes are ready to sleep**.
* Limitation:
* One channel of CanNm is associated with only one network management cluster in one network. One network management cluster can have only one channel of CanNm in one node * One channel of CanNm is associated with only one network within the same ECU.
* CAN Network Management (CanNm) mainly uses **services of CAN Interface** and provides services to the **Generic Network Management Interface**.
* **Coordination algorithm**
* The AUTOSAR CanNm is based on decentralized direct network management strategy (every network node performs activities self-sufficient)
* The AUTOSAR CanNm algorithm is based on periodic Network Management PDUs (via broadcast transmission)
* defined by two key-requirements:
1. Every network node in a CanNm cluster shall transmit periodic Network Management PDUs as long as it requires bus-communication; otherwise it shall transmit no Network Management PDUs.
2. If CanNmStayInPbsEnabled is disabled and bus communication in a CanNm cluster is released and there are no Network Management PDUs on the bus for a configurable amount of time determined by CanNmTimeoutTime + CanNmWaitBusSleepTime (both configuration parameters) transition into the Bus-Sleep Mode shall be performed.
* The AUTOSAR CanNm state machine shall contain states, transitions and triggers required for the AUTOSAR CanNm algorithm seen from point of view of one single node in the network management cluster.
* Operational Modes:
* **Network mode**:
* Repeat Message State ensures, that any transition from Bus-Sleep or Prepare Bus-Sleep to the Network Mode becomes visible to the other nodes on the network. Also, it ensures that any node stays active for a minimum amount of time. It can be used for detection of present nodes.
* Normal Operation State ensures that any node can keep the network management cluster awake as long as the network is requested.
* The Ready Sleep State ensures that any node in the network management cluster waits with transition to the Prepare Bus-Sleep Mode as long as any other node keep the network management cluster awake.
* The purpose of the **Bus-Sleep Mode** is to reduce power consumption in the node when no messages are to be exchanged.
* The purpose of the **Prepare Bus-Sleep Mode** is to ensure that all nodes have time to stop their network activity before the Bus-Sleep Mode is entered.
* In the Passive Mode the node is only receiving Network Management PDUs but not transmitting any Network Management PDUs.
* **Network states** denote, whether the software components need to communicate on the bus (the network state is then ‘requested’); or whether the software components don’t have to communicate on the bus (the bus network state is then ‘released’)
* Depending on configuration the CanNm will evaluate the **confirmation function** that a Network Management PDU has been successfully transmitted or not.
* **CanNm does not provide any service interfaces**
## NM interact with sm

* from nm to sm :
* Whenever (partial) networks are activated or deactivated from outside request and this set of (partial) networks is represented by a NetworkHandle in Machine Manifest Network Management will change the value of the corresponding NetworkHandle. State Management is notified about the change, because it has registered to all availabe NetworkHandle fields. When State Management recognizes a change in a fields value it sets the corresponding Function Group in the Function Group State where the NetworkHandle is configured for in the Machine Manifest.
* from sm to nm
* State Managements shall change the value of the NetworkHandle when a Function Group has to change its Function Group State and an associa- tion between this Function Group State and the Network handle is available in Machine Manifest. Network Management will recognize this change and will change the state of the (partial) networks accordingly to the NetworkHandle.
* So we can know that if we want to interact with sm, we need to implement register and
* [SWS_SM_00301]{DRAFT} NetworkHandle Registration ⌈State Management shall register for all NetworkHandles provided by Network Managements which are available from Machine Manifest.⌋
* what it the Machine Manifest ?
## How do we start the nm?
* In sm Specification, we can know that em will help sm to do some change work. So we can find these in Execution Management:
* Execution Management is responsible for all aspects of system execution management including platform initialization and startup / shutdown of Applications.
* However, Execution Management is responsible for initialization / configuration of the OS to enable it to perform the necessary run-time scheduling and resource manage- ment based on information extracted by Execution Management from the Machine Manifest and Execution Manifests.
* Applications are developed to resolve a set of coherent functional requirements. An Application consists of executable software units, additional execution related items (e.g. data or parameter files), and descriptive information used for integration and execution (e.g. a formal model description based on the AUTOSAR meta model, test cases, etc.).
* Although we can know that one of the duties in nm is "all aspects of system execution" but we can not see the detail about how does it "start" the nm.
* If we can check that application include ara or nm, and we can know that em can start up nm.
* <font color='dark'> ->> **Execution Management is responsible for initiating execution of the processes in all the Functional Clusters, Adaptive AUTOSAR Services, and user-level Applications** -> so we can know that em will start the nm and initiate it. </font>
* But we can find this in ManifestSpeciation
>[TPS_MANI_03166]{DRAFT} Machine-specific configuration settings for NM module ⌈The Machine-specific configuration settings for Nm are collected in NmIn- stantiation.⌋(RS_MANI_00023)
* initiation of nm
> [TPS_MANI_03166]{DRAFT} Machine-specific configuration settings for NM module ⌈The Machine-specific configuration settings for Nm are collected in NmIn- stantiation.⌋(RS_MANI_00023)
>
> [TPS_MANI_03226]{DRAFT} Collection of partialNetworks and VLANs in NmNet- workHandle ⌈The NmNetworkHandle element is used to describe a collection of partialNetworks and vlans that can be controlled collectively by the State Man- agement.⌋(RS_MANI_00023)
* The NM configuration options that will typically be set by an Integrator are collected in the NmInstantiation element.
* The NmConfig element is a wrapper that contains all network management specific configuration settings in the System model.
* 
* 