[AUTOSAR] [Can Communication] CanNM

Table of contents

I. Overview

2. Description

3. Function description

3.1 Coordination Algorithm

3.2 Operating modes

3.2.1 Network mode

3.2.2 Prepare for bus sleep mode

3.2.3 Bus sleep mode

3.3 Network Status

3.4 Initialization

3.5 parameters

3.6 Network Management PDU Structure

3.7 Communication Scheduling

3.7.1 Send

3.7.2 Receive

3.8 Other functions

3.8.1 Detection of Remote Sleep Indicator

3.8.2 User data

3.8.3 Passive mode

3.8.4 Network management PDU Rx indication

3.8.5 Status Change Notification

3.8.6 Communication Control

3.8.7 Coordinator's support for synchronization function

3.9 UML state diagram

4. API interface

4.1 API definition

4.2 Notification function

4.3 Scheduling functions


I. Overview

        This document describes the concept, core functionality, configurable features, interfaces and configuration issues of AUTOSAR CAN Network Management (CanNm).

        AUTOSAR CAN network management is a hardware-independent protocol that can only be used on CAN. Its main purpose is to coordinate the transition of the network between normal operation and bus sleep mode. In addition to the core functionality, configurable functionality is provided, such as implementing a service that detects all current nodes or detects whether all other nodes are ready to sleep.

        The CAN Network Management (CanNm) function provides self-adaptation between the Network Management Interface (NmIf) and CAN Interface (CanIf) modules.

2. Description

(1) One channel of CanNm is only associated with one network management cluster in one network. A network management cluster can only have one CanNm channel in one node.

(2) One channel of CanNm is only associated with one network within the same ECU.

(3) CanNm is only applicable to CAN system.

3. Function description

3.1 Coordination Algorithm

        AUTOSAR CanNm is based on a decentralized direct network management strategy, which means that each network node performs self-sufficient activities only according to the network management pdus received or transmitted within the communication system.

        The CanNm algorithm is based on periodic network management pdus, which are received by all nodes in the cluster through broadcast transmissions. Receipt of the Network Management PDU indicates that the sending node wishes to keep the Network Management Cluster awake. If any node is ready to enter bus-sleep mode, it will stop sending network management PDUs, but it will delay the transition to bus-sleep mode as long as it receives network management PDUs from other nodes. Finally, each node initiates a transition to bus-sleep mode if a dedicated timer elapses because it is no longer receiving network management PDUs.

        If any node in the network management cluster needs bus communication, it can wake up the network management cluster from bus-sleep mode by transmitting the network management PDU.

[Specification] As long as each network node in the CanNm cluster needs bus communication, it should transmit network management PDU regularly, otherwise it should not transmit network management PDU.

[Specification] If the CanNm state is disabled, and the bus communication in the CanNm cluster, and the bus transitions to the bus sleep mode according to CanNmTimeoutTime + CanNmWaitBusSleepTime.

[Specification] The CanNm state machine shall contain the states, transitions and triggers required by the AUTOSAR CanNm algorithm from the perspective of a single node in the network management cluster.

3.2 Operating modes

[Specifications] CanNm includes three operating modes visible on the module interface:

  • Network Mode
  • Prepare Bus-Sleep Mode
  • Bus-Sleep Mode

[Specification] Changes in the operating mode should be notified to the upper layer through the callback function.

[Specification] When calling CanNm_GetState, CanNm will return the current NM state and mode.

3.2.1 Network mode

[Specification] The network model should include three internal states:

  • Repeat Message State
  • Normal Operation State
  • Ready Sleep State

[Specification] When entering the network mode from the bus sleep state, the CanNm module should enter the repeat message state by default.

[Specification] When entering the network mode from the prepare bus sleep mode, the CanNm module should enter the repeat message state by default.

[Specification] When entering the network mode, the CanNm module should start the NM-Timeout timer.

[Specification] When entering the network mode, CanNm should notify the upper layer of the new current operating mode by calling the callback function Nm_NetworkMode.

[Specification] When successfully receiving a network management PDU (calling CanNm_RxIndication) in network mode, if the PDU transmission capability is enabled, the CanNm module should restart the NM-Timeout timer.

[Specification] When the network management PDU is successfully transmitted in network mode (CanNm_TxConfirmation is called with E_OK), the CanNm module should restart the NM-Timeout timer.

Remark: If CanNmImmediateTxConfEnabled is enabled, it is assumed that every Network Management PDU transmission request will result in a successful Network Management PDU transmission.

[Specification] The CAN NM module should reset the NM-Timeout timer every time it starts or restarts.

[Specification] If CanNm_PassiveStartUp is called in network mode, CanNm module does not execute this service and returns E_NOT_OK.

(1)Repeat Message State

For nodes that are not in passive mode, the repeated message state ensures that any transition from bus-sleep or ready-to-bus-sleep to network mode is visible to other nodes on the network. Additionally, it ensures that any node remains active for the shortest amount of time. It can be used for detection of existing nodes.

[Specification] When entering the repeated message state, the CanNm module should (re)initiate the transmission of the network management pdu, unless the passive mode is enabled and/or the communication is disabled.

[Specification] When the NM-Timeout timer times out in the repeated message state, the CanNm module should (re)start the NM-Timeout timer.

[Specification] When the NM-Timeout time timer expires in the repeated message state, the CanNm module shall report CANNM_E_NETWORK_TIMEOUT to DET.

[Specification] The network management state machine should remain in the repeat message state for a configurable time determined by CanNmRepeatMessageTime (configuration parameter), after which the CanNm module should leave the repeat message state.

[Specification] When the repeated message state is left, the CanNm module should enter the normal operation state if the network has been requested.

[Specification] When the "repeat message state", if the network has been released, the CanNm module should enter the ready dormancy state.

[Specification] If CanNmNodeDetectionEnabled is set to TRUE, CanNm shall clear the duplicate message bit when leaving the duplicate message state.

[Specification] If the service CanNm_RepeatMessageRequest is called in the repeat message state, prepare for bus sleep mode or bus sleep mode, the CanNm module must not execute the service and return E_NOT_OK.

【specification】

(2)Normal Operation State

The "healthy state" ensures that, as long as the network is requested, any node can keep the network management cluster awake.

[Specification] When entering the normal operation state from the standby sleep state, the CanNm module should start the transmission of the network management pdu.

Note: If passive mode is enabled or the Network Management PDU transmission capability is disabled, no NMPDUs are transmitted, so no action is required.

[Specification] When the NM-Timeout timer times out in normal operation, the CanNm module should (re)start the NM-Timeout timer.

[Specification] CanNm module shall report CANNM_E_NETWORK_TIMEOUT to DET when NM-Timeout expires in normal operation state.

[Specification] When the network is released and the current state is normal operation, the CanNm module should enter the sleep state.

[Specification] If CanNmNodeDetectionEnabled is set to TRUE, and the duplicate message request bit is received in the normal operation state, the CanNm module shall enter the duplicate message status.

[Specification] If the CanNm_RepeatMessageRequest detection is enabled is set to TRUE, and the function CanNm_RepeatMessageRequest is called in the normal operation state, the CanNm module should enter the repeat message state.

[Specification] If CanNmNodeDetectionEnabled is set to TRUE, and the function CanNm_RepeatMessageRequest is called in the normal operation state, the CanNm module shall set the repeat message bit.

(3)Ready Sleep State

The ready sleep state ensures that any node in the network management cluster waits to transition to the ready bus sleep mode, as long as any other node keeps the network management cluster asleep.

[Specification] When entering the ready dormancy state from the repeated message state or the normal operation state, the CanNm module should stop the transmission of the network management pdu.

Note: If passive mode is enabled, NMpdu is not transmitted, so no action is required.

Remark: If passive mode is disabled in some cases, NMpdu must transmit in ready sleep state to allow synchronous shutdown in the network, e.g. retransmitting PN shutdown messages.

[Specification] When the NM-Timeout timer expires in the ready sleep state, the CanNm module shall enter the ready bus sleep mode.

[Specification] When the network is requested and the current state is ready to sleep, the CanNm module should enter the normal operating state.

[Specification] If CanNmNodeDetectionEnabled is set to TRUE, and the repeat message request bit is received in the ready-to-sleep state, the CanNm module should enter the repeat message state.

[Specification] If the CanNm_RepeatMessageRequest detection is enabled is set to TRUE, and the function CanNm_RepeatMessageRequest is called in the ready-to-sleep state, the CanNm module should enter the repeat message state.

[Specification] If CanNmNodeDetectionEnabled is set to TRUE and the function CanNm_RepeatMessageRequest is in the ready sleep state, the CanNm module should set the repeat message bit.

3.2.2 Prepare for bus sleep mode

The purpose of preparing for bus-sleep mode is to ensure that all nodes have time to cease their network activity before entering bus-sleep mode. In prepare-bus-sleep mode, bus activity quiets down (i.e. transmits queued messages to empty all Tx buffers), and finally in prepare-bus-sleep mode, there is no activity on the bus.

[Specification] When entering the prepare bus-sleep mode, the CanNm module should notify the upper layer by calling Nm_PrepareBusSleepMode.

[Specification] If CanNmStayInPbsEnabled is disabled, it should stay in bus sleep mode after CanNmWaitBusSleepTime (configuration parameter) and enter bus sleep mode.

[Specification] When the network management PDU is successfully received in the prepare bus sleep mode, the CanNm module should enter the network mode; by default, the CanNm module should enter the repeat message state.

[Specification] When the network is requested in the prepare bus sleep mode, the CanNm module should enter the network mode; by default, the CanNm module should enter the repeated message state.

[Specification] When the network is requested in the ready bus sleep mode, the CanNm module has entered the network mode, if CanNmImmediateRestartEnabled (configuration parameter) is set to TRUE, the CanNm module shall transmit the network management PDU.

3.2.3 Bus sleep mode

The purpose of the bus sleep mode is to reduce the power consumption of the nodes when messages are not being exchanged. The communication controller is switched to sleep mode, the respective wake-up mechanism is activated, and finally the power consumption is reduced to a sufficient level in bus-sleep mode.

[Specification] When entering the bus sleep mode, in addition to the default conditions during initialization, the CanNm module should notify the upper layer by calling the callback function Nm_BusSleepMode.

[Specification] When the CanNm module successfully receives a network management PDU (CanNm_RxIndication call) in the bus sleep mode, the CanNm module should notify the upper layer by calling the callback function Nm_NetworkStartIndication.

[Specification] When the CanNm module successfully receives the network management PDU (the call of CanNm_RxIndication) in the bus sleep mode, the CanNm module should report the error CANNM_E_NET_START_IND to DET.

[Specification] If CanNm_PassiveStartUp is called in bus sleep mode or ready bus sleep mode, the CanNm module should enter the network mode; by default, the CanNm module should enter the repeated message state.

[Specification] When requesting the network in the bus sleep mode, the CanNm module should enter the network mode, and the default CanNm module should enter the repeated message state.

3.3 Network Status

[Specification] The function call CanNm_NetworkRequest should request the network. That is, the CanNm module will change the network status to "requested".

[Specification] The function call CanNm_NetworkRelease will release the network. That is, the CanNm module will change the network status to "released".

3.4 Initialization

[Specification] If the initialization of the CanNm module (CanNm_Init) is successful, the CanNm module should set the network management status to bus sleep mode.

[Specification] When initialized, by default, the CanNm module should set the network status to "released"

[Specification] When initializing, the CanNm module should enter the bus sleep mode by default.

[Specification] The function CanNm_Init should pass a configuration pointer parameter to select the active configuration set.

[Specification] If CanNmGlobalPnSupport is set to TRUE, and CanNm is initialized (CanNm_Init is called), CanNm will stop the NM message Tx timeout timer.

[Specification] During initialization, the CanNm module should disable bus load reduction.

[Specification] After initialization, the CanNm module should stop the transmission of the network management pdu by stopping the message cycle timer.

[Specification] During initialization, the CanNm module should set each byte of user data to 0xFF.

[Specification] During initialization, the CanNm module should set the control bit vector to 0x00.

3.5 parameters

[Specification] The AUTOSAR CanNm algorithm should be processor independent, which means; it must not depend on any processor-specific hardware support, so it should be implementable on any processor architecture within the automatic memory range.

[Specification] Configure the time parameter network timeout NM-Timeout.

[Specification] Configure the time parameter Repeat Message Time.

[Specification] Configure the time parameter Wait Bus-Sleep Time.

[Specification] Configure the time parameter Remote Sleep Indication Time.

3.6 Network Management PDU Structure

The format of the network management PDU, for example 8 bytes, where the source node identifier (SNI) is in the first byte, the control bit vector (CBV) is in the second byte, uses user data, and enables part of the network. The user data range is between the system bytes and the PNC bit vector:

[Specification] The position of the source node identifier should be configured as byte 0, byte 1 or off by CanNmPduN position.

[Specification] The position of the control bit vector should be configurable through the computer to locate byte 0, byte 1 or close.

[Specification] The remaining bytes not allocated to Nm system bytes or PNC bit vectors shall be available for user data.

Format of the control bit vector:

The control bit vector should include:

  • Bit 0: Repeat message request bit
    • 0: Duplicate message status not requested
    • 1: Request to repeat message status
  • Bit 1: PN shutdown request bit (PNSR)
    • 0: NM message does not contain a synchronous partial network shutdown request
    • 1: The NM message does not contain a synchronized partial network shutdown request of at least one PNC
  • Bit 3: NM Coordinator Sleep Bit
    • 0: The master coordinator does not request to start a synchronous shutdown
    • 1: The master coordinator requests to start a synchronous shutdown
  • Bit 4: Active wake-up bit
    • 0: The node does not wake up the network (passive wakeup)
    • 1: The node has woken up the network (active wakeup)
  • Bit 5: Part Network Learning Bit (PNL)
    • 0: Do not request PNC learning
    • 1: Request PNC learning
  • Bit 6: Partial Network Information bit (PNI)
    • 0: NM PDU does not contain part of the network request information
    • 1: NM PDU does not contain part of the network request information
  • Bit 2 and Bit 7 are reserved for future expansion

[Specification] The CanNm module should set the source node identifier with the configuration parameter CanNmNodeId, unless the CanNmPduNid position is set to off.

[Specification] If CanNm changes state from bus sleep mode or ready bus sleep mode to network mode due to calling CanNm_NetworkRequest (i.e. due to active wakeup), and CanNmActiveWakeupBitEnabled is TRUE, CanNm shall set active VSWR bit in CBV.

[Specification] If the CanNm module leaves the network mode and CanNmActiveWakeupBitEnabled is TRUE, the CanNm module should clear the active wakeup bit in the CBV.

3.7 Communication Scheduling

3.7.1 Send

[Specification] The network management pdu transmission capability should be configured through the network CanNmPassiveModeEnabled.

[Specification] CanNm module should provide regular transmission mode. In this transfer mode, the CanNm module should periodically send network management pdus.

[Specification] The CanNm module shall optionally provide a periodic transfer mode with bus load reduction. In this transmission mode, the CanNm module should transmit network management pdus according to a specific algorithm.

[Specification] The immediate transmission confirmation mechanism should be configurable through CanNmImmediateTxConfEnabled.

[Specification] If the duplicate message status not entered through CanNm_NetworkRequest or CanNmImmediateNmTransmissions is zero, CanNmMsg CanNmImmediateNmTransmissions shall delay the transmission of NM PDUs after entering the duplicate message status.

[Specification] When entering the repeated message state from bus sleep mode or ready bus sleep mode due to CanNm_NetworkRequest() (active wakeup), if CanNmImmediateNmTransmissions is greater than zero, CanNm_NetworkRequest() should be sent immediately using CanNm_NetworkRequest() as the cycle time. The transmission of the first NM PDU shall be triggered as soon as possible. After transmission, the message cycle timer should be reloaded. Not applicable in this case.

[Specification] If entering the normal operation state from the ready sleep state, the transmission of the NMPDU should be started immediately.

[Specification] If CanNmPnHandleMultipleNetworkRequests is set to TRUE, CanNm_NetworkRequest will trigger a state transition from network mode to repeated message state. If the PDU transmission capability is enabled, the NMPDU shall be transmitted immediately using the computer network Nm cycle time as the cycle time. The transmission of the first NM PDU shall be triggered as soon as possible. After transmission, the message cycle timer should be reloaded. Not applicable in this case.

[Specification] If the NMPDU transmits an immediate transmission time, it should ensure that this timed CanNmImmediateNmTransmissions (including the first immediate transmission) is successfully requested. If the transfer request to CanIf fails (returns E_NOT_OK), CanNm will retry the transfer request in the next main function. CanNm will then continue to transmit the NMpdu using the CanNmMsg cycle time.

[Specification] If the CanNm message cycle timer expires, the CanNm module will restart with the CanNm message cycle time.

[Specification] If the transmission of the network management pdu has stopped, the CanNm module should cancel the message cycle timer.

3.7.2 Receive

If the NM PDU has been successfully received, the CanIf module will call the callback function CanNm_RxIndication.

[Specification] When the callback function CanNm_RxIndication is called, the CanNm module should copy the data of the network management PDU referenced in the function parameter to an internal buffer.

3.8 Other functions

3.8.1 Detection of Remote Sleep Indicator

A "remote sleep indication" indicates a situation where a node in normal operation sees that all other nodes in the cluster are ready to sleep (in read state). Nodes that are in a healthy state will still keep the bus awake.

3.8.2 User data

If userdata is configured, it will be sent affirmatively in the repeated message state. In normal operation, whether or not user data is sent depends on the configuration of the bus load reduction. In the ready sleep state, no user data will be sent.

3.8.3 Passive mode

In passive mode, the node only receives network management PDUs and does not transmit any network management PDUs.

3.8.4 Network management PDU Rx indication

When calling the callback function CanNm_RxIndication, the CanNm module should call the Nm callback function Nm_PduRxIndication if and only if CanNmPduRxIndicationEnabled (configuration parameter) is set to TRUE.

3.8.5 Status Change Notification

If the callback Nm_StateChangeNotification is enabled (configuration parameter CanNmStateChangeIndEnabled is TRUE), all changes of the automatic memory CanNm state shall be notified to the upper layer by calling Nm_StateChangeNotification.

3.8.6 Communication Control

[Specification] If CanNm_DisableCommunication is served, the CanNm module shall disable the network management PDU transmission capability.

3.8.7 Coordinator's support for synchronization function

A special bit in the CBV of the Nm coordinator sleep ready bit is used to indicate to the master coordinator to request initiation of a shutdown sequence when there are multiple coordinators connected to the same bus. The main functions of the algorithm are described in the Nm module.

3.9 UML state diagram

The following image shows the UML state diagram in relation to API specification. Transitions related to mode changes are shown in green, those related to error handling are shown in red, and those related to optional node detection/dynamic pnc-to-channel mapping are shown in blue.

4. API interface

4.1 API definition

  1. CanNm_Init
  2. CanNm_DeInit
  3. CanNm_PassiveStartUp - Passive wake-up start network CAN NM
  4. CanNm_NetworkRequest - request network, because ECU needs to communicate on the bus.
  5. CanNm_NetworkRelease - Releases the network, since the ECU does not need to communicate on the bus.
  6. CanNm_DisableCommunication - Disable NM PDU transmission capability
  7. CanNm_EnableCommunication - enable NM PDU transmission capability
  8. CanNm_SetUserData - set user data for the network element pdu to be transmitted next time on the bus
  9. CanNm_GetUserData - Get user data from the most recently received network MPDU.
  10. CanNm_Transmit - request to transmit a PDU.
  11. CanNm_GetNodeIdentifier - Get the node identifier from the most recently received NM PDU.
  12. CanNm_GetLocalNodeIdentifier - Get the node identifier configured for the local node.
  13. CanNm_RepeatMessageRequest - Sets the repeat message request bit for the next NMPDU transmitted on the bus.
  14. CanNm_GetPduData - Get the entire PDU data from the most recently received NM PDU.
  15. CanNm_GetState - Returns the state and mode of network management.
  16. CanNm_GetVersionInfo
  17. CanNm_RequestBusSynchronization - request bus synchronization.
  18. CanNm_CheckRemoteSleepIndication - Check if a remote sleep indication has occurred.
  19. CanNm_SetSleepReadyBit - Sets the NM coordinator sleep ready bit in the control bit vector

4.2 Notification function

  1. CanNm_TxConfirmation - The lower layer communication interface module confirms the transmission of the PDU, or the transmission of the PDU fails.
  2. CanNm_RxIndication - Indicates a PDU received from the lower communication interface module.
  3. CanNm_ConfirmPnAvailability——Enable the PN filter function on the specified network element channel.
  4. CanNm_TriggerTransmit ——The upper module performs data filling here

4.3 Scheduling functions

  1. CanNm_MainFunction - handles the state machine of CanNm.

Guess you like

Origin blog.csdn.net/qq_42357877/article/details/129968067