这样通过休眠唤醒需求分析各个场景,最终可以提炼出每一个控制器作为主动唤醒节点,它需要去唤醒哪些控制器或网络。因此可以确定每个控制器的网络管理报文,不难理解,byte0和byte1。同时针对不同休眠或唤醒场景,网管报文的user data有所区别,如何做到场景与网管报文内容一一映射,通常会定义另一帧报文,用来表明当前是哪个或哪几个请求条件或释放条件满足。另外,采取何种网络管理策略其实会影响休眠唤醒表的定义,比如采用PN,那么在休眠唤醒表中,是需要定义清楚PN cluster的。对于PN,有需要的话,可关注开心果 Need Car。
7 代码的角度
前面很多的理论知识。这里我们从代码的角度看看CANNM 的过程。
/*************************************************************************************************** Function name : CanNm_InternalMainProcess Syntax : void CanNm_InternalMainProcess( const NetworkHandleType CanNm_NetworkHandle ) Description : This is an internal main function of CANNM which does state machine processing for all channels. Parameter : CanNm_NetworkHandle - Identification of the CANNM-channel Return value : None***************************************************************************************************/
/*************************************************************************************************** Function name : CanNm_NetworkRequest Description : This is the AUTOSAR interface to request the network, since ECU needs to communicate on the bus. This API shall be called by Nm. Parameter : nmChannelHandle - Identification of the NM-channel Return value : E_OK - No error : E_NOT_OK - Requesting of network has failed***************************************************************************************************/
?
/*************************************************************************************************** Function name : CanNm_NetworkRelease Description : This is the AUTOSAR interface to release the network, since ECU doesn't have to communicate on the bus. This API shall be called by Nm. Parameter : nmChannelHandle - Identification of the NM-channel Return value : E_OK - No error : E_NOT_OK - Releasing of network has failed***************************************************************************************************/