code
stringlengths 1
1.05M
| repo_name
stringlengths 6
83
| path
stringlengths 3
242
| language
stringclasses 222
values | license
stringclasses 20
values | size
int64 1
1.05M
|
|---|---|---|---|---|---|
#FrSM
obj-$(USE_FRSM) += FrSM.o
obj-$(USE_FRSM) += FrSM_Internal.o
obj-$(USE_FRSM) += FrSM_Lcfg.o
obj-$(USE_FRSM) += FrSM_PBcfg.o
vpath-$(USE_FRSM) += $(ROOTDIR)/communication/FrSM/src
inc-$(USE_FRSM) += $(ROOTDIR)/communication/FrSM/inc
|
2301_81045437/classic-platform
|
communication/FrSM/FrSM.mod.mk
|
Makefile
|
unknown
| 245
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRSM_H_
#define FRSM_H_
#include "ComStack_Types.h"
#include "ComM.h"
#include "FrSM_Types.h" /* @req FrSm121 */
#if (USE_DEM)
#include "Dem.h"
#endif
/* @req FrSm139 */
#define FRSM_VENDOR_ID 60u
#define FRSM_MODULE_ID 142u
#define FRSM_AR_RELEASE_MAJOR_VERSION 4u
#define FRSM_AR_RELEASE_MINOR_VERSION 0u
#define FRSM_AR_RELEASE_REVISION_VERSION 3u
#define FRSM_AR_MAJOR_VERSION FRSM_AR_RELEASE_MAJOR_VERSION
#define FRSM_AR_MINOR_VERSION FRSM_AR_RELEASE_MINOR_VERSION
#define FRSM_AR_PATCH_VERSION FRSM_AR_RELEASE_REVISION_VERSION
#define FRSM_SW_MAJOR_VERSION 1u
#define FRSM_SW_MINOR_VERSION 0u
#define FRSM_SW_PATCH_VERSION 0u
/** Error IDs */
/* @req FrSm042 */
#define FRSM_E_NULL_PTR 1u
#define FRSM_E_INV_HANDLE 2u
#define FRSM_E_UNINIT 3u
#define FRSM_E_INV_MODE 4u
#define FRSM_E_CLUSTER_STARTUP 5u
#define FRSM_E_CLUSTER_SYNC_LOSS 6u
/** Service IDs */
#define FRSM_SERVICE_ID_INIT 1u
#define FRSM_SERVICE_ID_REQUEST_COM_MODE 2u
#define FRSM_SERVICE_ID_GET_CURRENT_COM_MODE 3u
#define FRSM_SERVICE_ID_GET_VERSION_INFO 4u
#define FRSM_SERVICE_ID_ALL_SLOTS 5u
#define FRSM_SERVICE_ID_SET_ECU_PASSIVE 6u
#define FRSM_SERVICE_ID_MAIN_FUNCTION 0x80u
/* @req FrSm121 */
#include "FrSM_Cfg.h"
/* Publish the configuration */
extern const FrSM_ConfigType FrSMConfigData;
/* @req FrSm120 */
/** FrSM.h shall export the API of the FrSM module */
/** Init function for FrSM */
/* @req FrSm013 */
void FrSM_Init( const FrSM_ConfigType* FrSM_ConfigPtr );
/** This service shall change the communication mode of a CAN network to the requested one. **/
/* @req FrSm020 */
Std_ReturnType FrSM_RequestComMode( NetworkHandleType NetworkHandle, ComM_ModeType ComM_Mode );
/** This service shall put out the current communication mode of a CAN network. */
/* @req FrSm024 */
Std_ReturnType FrSM_GetCurrentComMode( NetworkHandleType NetworkHandle, ComM_ModeType* ComM_ModePtr );
/** This service puts out the version information of this module */
/* @req FrSm029 */
/* @req FrSm129 */
/* @req FrSm130 */
#if (FRSM_VERSION_INFO_API == STD_ON)
#define FrSM_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,FRSM)
#endif
/* @req FrSm172 */
Std_ReturnType FrSM_AllSlots( NetworkHandleType NetworkHandle );
/* @req FrSm174 */
Std_ReturnType FrSM_SetEcuPassive( boolean FrSM_Passive );
#ifdef HOST_TEST
extern void ReportErrorStatus(void);
#endif
#endif /* FRSM_H_ */
|
2301_81045437/classic-platform
|
communication/FrSM/inc/FrSM.h
|
C
|
unknown
| 3,393
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRSM_TYPES_H_
#define FRSM_TYPES_H_
/* @req FrSm054 */
#if defined(USE_DEM)
#include "Dem.h"
#endif
#include "Fr_GeneralTypes.h"
/* @req FrSm180 */
typedef enum {
FRSM_BSWM_READY,
FRSM_BSWM_READY_ECU_PASSIVE,
FRSM_BSWM_STARTUP,
FRSM_BSWM_STARTUP_ECU_PASSIVE,
FRSM_BSWM_WAKEUP,
FRSM_BSWM_WAKEUP_ECU_PASSIVE,
FRSM_BSWM_HALT_REQ,
FRSM_BSWM_HALT_REQ_ECU_PASSIVE,
FRSM_BSWM_KEYSLOT_ONLY,
FRSM_BSWM_KEYSLOT_ONLY_ECU_PASSIVE,
FRSM_BSWM_ONLINE,
FRSM_BSWM_ONLINE_ECU_PASSIVE,
FRSM_BSWM_ONLINE_PASSIVE,
FRSM_BSWM_ONLINE_PASSIVE_ECU_PASSIVE,
FRSM_BSWM_LOW_NUMBER_OF_COLDSTARTERS,
FRSM_BSWM_LOW_NUMBER_OF_COLDSTARTERS_ECU_PASSIVE,
}FrSM_BswM_StateType;
typedef struct {
const uint8 FrIfControllerId;
const Fr_ChannelType FrSMChannel;
const boolean FrSMIsDualChannelNode;
const boolean FrTrcvAvailable;
} FrSM_ControllerType;
typedef struct
{
const uint32 FrSMDurationT1;
const uint32 FrSMDurationT2;
const uint32 FrSMDurationT3;
const uint32 FrSMMainFunctionCycleTime;
const uint32 FrSMNumWakeupPatterns;
const uint32 FrSMStartupRepetitions;
const uint32 FrSMStartupRepetitionsWithWakeup;
const FrSM_ControllerType* FrSMControllerRef;
const uint8 FrSMClusterId;
const uint8 FrSMControllerCount;
const uint8 FrSMMinNumberOfColdstarter;
const uint8 FrSMComMNetworkHandle;
const uint8 FrSMFrIfClusterRef;
#if (USE_DEM)
Dem_EventIdType FrSMClusterStartUpDemEventId;
Dem_EventIdType FrSMClusterSyncLossDemEventId;
#endif
const boolean FrSMCheckWakeupReason;
const boolean FrSMDelayStartupWithoutWakeup;
const boolean FrSMIsColdstartEcu;
const boolean FrSMIsWakeupEcu;
const boolean FrSMStartupRepetitionsType;
const boolean FrSMStartupRepetitionsWithWakeupType;
}FrSM_ClusterType;
typedef struct
{
const FrSM_ClusterType* FrSMClusters; /* configuration structure that is for FrSM_Init */
const uint8* FrSMClusterLookups; /* Pointer to map from NetworkHandle to Frif Cluster IDs */
const uint8 FrSMClusterCount; /* No. of FrSM clusters */
const uint8 FrSMTotalCtrlCount; /* Total num of Controllers */
}FrSM_ConfigType;
#endif /* FRSM_TYPES_H_ */
|
2301_81045437/classic-platform
|
communication/FrSM/inc/FrSM_Types.h
|
C
|
unknown
| 3,472
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "ComStack_Types.h"
#include "ComM_BusSM.h"
#include "FrSM.h" /* @req FrSm055 */
#include "FrSM_Internal.h"
#include "FrNm.h"
#if (FRSM_DEV_ERROR_DETECT == STD_ON)
#include "Det.h" /* @req FrSm056 */
#endif
#if defined(USE_DEM)
#include "Dem.h" /* @req FrSm059 */
#endif
#include "MemMap.h" /* @req FrSm057 */
#include "FrIf.h" /* @req FrSm058 */
#include "SchM_FrSM.h"
#if defined(USE_BSWM)
#include "BswM_FrSM.h"
#endif
/* Globally fulfilled requirements */
/** @req FrSm051 */ /* Code file structure */
/** @req FrSm159 */ /* Timer T3 timeout implementation */
/** @req FrSm105 */ /* State machine actions will be in the order as specified by spec */
/** @req FrSm093 */ /* State Machine diagram */
/** @req FrSm149 */ /* ignore return values of FrIf Apis */
#define CONTROLLER_0 (0x00u)
#define WAKEUP_INDICATOR_MASK (0x03u)
#define WAKEUP_CH_A_B (0x03u)
#define WAKEUP_CH_A (0x01u)
#define WAKEUP_CH_B (0x02u)
void FrSM_MainFunction(uint8 clusterId);
/*lint -esym(9003,FrSM_ConfigPointer )*/
const FrSM_ConfigType* FrSM_ConfigPointer;
/* here controller count = FRSM_CLUSTER_COUNT since design Consideration for State machine
is only one CC's of every cluster */
static FrSM_Internal_CtrlStatusType FrSM_InternalControllerStatus[FRSM_CLUSTER_COUNT];
static FrSM_Internal_ClusterType FrSM_InternalClusters[FRSM_CLUSTER_COUNT];
/** Static declarations */
FrSM_InternalType FrSM_Internal = {
.initStatus = FRSM_STATUS_UNINIT,
.clusterStatus = FrSM_InternalClusters,
.controllerMode = FrSM_InternalControllerStatus,
};
/**
* @brief Function indicates Upper ComM layer
* @param clusterid
* @param ComM_Mode
*/
static void FrSM_Internal_ComM_BusSM_ModeIndication( uint8 clusterid, ComM_ModeType ComM_Mode )
{
/* Update internals */
/* @req FrSm026 */
FrSM_Internal.clusterStatus[clusterid].curComMode = ComM_Mode;
/* Indicate to ComM */
ComM_BusSM_ModeIndication(FrSM_ConfigPointer->FrSMClusters[clusterid].FrSMComMNetworkHandle, &ComM_Mode);
}
/**
* @brief function calls the FrIf_AllowColdstart api if cluster is Cold start ECU
* @param clusterId
*/
INLINE static void FrSM_Internal_AllowColdStart(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg ;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(TRUE == clusterCfg->FrSMIsColdstartEcu) {
(void)FrIf_AllowColdstart(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId);
} else {
/* Do nothing */
}
}
/**
* @brief Reset WakeUp status variables
* @param clusterId
*/
static void FrSM_Internal_WakeUp_Reset_Var(uint8 clusterId)
{
FrSM_Internal.controllerMode[clusterId].wakeUpAction = ECHO_MODE_OFF;
FrSM_Internal.controllerMode[clusterId].wakeupTransmitted = FALSE;
FrSM_Internal.controllerMode[clusterId].wakeupFinished = FALSE;
FrSM_Internal.controllerMode[clusterId].wakeupCounter = 0;
FrSM_Internal.controllerMode[clusterId].busTrafficDetected = FALSE;
}
/**
* @brief Get POC states of First CC of Cluster
* @param clusterId
*/
INLINE static void FrSM_Internal_PocStatus(uint8 clusterId) {
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
/* @req FrSm047 */
(void)FrIf_GetPOCStatus(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId, &FrSM_Internal.controllerMode[clusterId].pocCcStatus);
}
/**
* @brief set lowNumberOfColdstarters to true/false
* @param clusterId
*/
INLINE static void FrSM_Internal_StartupFrame_No(uint8 clusterId) {
uint8 coldStartVal;
/* @req FrSm192 */
if( 0 != FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMMinNumberOfColdstarter) {
/* Call FrIf function to get startup numbers */
(void)FrIf_GetNumOfStartupFrames( FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMControllerRef[CONTROLLER_0].FrIfControllerId, &coldStartVal );
if(coldStartVal < FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMMinNumberOfColdstarter ) {
/* @req FrSm187 */
FrSM_Internal.controllerMode[clusterId].lowNumberOfColdstarters = TRUE;
} else {
/* @req FrSm188*/
FrSM_Internal.controllerMode[clusterId].lowNumberOfColdstarters = FALSE;
}
} else {
FrSM_Internal.controllerMode[clusterId].lowNumberOfColdstarters = FALSE;
}
}
/**
* @brief function does common actions required for READY to WakeUp transition
* @param clusterId
*/
INLINE static void FrSM_Internal_ReadyToWakeup_Action(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
FrSM_Internal_TrcvNormal(clusterId);
/* Send Wake up pattern and update the required variables */
FrSM_Internal.controllerMode[clusterId].startupCounter = 0x01;
/* Reset variable of WakeUp states */
FrSM_Internal_WakeUp_Reset_Var(clusterId);
/* Send the wakeUp pattern for first CC of Cluster */
(void)FrIf_SendWUP(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId); /* Send Wake up pattern */
/* If timer T1 is configured then start it */
UPDATE_TIMER1(clusterId);
/* If timer T3 is configured then start it */
UPDATE_TIMER3(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_WAKEUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.controllerMode[clusterId].wakeupCounter++;
}
/**
* @brief function does common action required for READY to StartUp transition
* @param clusterId
*/
INLINE static void FrSM_Internal_ReadyToStartup_Action(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
uint8 ctlr;
FrSM_Internal_TrcvNormal(clusterId);
/* start with start up frame and updates required variable */
FrSM_Internal.controllerMode[clusterId].startupCounter = 0x01;
FrSM_Internal.controllerMode[clusterId].wakeupType = NO_WAKEUP;
/* start the communication for all CC's of cluster */
for(ctlr = 0; ctlr < clusterCfg->FrSMControllerCount; ctlr++) {
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[ctlr].FrIfControllerId);
}
/* If timer T2 is configured then start it */
UPDATE_TIMER2(clusterId);
/* If timer T3 is configured then start it */
UPDATE_TIMER3(clusterId);
}
/**
* @brief function does transition from Ready to wakeup or starup state
* @param clusterId
*/
INLINE static void FrSM_Internal_ReadyToWakeUpStartUp_Trans(uint8 clusterId)
{
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if( (COMM_FULL_COMMUNICATION == cluster->reqComMode) &&
(TRUE == clusterCfg->FrSMIsWakeupEcu) &&
(NO_WU_BY_BUS == FrSM_Internal.controllerMode[clusterId].wuReason) ) {
if(TRUE == clusterCfg->FrSMControllerRef[CONTROLLER_0].FrSMIsDualChannelNode) {
/* @req FrSm151 trans T01 (b) */
FrSM_Internal.controllerMode[clusterId].wakeupType = DUAL_CHANNEL_WAKEUP;
/* Set wake up channel before sending wake up pattern */
(void)FrIf_SetWakeupChannel(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,FR_CHANNEL_A);
} else {
/* @req FrSm072 trans T01 (a) */
FrSM_Internal.controllerMode[clusterId].wakeupType = SINGLE_CHANNEL_WAKEUP;
}
/* Function call to send wake up pattern */
FrSM_Internal_ReadyToWakeup_Action(clusterId);
} else if( (COMM_FULL_COMMUNICATION == cluster->reqComMode) &&
(TRUE == clusterCfg->FrSMIsWakeupEcu) &&
(PARTIAL_WU_BY_BUS == FrSM_Internal.controllerMode[clusterId].wuReason) ) {
/* @req FrSm152 trans T01 (c) */
FrSM_Internal.controllerMode[clusterId].wakeupType = DUAL_CHANNEL_ECHO_WAKEUP;
/* Set wake up channel before sending wake up pattern */
(void)FrIf_SetWakeupChannel(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,FrSM_Internal.controllerMode[clusterId].channelType);
/* Function call to send wake up pattern */
FrSM_Internal_ReadyToWakeup_Action(clusterId);
} else if((COMM_FULL_COMMUNICATION == cluster->reqComMode) &&
((FALSE == clusterCfg->FrSMIsWakeupEcu) || (ALL_WU_BY_BUS == FrSM_Internal.controllerMode[clusterId].wuReason))) {
/* Function call to start with startup communication trans T02 (a) trans T02 (b)*/
FrSM_Internal_ReadyToStartup_Action(clusterId);
if((FALSE == clusterCfg->FrSMDelayStartupWithoutWakeup)) {
/* @req FrSm073 trans T02 (a)*/
FrSM_Internal_AllowColdStart(clusterId);
} else {
/* @req FrSm184 Trans T02 (b) */
/* If timer T1 is configured then start it */
UPDATE_TIMER1(clusterId);
}
/* transition to START UP state */
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else {
/* Do nothing */
}
#if defined(USE_BSWM)
/* Report change in cluster state to BswM module */
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
} else { /* Do Nothing */ }
#endif
}
/**
* @brief function check wake Up action and set wakeupFinished variable to true/false
* @param clusterId
*/
INLINE static void FrSM_Internal_WakeUp_Action(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(FR_POCSTATE_WAKEUP != FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) {
/* @req FrSm183 */
if((FrSM_Internal.controllerMode[clusterId].wakeupCounter <= clusterCfg->FrSMNumWakeupPatterns) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].busTrafficDetected) ) {
/* Proceed if POC state is in FR_POCSTATE_READY */
if(FR_POCSTATE_READY == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) {
if((FR_WAKEUP_RECEIVED_HEADER == FrSM_Internal.controllerMode[clusterId].pocCcStatus.WakeupStatus) ||
(FR_WAKEUP_RECEIVED_WUP == FrSM_Internal.controllerMode[clusterId].pocCcStatus.WakeupStatus) ) {
/* received a frame header/valid wakeup pattern on either channel during the initial listen phase */
FrSM_Internal.controllerMode[clusterId].busTrafficDetected = TRUE;
/* Wake Up is finished since wakeup pattern/header was recieved */
FrSM_Internal.controllerMode[clusterId].wakeupFinished = TRUE;
} else if(FR_WAKEUP_TRANSMITTED == FrSM_Internal.controllerMode[clusterId].pocCcStatus.WakeupStatus) {
/* wakeup pattern was completely transmitted */
FrSM_Internal.controllerMode[clusterId].wakeupTransmitted = TRUE;
/* Wake Up is finished since wakeup pattern was completely transmitted */
FrSM_Internal.controllerMode[clusterId].wakeupFinished = TRUE;
} else {
/* Wake up is not done ,try again by sending wake up pattern */
(void)FrIf_SendWUP(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId);
/* memorize wake up attempts */
FrSM_Internal.controllerMode[clusterId].wakeupCounter++;
}
} else {
FrSM_Internal.controllerMode[clusterId].wakeupFinished = FALSE;
}
} else {
/* Do Nothing */
}
} else {
/* Do Nothing */
}
}
/**
* @brief function to handle wake up pattern and No Com request
* @param clusterId
*/
INLINE static void FrSM_Internal_WakeUp_Pattern(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
/* @req FrSm085 trans T13 */
if((COMM_NO_COMMUNICATION == cluster->reqComMode)) {
/* Set TRCV mode to stand by and init all CC */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
if(TRUE == clusterCfg->FrSMControllerRef[controller].FrTrcvAvailable){
if(TRUE == clusterCfg->FrSMControllerRef[controller].FrSMIsDualChannelNode) {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_A,FRTRCV_TRCVMODE_STANDBY );
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_B,FRTRCV_TRCVMODE_STANDBY );
} else {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,clusterCfg->FrSMControllerRef[controller].FrSMChannel, FRTRCV_TRCVMODE_STANDBY );
}
} else { /* Do nothing */ }
/* Call FrIf_ControllerInit to enter into Ready state */
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
/* Cancle timerT3 and update state to FRSM_READY */
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_READY;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else {
/* proceed if timer T3 is not expired */
if(FALSE == FrSM_Internal.controllerMode[clusterId].t3_IsNotActive) { /* @req FrSm160 trans T31 */
switch (FrSM_Internal.controllerMode[clusterId].wakeUpAction) {
case ECHO_MODE_OFF :
/* call function to check wake up is done or not */
FrSM_Internal_WakeUp_Action(clusterId);
if((TRUE == FrSM_Internal.controllerMode[clusterId].wakeupFinished ) && (DUAL_CHANNEL_ECHO_WAKEUP != FrSM_Internal.controllerMode[clusterId].wakeupType)){
/* Wake up for channel is done */
FrSM_Internal.controllerMode[clusterId].wakeUpAction = NO_ACTION;
} else if((TRUE == FrSM_Internal.controllerMode[clusterId].wakeupFinished ) && (FR_POCSTATE_READY == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State)
&& (COMM_FULL_COMMUNICATION == cluster->reqComMode) && (FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze) &&
(DUAL_CHANNEL_ECHO_WAKEUP == FrSM_Internal.controllerMode[clusterId].wakeupType)){
/* Wake up for one channel is done and start with other left channel by sending wake up pattern */
/* @req FrSm150 trans T103 */
FrSM_Internal.controllerMode[clusterId].wakeupType = DUAL_CHANNEL_WAKEUPFORWARD;
/* set wake up channel before sending pattern to a asleep channel */
if(FR_CHANNEL_A == FrSM_Internal.controllerMode[clusterId].channelType) {
(void)FrIf_SetWakeupChannel(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,FR_CHANNEL_B);
} else {
(void)FrIf_SetWakeupChannel(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,FR_CHANNEL_A);
}
/* Send wake up pattern and updates required variables */
FrSM_Internal.controllerMode[clusterId].wakeUpAction = ECHO_MODE_ON;
FrSM_Internal.controllerMode[clusterId].busTrafficDetected = FALSE;
FrSM_Internal.controllerMode[clusterId].wakeupTransmitted = FALSE;
FrSM_Internal.controllerMode[clusterId].wakeupFinished = FALSE;
(void)FrIf_SendWUP(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId); /* send wake up pattern */
FrSM_Internal.controllerMode[clusterId].wakeupCounter = 1;
} else {
/* Do Nothing */
}
break;
case ECHO_MODE_ON : /* ECHO_MODE_ON will excute only once during transition from Echo_wake up to wakeupForward */
/* call function to check wake up is done or not for other left channel */
FrSM_Internal_WakeUp_Action(clusterId);
if(TRUE == FrSM_Internal.controllerMode[clusterId].wakeupFinished ) {
/* Wake up for channel is done */
FrSM_Internal.controllerMode[clusterId].wakeUpAction = NO_ACTION;
} else {
/* Do Nothing */
}
break;
default :
break;
}
} else{
/* @req FrSm160 trans T31 */
/* synchronisation has been fail, report to FrNm */
FrNm_StartupError(clusterCfg->FrSMComMNetworkHandle);
UPDATE_TIMER3(clusterId); //Reset t3 timer
/* @req FrSm046 */
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_STARTUP);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterStartUpDemEventId), clusterCfg->FrSMClusterStartUpDemEventId, DEM_EVENT_STATUS_FAILED);
}
}
}
/**
* @brief function does transition from wakeup state to Start up
* @param clusterId
*/
static void FrSM_Internal_WakeupToStartUp_Trans(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if((TRUE == FrSM_Internal.controllerMode[clusterId].wakeupFinished) && (COMM_FULL_COMMUNICATION == cluster->reqComMode)) {
switch (FrSM_Internal.controllerMode[clusterId].wakeupType) {
case SINGLE_CHANNEL_WAKEUP:
if(1 == clusterCfg->FrSMNumWakeupPatterns) {
/* @req FrSm074 trans T03 (a) */
/* Update State to FRSM_READY and required varaible */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
UPDATE_TIMER1(clusterId);
UPDATE_TIMER2(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if ((1 < clusterCfg->FrSMNumWakeupPatterns) &&
((TRUE == FrSM_Internal.controllerMode[clusterId].wakeupTransmitted) || (FALSE == FrSM_Internal.controllerMode[clusterId].t1_IsActive)) ) {
/* @req FrSm183 trans T03 (b) */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.controllerMode[clusterId].t1Started = FALSE;
UPDATE_TIMER2(clusterId);
FrSM_Internal_AllowColdStart(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if((1 < clusterCfg->FrSMNumWakeupPatterns) && (FALSE == FrSM_Internal.controllerMode[clusterId].wakeupTransmitted)) {
/* @req FrSm184 T03 (c) */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else {
/* Do Nothing */
}
break;
case DUAL_CHANNEL_WAKEUP:
/* @req FrSm153 T03 (d) */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
UPDATE_TIMER2(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
break;
case DUAL_CHANNEL_WAKEUPFORWARD:
/* @req FrSm154 T03 (e) */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal_AllowColdStart(clusterId);
UPDATE_TIMER2(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
break;
default:
break;
}
} else {
/* Do Nothing */
}
#if defined(USE_BSWM)
/* Report change in cluster state to BswM module */
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
} else { /* Do Nothing */ }
#endif
}
/**
* @brief function to the find the wake up reason
* @param clusterId
*/
INLINE static void FrSM_Internal_WakeReason(uint8 clusterId)
{
FrTrcv_TrcvWUReasonType wakeReason[2];
const FrSM_ClusterType* clusterCfg;
FrSM_Internal_CtrlStatusType* cluster;
cluster = &FrSM_Internal.controllerMode[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(FALSE == clusterCfg->FrSMCheckWakeupReason) {
/* Channels not woken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = NO_WU_BY_BUS;
} else {
if(TRUE == clusterCfg->FrSMControllerRef[CONTROLLER_0].FrSMIsDualChannelNode) {
if(TRUE == clusterCfg->FrSMControllerRef[CONTROLLER_0].FrTrcvAvailable) {
/* get Wakeup reasons for dual channel*/
(void)FrIf_GetTransceiverWUReason(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,FR_CHANNEL_A,&wakeReason[0]);
(void)FrIf_GetTransceiverWUReason(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,FR_CHANNEL_B,&wakeReason[1]);
if((FRTRCV_WU_BY_BUS != wakeReason[0]) && (FRTRCV_WU_BY_BUS != wakeReason[1])) {
/* Channels not woken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = NO_WU_BY_BUS;
} else if((FRTRCV_WU_BY_BUS == wakeReason[0]) && (FRTRCV_WU_BY_BUS != wakeReason[1])) {
/* Channel A is Awaken and Channel B is asleep */
FrSM_Internal.controllerMode[clusterId].wuReason = PARTIAL_WU_BY_BUS;
FrSM_Internal.controllerMode[clusterId].channelType = FR_CHANNEL_A;
} else if((FRTRCV_WU_BY_BUS != wakeReason[0]) && (FRTRCV_WU_BY_BUS == wakeReason[1])){
/* Channel B is Awaken and Channel A is asleep */
FrSM_Internal.controllerMode[clusterId].wuReason = PARTIAL_WU_BY_BUS;
FrSM_Internal.controllerMode[clusterId].channelType = FR_CHANNEL_B;
} else {
/* Channel A and B are Awaken */
FrSM_Internal.controllerMode[clusterId].wuReason = ALL_WU_BY_BUS;
}
} else {
/* Get Wakeup Rx status */
(void)FrIf_GetWakeupRxStatus(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,&(cluster->wakeupRxstatus));
if(WAKEUP_CH_A_B == (WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus)) {
/* Channel A and B are Awaken */
FrSM_Internal.controllerMode[clusterId].wuReason = ALL_WU_BY_BUS;
} else if (WAKEUP_CH_B == ((uint8)WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus)) {
/* Channel B is Awaken and Channel A is asleep */
FrSM_Internal.controllerMode[clusterId].wuReason = PARTIAL_WU_BY_BUS;
FrSM_Internal.controllerMode[clusterId].channelType = FR_CHANNEL_B;
} else if(WAKEUP_CH_A == ((uint8)WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus)) {
/* Channel A is Awaken and Channel B is asleep */
FrSM_Internal.controllerMode[clusterId].wuReason = PARTIAL_WU_BY_BUS;
FrSM_Internal.controllerMode[clusterId].channelType = FR_CHANNEL_A;
} else if(0x00 == ((uint8)WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus)) {
/* Channels not woken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = NO_WU_BY_BUS;
} else {
/* Do Nothing */
}
}
} else {
if(TRUE == clusterCfg->FrSMControllerRef[CONTROLLER_0].FrTrcvAvailable) {
/* get Wakeup reason for single channel*/
(void)FrIf_GetTransceiverWUReason(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,clusterCfg->FrSMControllerRef[CONTROLLER_0].FrSMChannel,&wakeReason[0]);
if((FRTRCV_WU_BY_BUS == wakeReason[0])) {
/* Channel awaken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = ALL_WU_BY_BUS;
} else {
/* Channels not woken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = NO_WU_BY_BUS;
}
} else {
(void)FrIf_GetWakeupRxStatus(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,&cluster->wakeupRxstatus);
if((WAKEUP_CH_A == ((uint8)WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus)) ||(WAKEUP_CH_B == ((uint8)WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus)) ) {
/* Channel awaken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = ALL_WU_BY_BUS;
}else {
/* Channels not woken up by Bus */
FrSM_Internal.controllerMode[clusterId].wuReason = NO_WU_BY_BUS;
}
}
}
}
}
/**
* @brief function to find all channels waken up or not
* @param clusterId
*/
INLINE static void FrSM_Internal_AllChannelsAWake(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
FrSM_Internal_CtrlStatusType* cluster;
cluster = &FrSM_Internal.controllerMode[clusterId];
(void)FrIf_GetWakeupRxStatus(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId,&(cluster->wakeupRxstatus));
/* Check Both Channel A and B waken or not */
if(WAKEUP_CH_A_B == (((uint8)WAKEUP_INDICATOR_MASK & cluster->wakeupRxstatus))) {
FrSM_Internal.controllerMode[clusterId].allChannelsAwake = TRUE;
} else {
FrSM_Internal.controllerMode[clusterId].allChannelsAwake = FALSE;
}
}
/**
* @brief function allows cold start if timer T1 is expired or Dual channels are Awaken
* @param clusterId
*/
INLINE static void FrSM_Internal_StartUp_T1_Actions(uint8 clusterId)
{
switch (FrSM_Internal.controllerMode[clusterId].wakeupType) {
case SINGLE_CHANNEL_WAKEUP:
/* @req FrSm075 trans T04 (a) */
/* Wait till Timer1 expires before starting cold start */
if(FALSE == FrSM_Internal.controllerMode[clusterId].t1_IsActive) {
FrSM_Internal_AllowColdStart(clusterId);
FrSM_Internal.controllerMode[clusterId].t2action = TRUE;
}
break;
case DUAL_CHANNEL_WAKEUP:
/* @req FrSm155 trans T04 (b) */
/* Call function to check all channel are in awake state and start with Cold start if all channel are awaken */
FrSM_Internal_AllChannelsAWake(clusterId);
if(TRUE == FrSM_Internal.controllerMode[clusterId].allChannelsAwake) {
FrSM_Internal_AllowColdStart(clusterId);
FrSM_Internal.controllerMode[clusterId].t2action = TRUE;
}
break;
default:
break;
}
}
/**
* @brief Function decide whether to start START_UP state again with wakeUp/Without wakeUp.
* @param clusterId
*/
static void FrSM_Internal_StartUp_T2_Actions(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
uint8 controller;
if((NO_WAKEUP != FrSM_Internal.controllerMode[clusterId].wakeupType) &&
((FALSE == clusterCfg->FrSMStartupRepetitionsWithWakeupType) || (clusterCfg->FrSMStartupRepetitionsWithWakeup >= FrSM_Internal.controllerMode[clusterId].startupCounter)) ){
/*startupCounter does not exceed the threshold FrSMStartupRepetitionsWithWakeup, the startup procedure will be repeated including the wakeup. */
/* @req FrSm076 trans T05 */
FrSM_Internal_TrcvNormal(clusterId);
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
/* Reset variable of WakeUp states */
FrSM_Internal_WakeUp_Reset_Var(clusterId);
(void)FrIf_SendWUP(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId);
FrSM_Internal.controllerMode[clusterId].startupCounter++;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_WAKEUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.controllerMode[clusterId].wakeupCounter = 1; /* Wake pattern set = 1 since pattern is sent here */
FrSM_Internal.controllerMode[clusterId].t2action = FALSE;
} else if((( (FALSE == clusterCfg->FrSMStartupRepetitionsWithWakeupType) || (clusterCfg->FrSMStartupRepetitionsWithWakeup < FrSM_Internal.controllerMode[clusterId].startupCounter))
|| (NO_WAKEUP == FrSM_Internal.controllerMode[clusterId].wakeupType) )&&
( (FALSE == clusterCfg->FrSMStartupRepetitionsType) ||(clusterCfg->FrSMStartupRepetitions >= FrSM_Internal.controllerMode[clusterId].startupCounter) )) {
/* @req FrSm077 trans T06 */
/* startupCounter exceeds the threshold FrSMStartupRepetitionsWithWakeup but does not exceed the threshold FrSMStartupRepetitions,
* the startup procedure will be repeated without wakeup.*/
FrSM_Internal_TrcvNormal(clusterId);
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal_AllowColdStart(clusterId);
FrSM_Internal.controllerMode[clusterId].startupCounter++;
UPDATE_TIMER2(clusterId);
} else {
/* Do Nothing */
}
}
/**
* @brief funtion enter into Online state from StartUp state
* @param clusterId
*/
INLINE static void FrSM_Internal_StartUp_To_Online_Key_Tras(uint8 clusterId)
{
#if defined(USE_DEM)
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
#endif
if(FR_SLOTMODE_ALL == FrSM_Internal.controllerMode[clusterId].pocCcStatus.SlotMode) {
/* @req FrSm079 trans T08 */
FrSM_Internal.controllerMode[clusterId].t1Started = FALSE;
FrSM_Internal.controllerMode[clusterId].t2Started = FALSE;
(void)FrIf_SetState(clusterId, FRIF_GOTO_ONLINE);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterStartUpDemEventId), clusterCfg->FrSMClusterStartUpDemEventId, DEM_EVENT_STATUS_PASSED);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
FrSM_Internal_ComM_BusSM_ModeIndication(clusterId,COMM_FULL_COMMUNICATION);
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_ONLINE;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.controllerMode[clusterId].t2action = FALSE;
} else if(FR_SLOTMODE_KEYSLOT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.SlotMode){
/* @req FrSm156 trans T108 */
FrSM_Internal.controllerMode[clusterId].t1Started = FALSE;
FrSM_Internal.controllerMode[clusterId].t2Started = FALSE;
(void)FrIf_SetState(clusterId, FRIF_GOTO_ONLINE);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterStartUpDemEventId), clusterCfg->FrSMClusterStartUpDemEventId, DEM_EVENT_STATUS_PASSED);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_KEYSLOT_ONLY;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.controllerMode[clusterId].t2action = FALSE;
} else {
/* Do Nothing */
}
}
/**
* @brief Function does transition from startup to other states
* @param clusterId
*/
static void FrSM_Internal_StartUp_Trans(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(COMM_NO_COMMUNICATION == cluster->reqComMode) {
/* @req FrSm084 trans T12 */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
if(TRUE == clusterCfg->FrSMControllerRef[controller].FrTrcvAvailable){
if(TRUE == clusterCfg->FrSMControllerRef[controller].FrSMIsDualChannelNode) {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_A,FRTRCV_TRCVMODE_STANDBY );
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_B,FRTRCV_TRCVMODE_STANDBY );
} else {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,clusterCfg->FrSMControllerRef[controller].FrSMChannel, FRTRCV_TRCVMODE_STANDBY );
}
}
}
/* change state to FRSM_READY and updates required Variables */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.controllerMode[clusterId].t1Started = FALSE;
FrSM_Internal.controllerMode[clusterId].t2Started = FALSE;
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_READY;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.controllerMode[clusterId].t2action = FALSE;
} else {
/* proceed if timer T3 is not expired. trans T32*/
if(FALSE == FrSM_Internal.controllerMode[clusterId].t3_IsNotActive) {
if((FR_POCSTATE_NORMAL_ACTIVE != FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) && (COMM_FULL_COMMUNICATION == cluster->reqComMode)) {
if((FALSE == FrSM_Internal.controllerMode[clusterId].t2action) && ((SINGLE_CHANNEL_WAKEUP == FrSM_Internal.controllerMode[clusterId].wakeupType) ||
(DUAL_CHANNEL_WAKEUP == FrSM_Internal.controllerMode[clusterId].wakeupType)) ) {
/* if timer T1 is expired or Dual channel Awaken then allow coldstart */
FrSM_Internal_StartUp_T1_Actions(clusterId);
} else {
/* if timer T2 is expired then repeat the startup procedure depending on the value of the startupCounter:*/
if(FALSE == FrSM_Internal.controllerMode[clusterId].t2_IsActive) {
FrSM_Internal_StartUp_T2_Actions(clusterId);
FrSM_Internal.controllerMode[clusterId].t2action = FALSE;
}
}
} else if((FR_POCSTATE_NORMAL_ACTIVE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze) &&
(COMM_FULL_COMMUNICATION == cluster->reqComMode) ) {
/* cluster state changes to Online or Key slot only */
FrSM_Internal_StartUp_To_Online_Key_Tras(clusterId);
} else {
/* Do Nothing */
}
} else {
/* @req FrSm161 trans T32 */
/* synchronisation has been fail, report to FrNm */
FrNm_StartupError(clusterCfg->FrSMComMNetworkHandle);
UPDATE_TIMER3(clusterId); //Reset t3 timer
/* @req FrSm046 */
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_STARTUP);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterStartUpDemEventId), clusterCfg->FrSMClusterStartUpDemEventId, DEM_EVENT_STATUS_FAILED);
}
}
#if defined(USE_BSWM)
/* Report change in cluster state to BswM module */
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
}
#endif
}
/**
* @brief function to enter into Halt state
* @param clusterId
*/
INLINE static void FrSM_Internal_HaltState_Trans(uint8 clusterId)
{
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
uint8 controller;
if(FRSM_KEYSLOT_ONLY == cluster->frSMClusterState) {
/* @req FrSm080 T09 (b)*/
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_HaltCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
} else if(FRSM_ONLINE_PASSIVE == cluster->frSMClusterState) {
/* @req FrSm125 Trans T14 */
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_HaltCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
} else {
/* Do Nothing */
}
/* Update state to HALT_REQ */
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_HALT_REQ;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
}
/**
* @brief function call to return WakeUp state
* @param clusterId
*/
INLINE static void FrSM_Internal_Return_WakeUp_state(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
FrSM_Internal.controllerMode[clusterId].wakeupType = SINGLE_CHANNEL_WAKEUP;
if((FRSM_ONLINE == cluster->frSMClusterState) || (FRSM_LOW_NUMBER_OF_COLDSTARTERS == cluster->frSMClusterState)) {
/* @req FrSm0200 T20 (a) */
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
FrSM_Internal_ComM_BusSM_ModeIndication(clusterId,COMM_NO_COMMUNICATION );
} else if(FRSM_KEYSLOT_ONLY == cluster->frSMClusterState) {
/* @req FrSm0200 T20 (b) */
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
} else {
/* @req FrSm0201 T20 (c)*/
}
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
(void)FrIf_SendWUP(clusterCfg->FrSMControllerRef[CONTROLLER_0].FrIfControllerId);
FrSM_Internal.controllerMode[clusterId].startupCounter = 1;
UPDATE_TIMER1(clusterId);
UPDATE_TIMER3(clusterId);
}
/**
* @brief function call to transition from online to coldstart vice versa
* @param clusterId
*/
INLINE static void FrSM_Internal_Online_ColdStart_trans(uint8 clusterId)
{
if(TRUE == FrSM_Internal.controllerMode[clusterId].lowNumberOfColdstarters) {
/* @req FrSm187 Trans T40 */
if(FRSM_LOW_NUMBER_OF_COLDSTARTERS != FrSM_Internal.clusterStatus[clusterId].frSMClusterState) {
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_LOW_NUMBER_OF_COLDSTARTERS;
}
} else {
/* @req FrSm188 Trans T41 */
if(FRSM_ONLINE != FrSM_Internal.clusterStatus[clusterId].frSMClusterState) {
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_ONLINE;
}
}
}
/**
* @brief function performs online State actions
* @param clusterId
*/
static void FrSM_Internal_Online_Trans(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(cluster->reqComMode == COMM_FULL_COMMUNICATION) {
if(((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) &&
(TRUE == clusterCfg->FrSMCheckWakeupReason) ) {
/* @req FrSm081 Trans T10 (a)*/
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_SYNC_LOSS);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_FAILED);
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
FrSM_Internal_ComM_BusSM_ModeIndication(clusterId,COMM_NO_COMMUNICATION);
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.controllerMode[clusterId].startupCounter = 1;
UPDATE_TIMER2(clusterId);
UPDATE_TIMER3(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if((FR_POCSTATE_NORMAL_PASSIVE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) {
/* @req FrSm087 Trans T16 (a)*/
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_SYNC_LOSS);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_FAILED);
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
FrSM_Internal_ComM_BusSM_ModeIndication(clusterId,COMM_NO_COMMUNICATION );
UPDATE_TIMER3(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_ONLINE_PASSIVE;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if(((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) &&
(FALSE == clusterCfg->FrSMCheckWakeupReason) && (TRUE == clusterCfg->FrSMIsWakeupEcu) ) {
/* @req FrSm0200 */ /* Trans T20 (a) */
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_SYNC_LOSS);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_FAILED);
FrSM_Internal_Return_WakeUp_state(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_WAKEUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
/* Reset Variables of WakeUp state to repeat wakeUp state */
FrSM_Internal_WakeUp_Reset_Var(clusterId);
FrSM_Internal.controllerMode[clusterId].wakeupCounter = 1;
} else {
FrSM_Internal_Online_ColdStart_trans(clusterId);
}
}
#if defined(USE_BSWM)
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
} else { /* Do Nothing */ }
#endif
}
/**
* @brief function performs Keyslot State actions
* @param clusterId
*/
static void FrSM_Internal_KeySlot_Actions(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(COMM_NO_COMMUNICATION == cluster->reqComMode) {
/* Function call to enter into HALT state -Trans T09 (b)*/
FrSM_Internal_HaltState_Trans(clusterId);
} else {
if(((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) &&
(TRUE == clusterCfg->FrSMCheckWakeupReason) ) {
/* @req FrSm081 Trans T10 (b) */
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_SYNC_LOSS);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_FAILED);
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.controllerMode[clusterId].startupCounter = 1;
UPDATE_TIMER2(clusterId);
UPDATE_TIMER3(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if((FR_POCSTATE_NORMAL_PASSIVE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) {
/* @req FrSm087 Trans T16 (b)*/
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_SYNC_LOSS);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_FAILED);
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
UPDATE_TIMER3(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_ONLINE_PASSIVE;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if(((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE ==FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) &&
(FALSE == clusterCfg->FrSMCheckWakeupReason) && (TRUE == clusterCfg->FrSMIsWakeupEcu) ) {
/* @req FrSm0200 */ /* Trans T20 (b) */
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_SYNC_LOSS );
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_FAILED);
FrSM_Internal_Return_WakeUp_state(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_WAKEUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
/* Reset Variables of WakeUp state to repeat wakeUp state */
FrSM_Internal_WakeUp_Reset_Var(clusterId);
FrSM_Internal.controllerMode[clusterId].wakeupCounter = 1;
} else if((FR_POCSTATE_NORMAL_ACTIVE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze) &&
(FR_SLOTMODE_ALL == FrSM_Internal.controllerMode[clusterId].pocCcStatus.SlotMode)) {
/* @req FrSm157 Trans T101 */
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_ONLINE;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
FrSM_Internal_ComM_BusSM_ModeIndication(clusterId,COMM_FULL_COMMUNICATION);
} else { /* Do Nothing */ }
}
#if defined(USE_BSWM)
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
} else { /* Do Nothing */ }
#endif
}
/**
* @brief function performs online Passive State actions
* @param clusterId
*/
static void FrSM_Internal_Online_Passive_Actions(uint8 clusterId)
{
uint8 controller;
const FrSM_Internal_ClusterType* cluster;
const FrSM_ClusterType* clusterCfg;
cluster = &FrSM_Internal.clusterStatus[clusterId];
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(COMM_NO_COMMUNICATION == cluster->reqComMode) {
/* Function call to enter into HALT state - Trans T14*/
FrSM_Internal_HaltState_Trans(clusterId);
} else {
/* proceed if timer T3 is not expired. trans T33*/
/* @req FrSm173 */
if(FALSE == FrSM_Internal.controllerMode[clusterId].t3_IsNotActive) {
if(((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) &&
(TRUE == clusterCfg->FrSMCheckWakeupReason) ) {
/* @req FrSm117 Trans T17 */
FrSM_Internal.controllerMode[clusterId].wakeupType = NO_WAKEUP;
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
(void)FrIf_StartCommunication(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.controllerMode[clusterId].startupCounter = 1;
UPDATE_TIMER2(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_STARTUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if(((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze)) &&
(FALSE == clusterCfg->FrSMCheckWakeupReason) && (TRUE == clusterCfg->FrSMIsWakeupEcu) ) {
/* @req FrSm0201 */ /* Trans 20 (c) */
FrSM_Internal_Return_WakeUp_state(clusterId);
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_WAKEUP;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
/* Reset Variables of WakeUp state to repeat wakeUp state */
FrSM_Internal_WakeUp_Reset_Var(clusterId);
FrSM_Internal.controllerMode[clusterId].wakeupCounter = 1;
} else if((FR_POCSTATE_NORMAL_ACTIVE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze) &&
(FR_SLOTMODE_ALL == FrSM_Internal.controllerMode[clusterId].pocCcStatus.SlotMode)) {
/* @req FrSm086 Trans T15 */
(void)FrIf_SetState(clusterId, FRIF_GOTO_ONLINE);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
FrSM_Internal_ComM_BusSM_ModeIndication(clusterId,COMM_FULL_COMMUNICATION);
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_ONLINE;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
} else if((FR_POCSTATE_NORMAL_ACTIVE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) &&
(FALSE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze) &&
(FR_SLOTMODE_ALL != FrSM_Internal.controllerMode[clusterId].pocCcStatus.SlotMode)) {
/* @req FrSm158 Trans T115 */
(void)FrIf_SetState(clusterId, FRIF_GOTO_ONLINE);
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterSyncLossDemEventId), clusterCfg->FrSMClusterSyncLossDemEventId, DEM_EVENT_STATUS_PASSED);
FrSM_Internal.controllerMode[clusterId].t3Started = FALSE;
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_KEYSLOT_ONLY;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
}
else {
/* Do Nothing */
}
} else {
/* @req FrSm173 trans T33 */
/* synchronisation has been fail, report to FrNm */
FrNm_StartupError(clusterCfg->FrSMComMNetworkHandle);
UPDATE_TIMER3(clusterId); //Reset t3 timer
/* @req FrSm046 */
FRSM_DET_REPORT_WITHOUT_RET(FRSM_SERVICE_ID_MAIN_FUNCTION, FRSM_E_CLUSTER_STARTUP);
/* the timer t3 expires, the FrSM will report the production error */
FRSM_DEM_REPORTSTATUS((DEM_EVENT_ID_NULL == clusterCfg->FrSMClusterStartUpDemEventId), clusterCfg->FrSMClusterStartUpDemEventId, DEM_EVENT_STATUS_FAILED);
}
}
#if defined(USE_BSWM)
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
} else { /* Do Nothing */ }
#endif
}
/**
* @brief Function does transition from halt state to Ready state
* @param clusterId
*/
static void FrSM_Internal_Halt_State_Actions(uint8 clusterId)
{
uint8 controller;
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if((FR_POCSTATE_HALT == FrSM_Internal.controllerMode[clusterId].pocCcStatus.State) ||
(TRUE == FrSM_Internal.controllerMode[clusterId].pocCcStatus.Freeze) ) {
/* @req FrSm083 */ /* Transition T11 */
/* Set TRCV mode to stand by and init all CC */
SchM_Enter_FrSM_EA_0(); /* To satisfy the FrSm178 requirement - added the critical section */
for (controller = 0; controller < clusterCfg->FrSMControllerCount ; controller++) {
if(TRUE == clusterCfg->FrSMControllerRef[controller].FrTrcvAvailable){
if(TRUE == clusterCfg->FrSMControllerRef[controller].FrSMIsDualChannelNode) {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_A,FRTRCV_TRCVMODE_STANDBY );
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_B,FRTRCV_TRCVMODE_STANDBY );
} else {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[controller].FrIfControllerId,clusterCfg->FrSMControllerRef[controller].FrSMChannel, FRTRCV_TRCVMODE_STANDBY );
}
} else { /* Do Nothing */ }
/* Call FrIf_ControllerInit to enter into Ready state */
(void)FrIf_ControllerInit(clusterCfg->FrSMControllerRef[controller].FrIfControllerId);
}
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_READY;
FrSM_Internal.clusterStatus[clusterId].bswMindication = TRUE;
SchM_Exit_FrSM_EA_0(); /* Enable interrupt after state has been changed to READY */
} else {
/* Do Nothing */
}
#if defined(USE_BSWM)
if(TRUE == FrSM_Internal.clusterStatus[clusterId].bswMindication) {
FrSM_Internal_BswM_Indication(clusterId);
} else { /* Do Nothing */ }
#endif
}
/** APIs */
/* Init function for FrSM */
/* @req FrSm013 */
/**
*
* @param FrSM_ConfigPtr
*/
void FrSM_Init( const FrSM_ConfigType* FrSM_ConfigPtr )
{
uint8 clstrCount;
uint8 controller;
/* @req FrSm015 */
FRSM_DET_REPORTERROR((NULL != FrSM_ConfigPtr),FRSM_SERVICE_ID_INIT,FRSM_E_NULL_PTR);
/* @req FrSm127 */
FrSM_ConfigPointer = FrSM_ConfigPtr;
/* loop for number of cluster and initialize all variables */
for ( clstrCount = 0; clstrCount < FrSM_ConfigPointer->FrSMClusterCount; ++clstrCount) {
FrSM_Internal.clusterStatus[clstrCount].reqComMode = COMM_NO_COMMUNICATION;
FrSM_Internal.clusterStatus[clstrCount].curComMode = COMM_NO_COMMUNICATION;
FrSM_Internal.clusterStatus[clstrCount].frSMClusterPassiveState = FRSM_ECU_ACTIVE;
FrSM_Internal.clusterStatus[clstrCount].bswMindication = FALSE;
/* First CC of several CC's cluster are set to default values */
FrSM_Internal.controllerMode[clstrCount].controllerId = FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[CONTROLLER_0].FrIfControllerId;
FrSM_Internal.controllerMode[clstrCount].wakeUpAction = ECHO_MODE_OFF;
FrSM_Internal.controllerMode[clstrCount].wakeupFinished = FALSE;
FrSM_Internal.controllerMode[clstrCount].startupCounter = 0;
FrSM_Internal.controllerMode[clstrCount].t1_IsActive = FALSE;
FrSM_Internal.controllerMode[clstrCount].timerT1 = 0;
FrSM_Internal.controllerMode[clstrCount].t2_IsActive = FALSE;
FrSM_Internal.controllerMode[clstrCount].timerT2 = 0;
FrSM_Internal.controllerMode[clstrCount].t3_IsNotActive = TRUE;
FrSM_Internal.controllerMode[clstrCount].timerT3 = 0;
FrSM_Internal.controllerMode[clstrCount].wakeupCounter = 0;
FrSM_Internal.controllerMode[clstrCount].busTrafficDetected = FALSE;
FrSM_Internal.controllerMode[clstrCount].wakeupTransmitted = FALSE;
FrSM_Internal.controllerMode[clstrCount].t2action = FALSE;
for(controller = 0; controller < FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerCount; controller++) {
/* @req FrSm119 */
(void)FrIf_ControllerInit(FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrIfControllerId);
/* @req FrSm176 */ /* Check TRCV enabled for specific CC in Cluster */
if(TRUE == FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrTrcvAvailable) {
/* FrSM is concurrently in state FRSM_READY, the transceivers are in set into mode FRTRCV_TRCVMODE_STANDBY */
if(TRUE == FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrSMIsDualChannelNode) {
(void)FrIf_SetTransceiverMode(FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_A,FRTRCV_TRCVMODE_STANDBY );
(void)FrIf_SetTransceiverMode(FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrIfControllerId,FR_CHANNEL_B,FRTRCV_TRCVMODE_STANDBY );
} else
{
(void)FrIf_SetTransceiverMode(FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrIfControllerId,
FrSM_ConfigPointer->FrSMClusters[clstrCount].FrSMControllerRef[controller].FrSMChannel, FRTRCV_TRCVMODE_STANDBY );
}
}
}
/* @req FrSm126 */
FrSM_Internal.clusterStatus[clstrCount].frSMClusterState = FRSM_READY;
}
/* @req FrSm128 */
FrSM_Internal.initStatus = FRSM_STATUS_INIT;
}
/* @req FrSm020 */
/**
*
* @param NetworkHandle
* @param ComM_Mode
* @return
*/
Std_ReturnType FrSM_RequestComMode( NetworkHandleType NetworkHandle, ComM_ModeType ComM_Mode )
{
uint8 controller;
uint8 clusterId;
/* @req FrSm061 */
FRSM_DET_REPORTERROR((FRSM_STATUS_INIT == FrSM_Internal.initStatus),FRSM_SERVICE_ID_REQUEST_COM_MODE, FRSM_E_UNINIT, E_NOT_OK);
/* @req FrSm018 */
FRSM_DET_REPORTERROR(((NetworkHandle < COMM_CHANNEL_COUNT) && (FrSM_ConfigPointer->FrSMClusterLookups[NetworkHandle] != INVALID_FR_NW_HANDLE)),FRSM_SERVICE_ID_REQUEST_COM_MODE,FRSM_E_INV_HANDLE,E_NOT_OK);
/* @req FrSm019 */
FRSM_DET_REPORTERROR(!((COMM_NO_COMMUNICATION != ComM_Mode) && (COMM_SILENT_COMMUNICATION != ComM_Mode) && (COMM_FULL_COMMUNICATION != ComM_Mode)),FRSM_SERVICE_ID_REQUEST_COM_MODE,FRSM_E_INV_MODE,E_NOT_OK);
/* @req FrSm141 */
FRSM_DET_REPORTERROR((COMM_SILENT_COMMUNICATION != ComM_Mode),FRSM_SERVICE_ID_REQUEST_COM_MODE,FRSM_E_INV_MODE,E_NOT_OK);
/* @req FrSm021 */
clusterId = FrSM_ConfigPointer->FrSMClusterLookups[NetworkHandle];
FrSM_Internal.clusterStatus[clusterId].reqComMode = ComM_Mode;
/* @req FrSm022 */
if(( COMM_NO_COMMUNICATION == ComM_Mode) && (COMM_FULL_COMMUNICATION == FrSM_Internal.clusterStatus[clusterId].curComMode)) {
/* Transition T09 (a) */ /* @req FrSm080 */
/* Set state to Offline */
(void)FrIf_SetState(clusterId, FRIF_GOTO_OFFLINE);
/* Halt Communication of all CCs */
for(controller =0 ; controller < FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMControllerCount; controller++ )
{
(void)FrIf_HaltCommunication(FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMControllerRef[controller].FrIfControllerId);
}
/* Change Com mode and indicate to Upper ComM layer */
FrSM_Internal.clusterStatus[clusterId].curComMode = ComM_Mode;
ComM_BusSM_ModeIndication(FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMComMNetworkHandle, &ComM_Mode);
/* Cluster state set to Halt Req */
FrSM_Internal.clusterStatus[clusterId].frSMClusterState = FRSM_HALT_REQ;
/* Indication to BswM layer */
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMComMNetworkHandle,FRSM_BSWM_HALT_REQ);
} else {
BswM_FrSM_CurrentState(FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMComMNetworkHandle,FRSM_BSWM_HALT_REQ_ECU_PASSIVE);
}
} else {
/* Do nothing */
}
return E_OK;
}
/** This service shall put out the current communication mode of a FR network. */
/* @req FrSm024 */
/**
*
* @param NetworkHandle
* @param ComM_ModePtr
* @return
*/
Std_ReturnType FrSM_GetCurrentComMode( NetworkHandleType NetworkHandle, ComM_ModeType* ComM_ModePtr )
{
uint8 clusterId;
/* @req FrSm060 */
FRSM_DET_REPORTERROR((FRSM_STATUS_INIT == FrSM_Internal.initStatus),FRSM_SERVICE_ID_GET_CURRENT_COM_MODE, FRSM_E_UNINIT, E_NOT_OK);
/* @req FrSm028 */
FRSM_DET_REPORTERROR((NULL != ComM_ModePtr),FRSM_SERVICE_ID_GET_CURRENT_COM_MODE,FRSM_E_NULL_PTR,E_NOT_OK);
/* @req FrSm027 */
FRSM_DET_REPORTERROR(((NetworkHandle < COMM_CHANNEL_COUNT) && (FrSM_ConfigPointer->FrSMClusterLookups[NetworkHandle] != INVALID_FR_NW_HANDLE)),FRSM_SERVICE_ID_GET_CURRENT_COM_MODE,FRSM_E_INV_HANDLE,E_NOT_OK);
/* Get Cluster ID mapped to CoM channel */
clusterId = FrSM_ConfigPointer->FrSMClusterLookups[NetworkHandle];
/* @req FrSm025 */
*ComM_ModePtr = FrSM_Internal.clusterStatus[clusterId].curComMode;
return E_OK;
}
/* @req FrSm172 */
/**
*
* @param NetworkHandle
* @return
*/
Std_ReturnType FrSM_AllSlots( NetworkHandleType NetworkHandle )
{
Std_ReturnType status;
uint8 controller;
Std_ReturnType allSlotStatus[FRSM_CLUSTER_COUNT];
uint8 clusterId;
status = E_OK;
/* @req FrSm169 */
FRSM_DET_REPORTERROR((FRSM_STATUS_INIT == FrSM_Internal.initStatus),FRSM_SERVICE_ID_ALL_SLOTS, FRSM_E_UNINIT, E_NOT_OK);
/* @req FrSm168 */
FRSM_DET_REPORTERROR(((NetworkHandle < COMM_CHANNEL_COUNT) && (FrSM_ConfigPointer->FrSMClusterLookups[NetworkHandle] != INVALID_FR_NW_HANDLE)),FRSM_SERVICE_ID_ALL_SLOTS,FRSM_E_INV_HANDLE,E_NOT_OK);
/* Get Cluster ID mapped to CoM channel */
clusterId = FrSM_ConfigPointer->FrSMClusterLookups[NetworkHandle];
for(controller = 0; controller < FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMControllerCount; controller++) {
/* @req FrSm171 */
allSlotStatus[clusterId] = FrIf_AllSlots(FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMControllerRef[controller].FrIfControllerId);
if(allSlotStatus[clusterId] != E_OK) {
status = E_NOT_OK;
break;
} else {
/* Do nothing */
}
}
return status;
}
/* @req FrSm174 */
/**
*
* @param FrSM_Passive
* @return
*/
Std_ReturnType FrSM_SetEcuPassive( boolean FrSM_Passive )
{
uint8 clstrCount;
/* @req FrSm179 */
FRSM_DET_REPORTERROR((FRSM_STATUS_INIT == FrSM_Internal.initStatus),FRSM_SERVICE_ID_SET_ECU_PASSIVE, FRSM_E_UNINIT, E_NOT_OK);
/* @req FrSm177 */
for ( clstrCount = 0; clstrCount < FrSM_ConfigPointer->FrSMClusterCount; ++clstrCount) {
if(TRUE == FrSM_Passive) {
FrSM_Internal.clusterStatus[clstrCount].frSMClusterPassiveState = FRSM_ECU_PASSIVE;
}else {
FrSM_Internal.clusterStatus[clstrCount].frSMClusterPassiveState = FRSM_ECU_ACTIVE;
}
/* @req FrSm178 */
if(FRSM_READY != FrSM_Internal.clusterStatus[clstrCount].frSMClusterState) {
FrSM_Internal_TrcvNormal(clstrCount);
}
}
return E_OK;
}
/* @req FrSm030 */ /* one state machine impl per cluster */
/**
*
* @param clusterId
*/
void FrSM_MainFunction(uint8 clusterId)
{
/* @req FrSm181 */
if( FRSM_STATUS_UNINIT == FrSM_Internal.initStatus ) {
#ifdef HOST_TEST
ReportErrorStatus();
#endif
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return;
}
/* function call to know POC status for CC */
FrSM_Internal_PocStatus(clusterId);
/* @req FrSm048 */
switch(FrSM_Internal.clusterStatus[clusterId].frSMClusterState) {
case FRSM_READY:
/* function call to know wakeup reason to first CC of cluster */
FrSM_Internal_WakeReason(clusterId);
/* function to change state from READY to WAKEUP/STARTUP */
FrSM_Internal_ReadyToWakeUpStartUp_Trans(clusterId);
break;
case FRSM_WAKEUP:
/* Function call to know Wake Type and to handle to No Com request */
FrSM_Internal_WakeUp_Pattern(clusterId);
/* function call to change state from WAKEUP to STARTUP */
FrSM_Internal_WakeupToStartUp_Trans(clusterId);
break;
case FRSM_STARTUP:
/* Function call for StartUp to other state transition */
FrSM_Internal_StartUp_Trans(clusterId);
break;
case FRSM_HALT_REQ:
/* Function call to transition from HALT to READY state */
FrSM_Internal_Halt_State_Actions(clusterId);
break;
case FRSM_ONLINE:
case FRSM_LOW_NUMBER_OF_COLDSTARTERS:
/* function call to know number of startup frames */
FrSM_Internal_StartupFrame_No(clusterId);
FrSM_Internal_Online_Trans(clusterId);
break;
case FRSM_ONLINE_PASSIVE:
FrSM_Internal_Online_Passive_Actions(clusterId);
break;
case FRSM_KEYSLOT_ONLY:
FrSM_Internal_KeySlot_Actions(clusterId);
break;
default :
break;
}
/* Function call to Update timer Variables*/
FrSM_Internal_UpdateTimer(clusterId);
}
#ifdef HOST_TEST
FrSM_InternalType* readinternal_status(void );
FrSM_InternalType* readinternal_status(void)
{
return &FrSM_Internal;
}
#endif
|
2301_81045437/classic-platform
|
communication/FrSM/src/FrSM.c
|
C
|
unknown
| 72,581
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "FrSM.h"
#include "FrSM_Internal.h"
#if defined(USE_BSWM)
#include "BswM_FrSM.h"
#endif
extern const FrSM_ConfigType* FrSM_ConfigPointer;
extern FrSM_InternalType FrSM_Internal;
/**
* @brief FE_TRCV_NORMAL functionality
* @param clusterId
*/
void FrSM_Internal_TrcvNormal(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
uint8 cltr;
for(cltr = 0; cltr < clusterCfg->FrSMControllerCount; cltr++) {
/* Check TRCV enabled for specific CC in Cluster */
if(TRUE == clusterCfg->FrSMControllerRef[cltr].FrTrcvAvailable) {
if(FRSM_ECU_ACTIVE != FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState) {
if(TRUE == clusterCfg->FrSMControllerRef[cltr].FrSMIsDualChannelNode) {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_A,FRTRCV_TRCVMODE_RECEIVEONLY );
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_B,FRTRCV_TRCVMODE_RECEIVEONLY );
(void)FrIf_ClearTransceiverWakeup( clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_A);
(void)FrIf_ClearTransceiverWakeup( clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_B);
} else {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,clusterCfg->FrSMControllerRef[cltr].FrSMChannel, FRTRCV_TRCVMODE_RECEIVEONLY );
(void)FrIf_ClearTransceiverWakeup(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,clusterCfg->FrSMControllerRef[cltr].FrSMChannel);
}
} else {
if(TRUE == clusterCfg->FrSMControllerRef[cltr].FrSMIsDualChannelNode) {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_A,FRTRCV_TRCVMODE_NORMAL );
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_B,FRTRCV_TRCVMODE_NORMAL );
(void)FrIf_ClearTransceiverWakeup( clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_A);
(void)FrIf_ClearTransceiverWakeup( clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,FR_CHANNEL_B);
} else {
(void)FrIf_SetTransceiverMode(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,clusterCfg->FrSMControllerRef[cltr].FrSMChannel, FRTRCV_TRCVMODE_NORMAL );
(void)FrIf_ClearTransceiverWakeup(clusterCfg->FrSMControllerRef[cltr].FrIfControllerId,clusterCfg->FrSMControllerRef[cltr].FrSMChannel);
}
}
}
}
}
/**
* @brief Function updates all timers after every main function call if applicable
* @param clusterId
*/
void FrSM_Internal_UpdateTimer(uint8 clusterId)
{
/* t1_IsActive flag is checked only if Started was set to true. If t1_IsActive flag is false it means a timeout. */
if((TRUE == FrSM_Internal.controllerMode[clusterId].t1Started) &&
(FrSM_Internal.controllerMode[clusterId].timerT1 < FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMDurationT1)) {
FrSM_Internal.controllerMode[clusterId].timerT1++;
FrSM_Internal.controllerMode[clusterId].t1_IsActive = TRUE;
} else {
/* @req FrSm142 */
FrSM_Internal.controllerMode[clusterId].t1_IsActive = FALSE;
}
/* t2_IsActive flag is checked only if Started was set to true. If t2_IsActive flag is false it means a timeout. */
if((TRUE == FrSM_Internal.controllerMode[clusterId].t2Started) &&
(FrSM_Internal.controllerMode[clusterId].timerT2 < FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMDurationT2)) {
FrSM_Internal.controllerMode[clusterId].timerT2++;
FrSM_Internal.controllerMode[clusterId].t2_IsActive = TRUE;
} else {
/* @req FrSm143 */
FrSM_Internal.controllerMode[clusterId].t2_IsActive = FALSE;
}
/* t3_IsNotActive flag is checked only if Started was set to true. If t3_IsNotActive flag is true it means a timeout. */
if((TRUE == FrSM_Internal.controllerMode[clusterId].t3Started) &&
(FrSM_Internal.controllerMode[clusterId].timerT3 < FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMDurationT3)) {
FrSM_Internal.controllerMode[clusterId].timerT3++;
FrSM_Internal.controllerMode[clusterId].t3_IsNotActive = FALSE;
} else {
FrSM_Internal.controllerMode[clusterId].t3_IsNotActive = TRUE;
}
}
/**
* @brief Function updates BswM layer about FrSm cluster state
* @param clusterId
*/
#if defined(USE_BSWM)
/* @req FrSm145 */
void FrSM_Internal_BswM_Indication(uint8 clusterId)
{
const FrSM_ClusterType* clusterCfg;
clusterCfg = &FrSM_ConfigPointer->FrSMClusters[clusterId];
if(FRSM_WAKEUP == FrSM_Internal.clusterStatus[clusterId].frSMClusterState) {
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_WAKEUP);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_WAKEUP_ECU_PASSIVE);
}
} else if(FRSM_STARTUP == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_STARTUP);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_STARTUP_ECU_PASSIVE);
}
} else if(FRSM_HALT_REQ == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_HALT_REQ);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_HALT_REQ_ECU_PASSIVE);
}
} else if(FRSM_ONLINE == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_ONLINE);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_ONLINE_ECU_PASSIVE);
}
} else if(FRSM_ONLINE_PASSIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_ONLINE_PASSIVE);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_ONLINE_PASSIVE_ECU_PASSIVE);
}
} else if(FRSM_KEYSLOT_ONLY == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_KEYSLOT_ONLY);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_KEYSLOT_ONLY_ECU_PASSIVE);
}
} else if(FRSM_LOW_NUMBER_OF_COLDSTARTERS == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_LOW_NUMBER_OF_COLDSTARTERS);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_LOW_NUMBER_OF_COLDSTARTERS_ECU_PASSIVE);
}
} else if(FRSM_READY == FrSM_Internal.clusterStatus[clusterId].frSMClusterState){
if(FRSM_ECU_ACTIVE == FrSM_Internal.clusterStatus[clusterId].frSMClusterPassiveState)
{
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_READY);
} else {
BswM_FrSM_CurrentState(clusterCfg->FrSMComMNetworkHandle,FRSM_BSWM_READY_ECU_PASSIVE);
}
} else {
/* Do Nothing */
}
FrSM_Internal.clusterStatus[clusterId].bswMindication = FALSE;
}
#endif
|
2301_81045437/classic-platform
|
communication/FrSM/src/FrSM_Internal.c
|
C
|
unknown
| 9,296
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRSM_INTERNAL_H_
#define FRSM_INTERNAL_H_
#include "FrSM.h"
#include "FrIf.h"
//lint -emacro(904,FRSM_DET_REPORTERROR) //904 PC-Lint exception to MISRA 14.7 (validate DET macros).
typedef enum {
FRSM_STATUS_UNINIT,
FRSM_STATUS_INIT
}FrSM_Internal_InitStatusType;
/* @req FrSm176 */
typedef enum {
FRSM_ECU_ACTIVE,
FRSM_ECU_PASSIVE
}FrSM_Internal_Passive_State;
/* @req FrSm032 */
typedef enum {
FRSM_READY,
FRSM_WAKEUP,
FRSM_STARTUP,
FRSM_HALT_REQ,
FRSM_ONLINE,
FRSM_ONLINE_PASSIVE,
FRSM_KEYSLOT_ONLY,
FRSM_LOW_NUMBER_OF_COLDSTARTERS,
}FrSM_Internal_Cluster_State;
typedef enum{
SINGLE_CHANNEL_WAKEUP,
DUAL_CHANNEL_WAKEUP,
DUAL_CHANNEL_WAKEUPFORWARD,
DUAL_CHANNEL_ECHO_WAKEUP,
NO_WAKEUP
}FrSM_Internal_Wakeup_Type;
typedef enum{
NO_ACTION,
ECHO_MODE_OFF,
ECHO_MODE_ON
}FrSM_Internal_Wakeup_Action;
typedef enum {
NO_WU_BY_BUS,
PARTIAL_WU_BY_BUS,
ALL_WU_BY_BUS,
}FrSM_Internal_WakeType;
typedef struct {
uint32 timerT1;
uint32 timerT2;
uint32 timerT3;
uint16 wakeupCounter;
uint8 controllerId;
uint8 startupCounter;
uint8 wakeupRxstatus;
Fr_POCStatusType pocCcStatus;
FrSM_Internal_Wakeup_Type wakeupType;
Fr_ChannelType channelType;
FrSM_Internal_Wakeup_Action wakeUpAction;
FrSM_Internal_WakeType wuReason;
boolean wakeupTransmitted;
boolean busTrafficDetected;
boolean allChannelsAwake;
boolean t1_IsActive;
boolean t2_IsActive;
boolean t3_IsNotActive;
boolean wakeupFinished;
boolean lowNumberOfColdstarters;
boolean t1Started;
boolean t2Started;
boolean t3Started;
boolean t2action;
}FrSM_Internal_CtrlStatusType;
typedef struct {
ComM_ModeType reqComMode;
ComM_ModeType curComMode;
FrSM_Internal_Cluster_State frSMClusterState;
FrSM_Internal_Passive_State frSMClusterPassiveState;
boolean bswMindication;
}FrSM_Internal_ClusterType;
typedef struct {
FrSM_Internal_ClusterType* clusterStatus;
FrSM_Internal_CtrlStatusType* controllerMode;
FrSM_Internal_InitStatusType initStatus;
}FrSM_InternalType;
void FrSM_Internal_TrcvNormal(uint8 clusterId);
void FrSM_Internal_UpdateTimer(uint8 clusterId);
#if defined(USE_BSWM)
void FrSM_Internal_BswM_Indication(uint8 clusterId);
#endif
#define UPDATE_TIMER1(clusterId) if(0 != FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMDurationT1) { \
FrSM_Internal.controllerMode[clusterId].t1Started = TRUE; \
FrSM_Internal.controllerMode[clusterId].timerT1 = 0; \
}
#define UPDATE_TIMER2(clusterId) if(0 != FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMDurationT2) { \
FrSM_Internal.controllerMode[clusterId].t2Started = TRUE; \
FrSM_Internal.controllerMode[clusterId].timerT2 = 0; \
}
#define UPDATE_TIMER3(clusterId) if(0 != FrSM_ConfigPointer->FrSMClusters[clusterId].FrSMDurationT3) { \
FrSM_Internal.controllerMode[clusterId].t3Started = TRUE; \
FrSM_Internal.controllerMode[clusterId].timerT3 = 0; \
}
/* @req FrSm044 */
/* @req FrSm045 */
#if (FRSM_DEV_ERROR_DETECT == STD_ON)
#define FRSM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
(void)Det_ReportError(FRSM_MODULE_ID, 0, _api, _error); \
return __VA_ARGS__; \
}
#else
#define FRSM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
return __VA_ARGS__; \
}
#endif
#if (FRSM_DEV_ERROR_DETECT == STD_ON)
#define FRSM_DET_REPORT_WITHOUT_RET(_api, _error) (void)Det_ReportError(FRSM_MODULE_ID, 0, _api, _error)
#else
#define FRSM_DET_REPORT_WITHOUT_RET(serviceId, errorId)
#endif
#if defined(USE_DEM)
#define FRSM_DEM_REPORTSTATUS(_cond, _demid, _status) \
if (!_cond) { \
(void)Dem_SetEventStatus(_demid, _status); \
}
#else
#define FRSM_DEM_REPORTSTATUS(_cond, _demid, _status)
#endif
#endif /* FRSM_INTERNAL_H_ */
|
2301_81045437/classic-platform
|
communication/FrSM/src/FrSM_Internal.h
|
C
|
unknown
| 5,505
|
#FrTp
obj-$(USE_FRTP) += FrTp.o
obj-$(USE_FRTP) += FrTp_PBcfg.o
obj-$(USE_FRTP) += FrTp_Lcfg.o
vpath-$(USE_FRTP) += $(ROOTDIR)/communication/FrTp/src
inc-$(USE_FRTP) += $(ROOTDIR)/communication/FrTp/inc
|
2301_81045437/classic-platform
|
communication/FrTp/FrTp.mod.mk
|
Makefile
|
unknown
| 211
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRTP_H_
#define FRTP_H_
/* @req FRTP1004 */
#include "FrTp_Types.h"
#include "FrTp_Cbk.h" /* @req FRTP1135 */
#define FRTP_VENDOR_ID 60u
#define FRTP_MODULE_ID 36u
#define FRTP_AR_RELEASE_MAJOR_VERSION 4u
#define FRTP_AR_RELEASE_MINOR_VERSION 0u
#define FRTP_AR_RELEASE_REVISION_VERSION 3u
#define FRTP_AR_MAJOR_VERSION FRTP_AR_RELEASE_MAJOR_VERSION
#define FRTP_AR_MINOR_VERSION FRTP_AR_RELEASE_MINOR_VERSION
#define FRTP_AR_PATCH_VERSION FRTP_AR_RELEASE_REVISION_VERSION
#define FRTP_SW_MAJOR_VERSION 1u
#define FRTP_SW_MINOR_VERSION 0u
#define FRTP_SW_PATCH_VERSION 0u
#include "FrTp_Cfg.h"
#include "FrIf.h"
/* @req FRTP1157 */
/*
* Errors described by FrTp 7.7.3 Error classification.
*****************************************************/
/** @req FRTP1132 */ /** @req FRTP1111 */
#define FRTP_E_UNINIT 0x01u
#define FRTP_E_NULL_PTR 0x02u
#define FRTP_E_INVALID_PDU_SDU_ID 0x03u
#define FRTP_E_INVALID_PARAMETER 0x04u
#define FRTP_E_SEG_ERROR 0x05u
#define FRTP_E_UMSG_LENGTH_ERROR 0x06u
#define FRTP_E_NO_CHANNEL 0x07u
/*
* Service IDs for FrTP function definitions.
*/
#define FRTP_SERVICE_ID_INIT 0x00u
#define FRTP_SERVICE_ID_GET_VERSION_INFO 0x27u
#define FRTP_SERVICE_ID_SHUTDOWN 0x01u
#define FRTP_SERVICE_ID_TRANSMIT 0x02u
#define FRTP_SERVICE_ID_CANCEL_TRANSMIT_REQUEST 0x03u
#define FRTP_SERVICE_ID_CHANGE_PARAMETER 0x04u
#define FRTP_SERVICE_ID_CANCEL_RECEIVE 0x08u
#define FRTP_SERVICE_ID_TRIGGER_TRANSMIT 0x41u
#define FRTP_SERVICE_ID_RX_INDICATION 0x42u
#define FRTP_SERVICE_ID_TX_CONFIRMATION 0x40u
#define FRTP_SERVICE_ID_MAIN_FUNCTION 0x10u
#define FRTP_INVALID_PDU_ID 0xFFFFu
#define FRTP_NO_RETRY 0u
#define FRTP_ACK_WITH_RETRY 1u
/* 8.3.1 Standard functions */
/* This service returns the version information of this module. */
/* @req FRTP215 */
#if ( FRTP_VERSION_INFO_API == STD_ON ) /* @req FRTP498 */
void FrTp_GetVersionInfo(Std_VersionInfoType* versioninfo);
#endif /* FRTP_VERSION_INFO_API */
/* This service initializes all global variables of a FlexRay Transport Layer instance
and set it in the idle state */
/* @req FRTP147 */
void FrTp_Init(const FrTp_ConfigType* ConfigPtr);
/*This service closes all pending transport protocol connections by simply stopping
operation, frees all resources and stops the FrTp Module */
/* @req FRTP148 */
void FrTp_Shutdown(void);
/*This service is utilized to request the transfer of data*/
/* @req FRTP149 */
Std_ReturnType FrTp_Transmit(PduIdType FrTpTxSduId, const PduInfoType* FrTpTxSduInfoPtr);
/*This service primitive is used to cancel the transfer of pending Fr N-SDUs.*/
/* @req FRTP150 */
Std_ReturnType FrTp_CancelTransmit(PduIdType FrTpTxSduId);
/*Request to change transport protocol parameter BandwithControl.*/
/* !req FRTP151 */
Std_ReturnType FrTp_ChangeParameter( PduIdType id, TPParameterType parameter, uint16 value);
/*this API with the corresponding RxSduId the currently ongoing data
reception is terminated immediately */
/* @req FRTP1172 */
Std_ReturnType FrTp_CancelReceive(PduIdType FrTpRxSduId);
/*Schedules the FlexRay TP. (Entry point for scheduling)*/
/* @req FRTP162 */
void FrTp_MainFunction(void);
#endif /* FRTP_H_ */
|
2301_81045437/classic-platform
|
communication/FrTp/inc/FrTp.h
|
C
|
unknown
| 4,333
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRTP_CBK_H_
#define FRTP_CBK_H_
/*The lower layer communication module requests the buffer of the SDU for
transmission from the upper layer module. */
/* @req FRTP154 */
Std_ReturnType FrTp_TriggerTransmit(PduIdType TxPduId,PduInfoType* PduInfoPtr);
/* Indication of a received I-PDU from a lower layer communication module. */
/* @req FRTP152 */
void FrTp_RxIndication(PduIdType RxPduId,PduInfoType* PduInfoPtr);
/* The lower layer communication module confirms the transmission of an I-PDU.*/
/* @req FRTP153 */
void FrTp_TxConfirmation(PduIdType TxPduId);
#endif /* FRTP_CBK_H_ */
|
2301_81045437/classic-platform
|
communication/FrTp/inc/FrTp_Cbk.h
|
C
|
unknown
| 1,365
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRTP_TYPES_H_
#define FRTP_TYPES_H_
#include "ComStack_Types.h"
/* @req FRTP1028 */
typedef enum {
FRTP_OFF = 0,
FRTP_ON
} FrTp_StateType;
typedef enum {
FRTP_NO,
FRTP_ACK_WITH_RT
}FrTp_AckType;
typedef enum {
NOT_ACTIVE = 0,
ACTIVE_RX,
ACTIVE_TX,
}FrtpCommType;
typedef enum {
AVAILABLE = 0,
LOCKED_FOR_FC,
LOCKED_FOR_SF_CF_LF,
}FrtpTxPduLockType;
typedef enum{
IDLE =0,
BUSY,
FRTP_STF_RECEIVED,
FRTP_RX_WAIT_STF_SDU_BUFFER,
FRTP_RX_WAIT_CF,
FRTP_RX_WAIT_FC_SENDING,
FRTP_EOB_RECEIVED_WAIT_SDU_BUFFER,
RX_LAST_FRAME,
FRTP_TX_STARTED,
FRTP_TX_WAIT_FOR_FC,
FRTP_TX_SEG_ONGOING,
FRTP_TX_FINISHED,
FRTP_WAIT_FOR_TRIGGER_TRANSMIT,
FRTP_FRIF_ERROR,
}FrTpChnlStateType;
typedef enum {
INVALID_FRAME, /* Not specified by ISO10681 - used as error return type when decoding frame. */
START_FRAME,
START_FRAME_ACK,
CONSECUTIVE_FRAME_1,
CONSECUTIVE_FRAME_2,
CONSECUTIVE_FRAME_EOB,
FLOW_CONTROL_FRAME,
LAST_FRAME
} ISO10681FrameType; /* Different types of Flexray Frames as per ISO10681-2 section 7.4 Table 8 */
typedef struct {
uint16 Source_Address;
uint16 Target_Address;
} ISO10681PduAddressType;
typedef struct {
PduIdType FrTpTxPduId;
PduIdType FrTpFrIfTxPduId;
PduLengthType FrTpTxPduLength;
boolean FrTpImmediateAccess;
}FrTp_TxPduPoolType;
typedef struct {
PduIdType FrTpRxPduId;
PduLengthType FrTpRxPduLength;
}FrTp_RxPduPoolType;
typedef struct {
uint16 FrTpTimeoutCr;
uint16 FrTpTimeoutBs;
uint16 FrTpTimeoutAs;
uint16 FrTpTimeoutAr;
uint16 FrTpTimeFrIf;
uint16 FrTpTimeBuffer;
uint16 FrTpTimeBr;
uint16 FrTpMaxBufferSize;
uint8 FrTpSCexp;
uint8 FrTpMaxRn;
uint8 FrTpMaxNbrOfNPduPerCycle;
uint8 FrTpMaxFrIf;
uint8 FrTpMaxFCWait;
uint8 FrTpMaxAs;
uint8 FrTpMaxAr;
FrTp_AckType FrTpAckType;
}FrTp_ConnectionControlType;
typedef struct {
const FrTp_TxPduPoolType *FrTpTxPduPoolRef;
const FrTp_RxPduPoolType *FrTpRxPduPoolRef;
const FrTp_ConnectionControlType *FrTpConCtrlRef;
uint16 FrTpRa;
uint16 FrTpLa;
PduIdType FrTpRxSduId; /*Reference to a PDU in the global PDU structure.*/
PduIdType FrTpTxSduId; /*Reference to a PDU in the global PDU structure.*/
PduIdType FrTpULRxPduId;
PduIdType FrTpULTxPduId;
uint8 FrTpRxPduRefCount;
uint8 FrTpPoolTxPduCnt;
boolean FrTpBandwidthLimitation;
boolean FrTpMultipleReceiverCon;
}FrTp_ConnectionConfigType;
/** Top level config container for FRTP implementation. */
typedef struct {
const uint8 * FrTpPduIdToFrIfPduIdMap;
const FrTp_ConnectionConfigType *FrTpConnectionConfig;
const PduIdType FrTpTxSduCount;
const PduIdType FrTpRxSduCount;
const PduIdType FrTpRxPducount;
const PduIdType FrTpTxPduCount;
uint8 FrTpConnectionCount;
}FrTp_ConfigType;
#endif /* FRTP_TYPES_H_ */
|
2301_81045437/classic-platform
|
communication/FrTp/inc/FrTp_Types.h
|
C
|
unknown
| 3,978
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req FRTP200 */ /* Each code (*.c) file of the FrTp module shall provide data of version identification as defined in chapter*/
/* @req FRTP141 */ /* PduInfoType is imported by including FrTp.h which includes FrTp_Types.h which includes ComStack_Types.h */
/* @req FRTP1004 */ /* header file structure of the FrTp module */
/* @req FRTP209 */ /* The source code of the FrTp module shall be neither compiler (tool) nor platform (processor) dependent*/
/* @req FRTP1005 */ /* @req FRTP1006*/ /*If no explicit requirement is defined shall follow the specification ISO10681-2*/
/* @req FRTP1033 */ /* FrTp specific types shall be defined in FrTp_Types.h */
/* @req FRTP1007*/ /* @req FRTP1008*/ /* @req FRTP1009*/ /* @req FRTP1010*/ /* @req FRTP1011*/ /* @req FRTP1012*/
/* @req FRTP1164*/ /* @req FRTP1166*/ /* PduInfoType is imported by including FrTp.h which includes FrTp_Types.h which includes ComStack_Types.h */
/* @req FRTP1168*/ /* @req FRTP1165*/ /* @req FRTP1167*/ /* @req FRTP1169 */ /* @req FRTP1170 */ /* @req FRTP1178 */ /* PduInfoType is imported by including FrTp.h which includes FrTp_Types.h*/
/* @req FRTP1055 */ /* Timing behaviour implemented as per requirement */
/* @req FRTP1020 */ /* Based on configuration this can be achived */
/* @req FRTP569 */ /* Configuration parameter genration is done through .xpt file*/
/* @req FRTP1158 */ /* Each header (*.h) file of the FrTp module shall provide data of version identification as defined in chapter*/
/* @req FRTP1133 */ /* FrTp specific types shall be defined in FrTp_Types.h */
/* @req FRTP1109 */ /* MODULE_ID set to 0x24 in FrTp.h */
#include "FrTp.h"
#include "Det.h"
#include "FrIf.h"
#include "SchM_FrTp.h"
#include "PduR_FrTp.h"
#include <string.h>
#include "debug.h"
#include "MemMap.h"
#include "FrTp_Internal.h"
//lint -emacro(904,FRTP_DET_REPORTERROR) //904 PC-Lint exception to MISRA 14.7 (validate DET macros).
#if (FRTP_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
#if defined(USE_DEM)
#include "Dem.h"
#endif
#if !(((FRTP_SW_MAJOR_VERSION == 1) && (FRTP_SW_MINOR_VERSION == 0)) )
#error FrTp: Configuration file expected BSW module version to be 1.0.*
#endif
#if !(((FRTP_AR_RELEASE_MAJOR_VERSION == 4) && (FRTP_AR_RELEASE_MINOR_VERSION == 0)) )
#error FrTp: Configuration file expected AUTOSAR version to be 4.0.*
#endif
/*@req FRTP1037*/ /*@req FRTP206*/ /*@req FRTP1107*/ /*@req FRTP1108*/
#if (FRTP_DEV_ERROR_DETECT == STD_ON)
#define FRTP_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
(void)Det_ReportError(FRTP_MODULE_ID, 0, _api, _error); \
return __VA_ARGS__; \
}
#else
#define FRTP_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
return __VA_ARGS__; \
}
#endif
/* Configuration of FrTp channel */
static const FrTp_ConfigType* FrTp_ConfigPtr = NULL;
/* Internal run time data */
/* @req FRTP1030*/
static FrTp_Internal_RunTimeType FrTp_Internal_RunTime = {
.FrTpState = FRTP_OFF,
};
/* Internal function declarations */
static void FrTp_Internal_TransmitStartFrame(FrTp_Internal_Channel_type* runtimeChnlData);
static void FrTp_Internal_WaitForFlowControl(FrTp_Internal_Channel_type* runtimeChnlData);
static Std_ReturnType FrTp_Internal_PrepareAndSendStartFrame(FrTp_Internal_Channel_type* runtimeChnlData, uint8 framePayloadLength);
static Std_ReturnType FrTp_Internal_SendFrame(FrTp_Internal_Channel_type* runtimeChnlData, PduInfoType* txPduInfo,FrtpCommType commState);
static Std_ReturnType FrTp_Internal_GetConnectionForTxSdu(const PduIdType frtpTxSduId, uint8 *connectionIndex);
static void FrTp_Internal_AssignChannelForTx(const uint8 connectionIndex,const uint8 chnlIndex,FrTp_Internal_Channel_type **runtimeChnlDataAssigned,const PduInfoType* FrTpTxSduInfoPtr);
static void FrTp_Internal_TxBufferRequestError(FrTp_Internal_Channel_type* runtimeChnlData,BufReq_ReturnType BufReqResult );
static void FrTp_Internal_FreeChannel(FrTp_Internal_Channel_type* runtimeChnlData);
static void FrTp_Internal_TransmitFinished(FrTp_Internal_Channel_type* runtimeChnlData);
static void FrTp_Internal_TransmitStatesHandle(FrTp_Internal_Channel_type* runtimeChnlData);
static void FrTp_Internal_TimeoutAs(FrTp_Internal_Channel_type* runtimeChnlData);
static void handelflowcontrolframe(FrTp_Internal_Channel_type *ChannelInternal,PduInfoType* PduInfoPtr);
static Std_ReturnType FrTp_Internal_GetNextFrameType(FrTp_Internal_Channel_type* runtimeChnlData,uint8 *txFrameType,PduLengthType *remainingTxBufferLength);
static PduLengthType FrTp_Internal_FillNextFrame(FrTp_Internal_Channel_type* runtimeChnlData, uint8 txFrameType);
static void FrTp_Internal_SendNextFrame(FrTp_Internal_Channel_type* runtimeChnlData,PduLengthType payloadIndex );
static void FrTp_Internal_HandleFrIfError(FrTp_Internal_Channel_type* runtimeChnlData,FrtpCommType commState);
static void FrTp_Internal_HandleTxCanceled(FrTp_Internal_Channel_type* runtimeChnlData);
static void FrTp_Internal_HandleRecvdFCAck(FrTp_Internal_Channel_type *ChannelInternal,PduInfoType* PduInfoPtr );
static void FrTp_Internal_HandleNextSegFrames(FrTp_Internal_Channel_type* runtimeChnlData);
static ISO10681FrameType getFrameType(const uint8 *sdudataPtr);
static boolean validateConnectionType(PduInfoType* PduInfoPtr,ISO10681FrameType frame,uint8 connection_count);
static void resetRxChannelConfiguration(FrTp_Internal_Channel_type *runtimeInternalChnllData);
static void getFrameAddress(const PduInfoType *PduInfoPtr, ISO10681PduAddressType *frameAddressInfo);
static void sendFlowControlFrame(FrTp_Internal_Channel_type *ChannelInternal, uint8 flowstatus, boolean Retry_flag);
static BufReq_ReturnType copySegmentToPduRRxBuffer(BufReq_ReturnType retun_value,FrTp_Internal_Channel_type *ChannelInternal);
static void handlePdurReturn(BufReq_ReturnType retun_value,FrTp_Internal_Channel_type *ChannelInternal,boolean stf_ack_flag);
static void handleStartFrame(FrTp_Internal_Channel_type *ChannelInternal,PduInfoType *PduInfoPtr);
static boolean handelSequenceError(FrTp_Internal_Channel_type *ChannelInternal);
static void handelconsecutiveframes(FrTp_Internal_Channel_type *ChannelInternal,ISO10681FrameType frameType);
static void handelLastFrame(FrTp_Internal_Channel_type *ChannelInternal);
static void handelpduRwaitcalls(FrTp_Internal_Channel_type *ChannelInternal);
static uint8 frtpManageStfConnections(PduInfoType* PduInfoPtr,PduIdType RxPduId,ISO10681FrameType frameTypelcl,ISO10681PduAddressType frameAddressInfo);
static void frtpManageCfConnections(PduInfoType* PduInfoPtr, ISO10681FrameType frameTypelcl, ISO10681PduAddressType frameAddressInfo);
static void frtpManageFcConnections(PduInfoType* PduInfoPtr, ISO10681PduAddressType frameAddressInfo);
static void handleReceivedFrame(FrTp_Internal_Channel_type *ChannelInternal);
static uint8 frtpRxStfAssignConnections(PduInfoType* PduInfoPtr,uint8 connection_count,ISO10681FrameType frameTypelcl);
static void handelCrTimeout(FrTp_Internal_Channel_type *ChannelInternal);
static void handelArTimeout(FrTp_Internal_Channel_type *ChannelInternal);
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
static void updateBlockPosition(FrTp_Internal_Channel_type *ChannelInternal);
#endif
/**
*
* @param version info
*/
/* This service returns the version information of this module. */
/* @req FRTP215 */
#if ( FRTP_VERSION_INFO_API == STD_ON ) /* @req FRTP498 */
void FrTp_GetVersionInfo(Std_VersionInfoType* versioninfo){
/* @req FRTP1150*/
FRTP_DET_REPORTERROR((NULL != versioninfo),FRTP_SERVICE_ID_GET_VERSION_INFO,FRTP_E_NULL_PTR);
/* @req FRTP202*/
STD_GET_VERSION_INFO(versioninfo, FRTP);
return;
}
#endif /* FRTP_VERSION_INFO_API */
/**
*
* @param ConfigPtr
*/
/* This service initializes all global variables of a FlexRay Transport Layer instance
and set it in the idle state */
/* @req FRTP147 */
void FrTp_Init( const FrTp_ConfigType* ConfigPtr) {
FrTp_Internal_Channel_type* runtimeInternalChnllData;
uint8 channel;
uint8 conIndex;
uint8 pduIndex;
uint8 initCount;
FRTP_DET_REPORTERROR((NULL != ConfigPtr),FRTP_SERVICE_ID_INIT,FRTP_E_NULL_PTR); /* @req FRTP1151 */
if(FrTp_Internal_RunTime.FrTpState == FRTP_ON){
/* This a case of re-initialization and the state is set to off to disable any concurrent frtp APIs*/
FrTp_Internal_RunTime.FrTpState = FRTP_OFF;/* @req FRTP1030*/
#if(FRTP_TRANSMIT_CANCEL_SUPPORT == STD_ON)
/* Processing the channels previously sent TxPdus got TxConfirmation */
for (channel = 0; channel < FRTP_CHANNEL_NUM; channel++) {
runtimeInternalChnllData = &FrTp_Internal_RunTime.FrTpChannels[channel];
if ((runtimeInternalChnllData->FrTpTxChannelState == FRTP_TX_SEG_ONGOING)||(runtimeInternalChnllData->FrTpTxChannelState == FRTP_WAIT_FOR_TRIGGER_TRANSMIT)){
/* Cancel the ongoing transmission */
if(runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef != NULL_PTR){
(void) FrIf_CancelTransmit(runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpFrIfTxPduId);/* @req FRTP1120 */
}
PduR_FrTpTxConfirmation(runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,NTFRSLT_E_CANCELATION_OK);
FrTp_Internal_FreeChannel(runtimeInternalChnllData);
}
}
#endif
}
FrTp_ConfigPtr = ConfigPtr;
/* @req FRTP1035*/ /* @req FRTP1034*/
for(channel =0;channel<FRTP_CHANNEL_NUM;channel++ ) {
runtimeInternalChnllData = &FrTp_Internal_RunTime.FrTpChannels[channel];
FrTp_Internal_FreeChannel(runtimeInternalChnllData);
#if FRTP_FULL_DUPLEX_ENABLE == STD_ON
resetRxChannelConfiguration(runtimeInternalChnllData);
#endif
runtimeInternalChnllData->FrTpRxPduAvailable = FALSE;
runtimeInternalChnllData->FrTpTxSduAvailable = FALSE;
runtimeInternalChnllData->FrTpTransmitPduLength = 0;
runtimeInternalChnllData->FrTpRetryInfo.TpDataState = TP_CONFPENDING;
runtimeInternalChnllData->FrTpRetryInfo.TxTpDataCnt = 0;
runtimeInternalChnllData->FrTpFramePayloadLength=0;
runtimeInternalChnllData->FrTpRxChannelState = IDLE;
runtimeInternalChnllData->FrTpTxChannelState = IDLE;
runtimeInternalChnllData->FrTpUlReturnValue = BUFREQ_OK;
runtimeInternalChnllData->FrTpRxSizeBuffer = 0;
runtimeInternalChnllData->FrTpFcRecveBuffSize = 0;
runtimeInternalChnllData->FrTpCounterRxRn = 0;
runtimeInternalChnllData->FrTpBandwidthcontol = 0;
runtimeInternalChnllData->FrTpTxSduUnknownMsgLength = 0;
runtimeInternalChnllData->FrTpTcRequest = FALSE;
for(initCount=0;initCount<FLOW_CONTROL_FRAME_PAYLOAD;initCount++){
runtimeInternalChnllData->FrTpRxFcDataPdu[initCount] = 0;
}
#if FRTP_ACK_RETRY_SUPPORT == STD_ON
runtimeInternalChnllData->FrTpAckPending = FRTP_NO;
runtimeInternalChnllData->FrTpuseCF1 = TRUE;
runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition = 0;
runtimeInternalChnllData->FrTpStfAckFlag = FALSE;
runtimeInternalChnllData->FrTpRxFcRetryFlag = FALSE;
runtimeInternalChnllData->FrTpStfReceivedFlag = FALSE;
runtimeInternalChnllData->FrTpEobReceivedFlag = FALSE;
#endif
}
for(conIndex =0;conIndex < FrTp_ConfigPtr->FrTpConnectionCount;conIndex++ ){
FrTp_Internal_RunTime.FrTpConnectionLockStatus[conIndex]= NOT_ACTIVE; /* To initialize connection locked by a rx or tx channel to false for half duplex*/
}
for(pduIndex =0;pduIndex < FrTp_ConfigPtr->FrTpTxPduCount;pduIndex++ ){
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[pduIndex].FrTpTxPduLockStatus= AVAILABLE; /* To initialize tx pdu locked by a channel for transmission to false*/
}
FrTp_Internal_RunTime.FrTpState = FRTP_ON;/* @req FRTP1032*/
}
/**
* @param void
*/
/*This service closes all pending transport protocol connections by simply stopping
operation, frees all resources and stops the FrTp Module */
/* @req FRTP148 */
void FrTp_Shutdown(void) {
uint8 channelIndex;
FrTp_Internal_Channel_type* chnlInternal;
/* @req FRTP1037 */
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_SHUTDOWN,FRTP_E_UNINIT);
/*@req FRTP1036*/
FrTp_Internal_RunTime.FrTpState = FRTP_OFF;
#if(FRTP_TRANSMIT_CANCEL_SUPPORT == STD_ON)
for (uint8 i=0; i < FRTP_MAX_TXPDU_COUNT; i++){
/* Cancel the ongoing transmission */
/* FrTpTxPduLockStatus is not NOT_ACTIVE, it means it is awaiting TX confirmation i.e a possibility to cancel prospective transmission */
if(FrTp_Internal_RunTime.FrTpTxPduStatusInfo[i].FrTpTxPduLockStatus != AVAILABLE)
{
/* @req FRTP1120 */
(void) FrIf_CancelTransmit(FrTp_ConfigPtr->FrTpPduIdToFrIfPduIdMap[i]);
}
}
#endif
/* Processing the channels previously sent TxPdus got TxConfirmation */
for (channelIndex = 0; channelIndex < FRTP_CHANNEL_NUM; channelIndex++) {
chnlInternal = &FrTp_Internal_RunTime.FrTpChannels[channelIndex];
if (chnlInternal->FrTpTxChannelState != IDLE)
{
#if(FRTP_TRANSMIT_CANCEL_SUPPORT == STD_ON)
PduR_FrTpTxConfirmation(chnlInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,NTFRSLT_E_CANCELATION_OK);
#endif
FrTp_Internal_FreeChannel(chnlInternal);
}
if (chnlInternal->FrTpRxChannelState != IDLE)
{
PduR_FrTpRxIndication(chnlInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_E_CANCELATION_OK);
resetRxChannelConfiguration(chnlInternal);
}
}
}
/**
*
* @param FrTpTxSduId
* @param FrTpTxSduInfoPtr
* @return
*/
/*This service is utilized to request the transfer of data*/
/* @req FRTP149 */
Std_ReturnType FrTp_Transmit(PduIdType FrTpTxSduId, const PduInfoType* FrTpTxSduInfoPtr){
/* @req FRTP136 */
Std_ReturnType status;
FrTp_Internal_Channel_type* runtimeInternalChnlData;
uint8 connectionIndex;
uint8 txPduIndex;
uint8 chnlIndex;
runtimeInternalChnlData = NULL;
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_UNINIT,E_NOT_OK); /* @req FRTP1037 */
FRTP_DET_REPORTERROR((NULL != FrTpTxSduInfoPtr),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_NULL_PTR,E_NOT_OK); /* @req FRTP1140 */
FRTP_DET_REPORTERROR((FrTpTxSduId <= FrTp_ConfigPtr->FrTpTxSduCount),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK); /* @req FRTP1139 */
/* Get the connection based on the TxsduId */
status = FrTp_Internal_GetConnectionForTxSdu(FrTpTxSduId, &connectionIndex);
/* If connection not found */
FRTP_DET_REPORTERROR((status != E_NOT_OK),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK); /* @req FRTP1040 */
#if (FRTP_UNKOWN_MSG_LNGT == STD_OFF)
/*For 1:n connections the unknown message length is not supported */
/* @req FRTP1063 */ /* @req FRTP1187 */
FRTP_DET_REPORTERROR(!((FrTpTxSduInfoPtr->SduLength == 0)&& (FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpMultipleReceiverCon!= FALSE)),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_SEG_ERROR,E_NOT_OK);
/* @req FRTP1062 */
/* Report error if unknown message length is not supported */
/* @req FRTP1134 */ /* @req FRTP1043 */ /* @req FRTP1064 */
FRTP_DET_REPORTERROR((FrTpTxSduInfoPtr->SduLength!=0),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_UMSG_LENGTH_ERROR,E_NOT_OK);
#endif
FRTP_DET_REPORTERROR(!((FrTpTxSduInfoPtr->SduLength > FRTP_MAX_USEG_UL_FPL)&&(FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpMultipleReceiverCon!= FALSE)),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_SEG_ERROR,E_NOT_OK);
if(FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpMultipleReceiverCon == TRUE){
for(txPduIndex=0;txPduIndex<FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpPoolTxPduCnt;txPduIndex++){
if(FrTpTxSduInfoPtr->SduLength < (FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpTxPduPoolRef[txPduIndex].FrTpTxPduLength-FRTP_HEADER_LENGTH_STF_LF)){
break;
}
}
FRTP_DET_REPORTERROR((txPduIndex < FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpPoolTxPduCnt),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_SEG_ERROR,E_NOT_OK);
}
if( FrTp_Internal_RunTime.FrTpConnectionLockStatus[connectionIndex]==ACTIVE_RX){
#if(FRTP_FULL_DUPLEX_ENABLE == STD_ON)
for(chnlIndex=0;chnlIndex <FRTP_CHANNEL_NUM; chnlIndex++){
if(FrTp_Internal_RunTime.FrTpChannels[chnlIndex].FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex == connectionIndex){
if(FrTp_Internal_RunTime.FrTpChannels[chnlIndex].FrTpTxChannelState==IDLE){
FrTp_Internal_AssignChannelForTx(connectionIndex,chnlIndex,&runtimeInternalChnlData,FrTpTxSduInfoPtr);
}
break;
}
}
/* If there isn't any free channel */
/* @req FRTP1041 */ /* @req FRTP1185 */
FRTP_DET_REPORTERROR((runtimeInternalChnlData != NULL_PTR),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_NO_CHANNEL,E_NOT_OK);
#endif
}else if(FrTp_Internal_RunTime.FrTpConnectionLockStatus[connectionIndex]==ACTIVE_TX){
/* @req FRTP142 */
PduR_FrTpTxConfirmation(FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex].FrTpULTxPduId, NTFRSLT_E_FR_TX_ON);
status = E_NOT_OK;
}else{
/* If there is a free channel */ /* @req FRTP228 */
for(chnlIndex=0;chnlIndex <FRTP_CHANNEL_NUM; chnlIndex++){
if(FrTp_Internal_RunTime.FrTpChannels[chnlIndex].FrTpTxChannelState == IDLE) {
/* Allocate channel for the connection */
FrTp_Internal_AssignChannelForTx(connectionIndex,chnlIndex,&runtimeInternalChnlData,FrTpTxSduInfoPtr);
break;
}
}
/* If there isn't any free channel */
/* @req FRTP1041 */ /* @req FRTP1185 */
FRTP_DET_REPORTERROR((runtimeInternalChnlData != NULL_PTR),FRTP_SERVICE_ID_TRANSMIT,FRTP_E_NO_CHANNEL,E_NOT_OK);
}
return status;
}
/**
*
* @param FrTpTxPduId
* @return
*/
/*This service primitive is used to cancel the transfer of pending Fr N-SDUs.*/
/* @req FRTP150 */
Std_ReturnType FrTp_CancelTransmit(PduIdType FrTpTxSduId) {
/*@req FRTP384 */ /* @req FRTP1097 */
#if (FRTP_TRANSMIT_CANCEL_SUPPORT == STD_ON)
FrTp_Internal_Channel_type* runtimeInternalChnllData;
uint8 chnlIndex;
#endif
Std_ReturnType status;
uint8 connectionIndex;
/* @req FRTP1037 *//*@req FRTP1106*/ /*@req FRTP206*/ /*@req FRTP1107*/ /*@req FRTP205*/
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_CANCEL_TRANSMIT_REQUEST,FRTP_E_UNINIT,E_NOT_OK);
/* @req FRTP1141 */
FRTP_DET_REPORTERROR((FrTpTxSduId < FrTp_ConfigPtr->FrTpTxSduCount),FRTP_SERVICE_ID_CANCEL_TRANSMIT_REQUEST,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK);
/* Get the connection based on the TxsduId */
status = FrTp_Internal_GetConnectionForTxSdu(FrTpTxSduId, &connectionIndex);
/* If connection not found */
FRTP_DET_REPORTERROR((status != E_NOT_OK),FRTP_SERVICE_ID_CANCEL_TRANSMIT_REQUEST,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK);
#if (FRTP_TRANSMIT_CANCEL_SUPPORT == STD_ON)
runtimeInternalChnllData = NULL_PTR;
for(chnlIndex=0;chnlIndex <FRTP_CHANNEL_NUM; chnlIndex++){
if((FrTp_Internal_RunTime.FrTpChannels[chnlIndex].FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex == connectionIndex)&&
(FrTp_Internal_RunTime.FrTpChannels[chnlIndex].FrTpTxChannelState != IDLE)){
runtimeInternalChnllData =&FrTp_Internal_RunTime.FrTpChannels[chnlIndex];
break;
}
}
if((chnlIndex<FRTP_CHANNEL_NUM)&&(runtimeInternalChnllData!= NULL_PTR)){
/* If the first frame is not sent it can be canceled in the states where FrTp is before calling FrIf_Transmit and receiving FrTp_TriggerTransmit */
/* @req FRTP1104 */
if(runtimeInternalChnllData->FrTpTxChannelState == FRTP_TX_STARTED) {
/* @req FRTP385 */ /* @req FRTP423*/
runtimeInternalChnllData->FrTpTcRequest = TRUE;
}
else if ((runtimeInternalChnllData->FrTpTxChannelState == FRTP_TX_SEG_ONGOING)||(runtimeInternalChnllData->FrTpTxChannelState == FRTP_WAIT_FOR_TRIGGER_TRANSMIT))
{
runtimeInternalChnllData->FrTpTcRequest = TRUE;
/* Try to cancel ongoing transmission */
if(runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef != NULL_PTR)
{
(void) FrIf_CancelTransmit(runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpFrIfTxPduId);
}
}else{
status = E_NOT_OK;
}
}else{
/* No transmit request to cancel */
status = E_NOT_OK;
}
#endif
return status;
}
/**
*
* @param id
* @param parameter
* @param value
* @return
*/
/*Request to change transport protocol parameter BandwithControl.*/
/* !req FRTP151 */
Std_ReturnType FrTp_ChangeParameter( PduIdType id, TPParameterType parameter, uint16 value){
Std_ReturnType status;
status = E_NOT_OK;
/* req FRTP1037 */
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_CHANGE_PARAMETER,FRTP_E_UNINIT,E_NOT_OK);
/* !req FRTP1143 */
/* FRTP_DET_REPORTERROR((id <= FrTp_ConfigPtr->FrTpRxPduCount),FRTP_SERVICE_ID_CHANGE_PARAMETER,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK);*/
/* !req FRTP1144 */
/* FRTP_DET_REPORTERROR((parameter <= TP_BC),FRTP_SERVICE_ID_CHANGE_PARAMETER,FRTP_E_INVALID_PARAMETER,E_NOT_OK);*/
(void)parameter;
(void)value;
(void)id;
return status;
}
/*lint -save -e9033 Typecasting is done from lower size to upper size uint8 to uint16 */
/**
*
* @param FrTpRxSduId
* @return
*/
/*this API with the corresponding RxSduId the currently ongoing data
reception is terminated immediately */
/* @req FRTP1172 */
Std_ReturnType FrTp_CancelReceive(PduIdType FrTpRxSduId) {
uint8 connectionCount;
uint8 channel;
Std_ReturnType ret;
FrTp_Internal_Channel_type *ChannelInternal;
ret = E_OK;
/* @req FRTP1037 */
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_CANCEL_RECEIVE,FRTP_E_UNINIT,E_NOT_OK);
/* @req FRTP1180 */
FRTP_DET_REPORTERROR((FrTpRxSduId < FrTp_ConfigPtr->FrTpRxSduCount),FRTP_SERVICE_ID_CANCEL_RECEIVE,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK);
for(connectionCount= 0; (connectionCount < FrTp_ConfigPtr->FrTpConnectionCount ) ;connectionCount++)
{
if(FrTpRxSduId == FrTp_ConfigPtr->FrTpConnectionConfig[connectionCount].FrTpRxSduId){
break;
}
}
for(channel=0;channel<FRTP_CHANNEL_NUM;channel++)
{
if(connectionCount == FrTp_Internal_RunTime.FrTpChannels[channel].FrTpChannelParams.FrTpRxChannel.FrTpAssignedRxConnectionIndex){
break;
}
}
if(channel<FRTP_CHANNEL_NUM){
ChannelInternal= &FrTp_Internal_RunTime.FrTpChannels[channel];
if((FRTP_STF_RECEIVED == ChannelInternal->FrTpRxChannelState ) ||(FRTP_RX_WAIT_STF_SDU_BUFFER == ChannelInternal->FrTpRxChannelState))
{
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength == (PduLengthType) ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE]){
ret = E_NOT_OK; /* @req FRTP1182*/ /* if receiving unsegmented msg */
}
}
if(RX_LAST_FRAME == ChannelInternal->FrTpRxChannelState ){
ret = E_NOT_OK; /* @req FRTP1182*/ /* if receiving LAST Frame */
}
if(ret != E_NOT_OK ){
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_E_CANCELATION_OK); /* @req FRTP1183*/
resetRxChannelConfiguration(ChannelInternal); /* @req FRTP1181*/
}
}else{
ret = E_NOT_OK; /* Execution should ideally not reach this part */
}
/* */
return ret;
}
/**
*
* @param TxPduId
* @param PduInfoPtr
* @return
*/
/* @req FRTP154 */
/*lint --e{818} */
Std_ReturnType FrTp_TriggerTransmit(PduIdType TxPduId,PduInfoType* PduInfoPtr){
/*@req FRTP1059 */
FrTp_Internal_Channel_type* runtimeInternalChnllData;
uint16 channelIndex;
PduLengthType buffDiffbytes;
PduLengthType txLen;
boolean flag;
Std_ReturnType status;
txLen =0;
buffDiffbytes =0;
status = E_OK;
/* @req FRTP1037 */
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_TRIGGER_TRANSMIT,FRTP_E_UNINIT,E_NOT_OK);
/* @req FRTP1146 */
FRTP_DET_REPORTERROR((NULL != PduInfoPtr),FRTP_SERVICE_ID_TRIGGER_TRANSMIT,FRTP_E_NULL_PTR,E_NOT_OK);
FRTP_DET_REPORTERROR((NULL != PduInfoPtr->SduDataPtr),FRTP_SERVICE_ID_TRIGGER_TRANSMIT,FRTP_E_NULL_PTR,E_NOT_OK);
/* @req FRTP1145 */
flag = (TxPduId < FrTp_ConfigPtr->FrTpTxPduCount)&&( FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpTxPduLockStatus != AVAILABLE);
FRTP_DET_REPORTERROR((TRUE == flag),FRTP_SERVICE_ID_TRIGGER_TRANSMIT,FRTP_E_INVALID_PDU_SDU_ID,E_NOT_OK);
channelIndex = FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpChannleHandle;
runtimeInternalChnllData = &FrTp_Internal_RunTime.FrTpChannels[channelIndex];
if(runtimeInternalChnllData->FrTpTcRequest == FALSE){
if( FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpTxPduLockStatus == LOCKED_FOR_SF_CF_LF){
/* @req FRTP1060 */ /* @req FRTP1061 */
if(runtimeInternalChnllData->FrTpTxChannelState == FRTP_WAIT_FOR_TRIGGER_TRANSMIT){
memcpy(PduInfoPtr->SduDataPtr,runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu,runtimeInternalChnllData->FrTpTransmitPduLength);
/* Copying back Orignal state */
runtimeInternalChnllData->FrTpTxChannelState = runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxPrevChannelState;
buffDiffbytes = PduInfoPtr->SduLength - runtimeInternalChnllData->FrTpTransmitPduLength;
txLen = runtimeInternalChnllData->FrTpTransmitPduLength;
}
}else{
if(runtimeInternalChnllData->FrTpRxChannelState == FRTP_WAIT_FOR_TRIGGER_TRANSMIT){
memcpy(PduInfoPtr->SduDataPtr,runtimeInternalChnllData->FrTpRxFcDataPdu,FLOW_CONTROL_FRAME_PAYLOAD);
/* Copying back Orignal state */
runtimeInternalChnllData->FrTpRxChannelState = runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxPrevChannelState;
buffDiffbytes = PduInfoPtr->SduLength - FLOW_CONTROL_FRAME_PAYLOAD;
txLen = FLOW_CONTROL_FRAME_PAYLOAD;
}
}
if ( buffDiffbytes > 0) {
memset(&(PduInfoPtr->SduDataPtr[txLen]), 0,buffDiffbytes);
}
} else {
status = E_NOT_OK;
}
return status;
}
/**
*
* @param RxPduId
* @param PduInfoPtr
*/
/* Indication of a received I-PDU from a lower layer communication module. */
/* @req FRTP152 */ /* @req FRTP137 */
void FrTp_RxIndication(PduIdType RxPduId,PduInfoType* PduInfoPtr) {
uint8 count;
static ISO10681FrameType frameTypelcl;
ISO10681PduAddressType frameAddressInfo;
/* @req FRTP1037 */
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_RX_INDICATION,FRTP_E_UNINIT);
/* @req FRTP1147 */ /* @req FRTP1069 *//* @req FRTP1070]*/
FRTP_DET_REPORTERROR((RxPduId < FrTp_ConfigPtr->FrTpRxPducount),FRTP_SERVICE_ID_RX_INDICATION,FRTP_E_INVALID_PDU_SDU_ID);
/* @req FRTP1148 */
FRTP_DET_REPORTERROR((NULL != PduInfoPtr),FRTP_SERVICE_ID_RX_INDICATION,FRTP_E_NULL_PTR);
FRTP_DET_REPORTERROR((NULL != PduInfoPtr->SduDataPtr),FRTP_SERVICE_ID_RX_INDICATION,FRTP_E_NULL_PTR);
frameTypelcl = getFrameType(PduInfoPtr->SduDataPtr);
getFrameAddress(PduInfoPtr, &frameAddressInfo);
if((START_FRAME == frameTypelcl)
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
|| (START_FRAME_ACK == frameTypelcl)
#endif
)
{
count = frtpManageStfConnections(PduInfoPtr,RxPduId,frameTypelcl,frameAddressInfo);
if(INVALID_CONNECTION != count) /* @req FRTP1072*/
{
/* @req FRTP1076*/ /* @req FRTP1186*/
FRTP_DET_REPORTERROR((FRTP_CHANNEL_NUM > count),FRTP_SERVICE_ID_RX_INDICATION,FRTP_E_NO_CHANNEL);
}
}
else
{
if(ISO10681_TPCI_FC == (PduInfoPtr->SduDataPtr[PCI_BYTE_1] & ISO10681_TPCI_MASK)){
frtpManageFcConnections(PduInfoPtr,frameAddressInfo);
}else{
frtpManageCfConnections(PduInfoPtr, frameTypelcl,frameAddressInfo);
}
}
}
/**
*
* @param TxPduId
*/
/* The lower layer communication module confirms the transmission of an I-PDU.*/
/* @req FRTP153 */
void FrTp_TxConfirmation(PduIdType TxPduId){
/* @req FRTP1052 */ /* @req FRTP1053*/ /* @req FRTP1093*/
FrTp_Internal_Channel_type* runtimeInternalChnllData;
uint16 channelIndex;
boolean flag;
/* @req FRTP1037 */
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_TX_CONFIRMATION,FRTP_E_UNINIT);
/* @req FRTP1149 */
flag = (TxPduId < FrTp_ConfigPtr->FrTpTxPduCount) &&( FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpTxPduLockStatus != AVAILABLE);
FRTP_DET_REPORTERROR((TRUE == flag),FRTP_SERVICE_ID_TX_CONFIRMATION,FRTP_E_INVALID_PDU_SDU_ID);
channelIndex = FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpChannleHandle;
runtimeInternalChnllData = &FrTp_Internal_RunTime.FrTpChannels[channelIndex];
if( FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpTxPduLockStatus == LOCKED_FOR_SF_CF_LF){
/* @req FRTP1092 */
runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPendingCounter--;
/* Stop A timer */
runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpCounterAs = 0u;
if((runtimeInternalChnllData->FrTpTxChannelState == FRTP_TX_WAIT_FOR_FC)
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
||((runtimeInternalChnllData->FrTpTxChannelState == FRTP_TX_FINISHED)&&
(runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType != FRTP_NO))
#endif
) {
/* For Segmented Tx if Flow control is expected start the Bs timer */
runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpCounterBs = runtimeInternalChnllData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpTimeoutBs+1;
}
}else if(FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpTxPduLockStatus == LOCKED_FOR_FC){
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPendingCounter--;
/* Stop Ar Timer */
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr = 0u;
if(((runtimeInternalChnllData->FrTpRxFcDataPdu[PCI_BYTE_1] & ISO10681_TPCI_FS_MASK) == ISO10681_FC_STATUS_ABORT)
|| ((runtimeInternalChnllData->FrTpRxFcDataPdu[PCI_BYTE_1] & ISO10681_TPCI_FS_MASK) == ISO10681_FC_STATUS_OVFL)){
resetRxChannelConfiguration(runtimeInternalChnllData);
}
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
else if(((runtimeInternalChnllData->FrTpRxFcDataPdu[PCI_BYTE_1] & ISO10681_TPCI_FS_MASK) == ISO10681_FC_STATUS_ACK_RET)
&&(runtimeInternalChnllData->FrTpRxFcDataPdu[PCI_BYTE_2] == 0)){
/* @req FRTP1083 */ /* @req FRTP1081 */
resetRxChannelConfiguration(runtimeInternalChnllData); /* Since FC with ACK is the final Activity of Reception */
}
#endif
else if(runtimeInternalChnllData->FrTpRxChannelState == FRTP_RX_WAIT_CF){
/* Start Cr timer */
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr = runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpTimeoutCr;
}
else{
/*do nothing */
}
}else{
/*do nothing */
}
/* @req FRTP1054*/
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[TxPduId].FrTpTxPduLockStatus= AVAILABLE;
return;
}
/**
* @param void
*/
/*Schedules the FlexRay TP. (Entry point for scheduling)*/
/* @req FRTP162 */
void FrTp_MainFunction(void) {
/* Disable interrupts */
SchM_Enter_FrTp_EA_0();
/* @req FRTP203*/ /* @req FRTP580*/
FrTp_Internal_Channel_type *ChannelInternal;
uint8 count;
/* @req FRTP1037 */ /*@req FRTP1106*/
FRTP_DET_REPORTERROR((FRTP_ON == FrTp_Internal_RunTime.FrTpState),FRTP_SERVICE_ID_MAIN_FUNCTION,FRTP_E_UNINIT);
for(count = 0; count< FRTP_CHANNEL_NUM; count++) {
ChannelInternal = &FrTp_Internal_RunTime.FrTpChannels[count];
if(IDLE != ChannelInternal->FrTpRxChannelState){
handleReceivedFrame(ChannelInternal);
}
FrTp_Internal_TransmitStatesHandle(ChannelInternal);
}
/* Enable interrupts */
SchM_Exit_FrTp_EA_0();
}
/**
* @brief To handle states of transmit sequence
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @return void
*/
static void FrTp_Internal_TransmitStatesHandle(FrTp_Internal_Channel_type* runtimeChnlData){
if(runtimeChnlData->FrTpTxChannelState!=IDLE){
if(runtimeChnlData->FrTpTcRequest == TRUE){
FrTp_Internal_HandleTxCanceled(runtimeChnlData);
}
/* @req FRTP1094*/ /* @req FRTP1095*/
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPendingCounter == 0){
switch(runtimeChnlData->FrTpTxChannelState) {
case FRTP_TX_STARTED :
FrTp_Internal_TransmitStartFrame(runtimeChnlData);
break;
case FRTP_TX_WAIT_FOR_FC :
FrTp_Internal_WaitForFlowControl(runtimeChnlData);
break;
case FRTP_TX_FINISHED:
FrTp_Internal_TransmitFinished(runtimeChnlData);
break;
case FRTP_FRIF_ERROR:
FrTp_Internal_HandleFrIfError(runtimeChnlData,ACTIVE_TX);
break;
case FRTP_TX_SEG_ONGOING:
FrTp_Internal_HandleNextSegFrames(runtimeChnlData);
break;
case FRTP_WAIT_FOR_TRIGGER_TRANSMIT:
default:
/* Do nothing */
break;
}
}else{
if(runtimeChnlData->FrTpTxSduAvailable !=FALSE){
/* Handle As timer and timeout */ /* @req FRTP1099 */
FrTp_Internal_TimeoutAs(runtimeChnlData);
}
}
}
}
/**
* @brief To handle Next segmented frames
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @return void
*/
static void FrTp_Internal_HandleNextSegFrames(FrTp_Internal_Channel_type* runtimeChnlData){
PduLengthType remainingTxBufferLength;
PduLengthType payloadIndex;
uint16 pduIndex;
uint8 txFrameType;
txFrameType = 0;
/* Check if this channel has to be scheduled for transmission*/
/* If there is a pending data in the transmit buffers or all the data is transmitted in the last CF */
if ((runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength != 0)
||(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength == runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength)
#if (FRTP_UNKOWN_MSG_LNGT == STD_ON)
/* In case of unknown message length in the condition FrTpRemainingTxBufferLength a Last Frame has to be sent *//* @req FRTP1066 */
|| (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength == 0)
#endif
){
for(pduIndex=0;pduIndex<runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpPoolTxPduCnt;pduIndex++){
if(FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pduIndex].FrTpTxPduId].FrTpTxPduLockStatus== AVAILABLE){
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef = (&runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pduIndex]);
break;
}
}
if(pduIndex<runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpPoolTxPduCnt){
if(E_OK == FrTp_Internal_GetNextFrameType(runtimeChnlData,&txFrameType,&remainingTxBufferLength)){
payloadIndex = FrTp_Internal_FillNextFrame(runtimeChnlData,txFrameType);
FrTp_Internal_SendNextFrame(runtimeChnlData,payloadIndex);
}
}
}
}
/**
* @brief To to send next frame buffer values and fill data from upper layer data
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @param txPayloadIndex
*/
static void FrTp_Internal_SendNextFrame(FrTp_Internal_Channel_type* runtimeChnlData,PduLengthType payloadIndex ){
PduInfoType txPduInfo;
BufReq_ReturnType bufferRetVal;
/* Ask upper layer to copy the tx data */
txPduInfo.SduDataPtr = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[payloadIndex];
txPduInfo.SduLength = runtimeChnlData->FrTpFramePayloadLength;
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType != FRTP_NO) {
bufferRetVal = PduR_FrTpCopyTxData(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, &txPduInfo,&runtimeChnlData->FrTpRetryInfo, &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength);
/* Clear retry request or data confirmation*/
runtimeChnlData->FrTpRetryInfo.TpDataState = TP_CONFPENDING;
}else
#endif
{
bufferRetVal = PduR_FrTpCopyTxData(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,&txPduInfo,NULL_PTR, &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength);
}
if (bufferRetVal == BUFREQ_OK) {
/* @req FRTP1105*/ /* @req FRTP1114 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxFCWait;
/* Reduce the available buffer with the already copied length */
runtimeChnlData->FrTpFcRecveBuffSize -= runtimeChnlData->FrTpFramePayloadLength;
/* Transmit the complete constructed frame */
txPduInfo.SduDataPtr = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[0];
txPduInfo.SduLength += payloadIndex;
/* Send out the next frame */
if (FrTp_Internal_SendFrame(runtimeChnlData, &txPduInfo,ACTIVE_TX) == E_OK) {
/* @req FRTP1114 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAsTimeoutRetryCounter = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxAs;
/* @req FRTP1067 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength += runtimeChnlData->FrTpFramePayloadLength;
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
if (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType != FRTP_NO) {
/* Increase the counter of the unacknowledged bytes */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition += runtimeChnlData->FrTpFramePayloadLength;
}
#endif
}
}
else
{
FrTp_Internal_TxBufferRequestError(runtimeChnlData, bufferRetVal);
}
}
/**
* @brief To to fill next frame buffer values
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @param txFrameType
* @param remainingTxBufferLength
* @return PduLengthType
*/
static PduLengthType FrTp_Internal_FillNextFrame(FrTp_Internal_Channel_type* runtimeChnlData, uint8 txFrameType ){
PduLengthType txPayloadIndex;
txPayloadIndex =0;
if(FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduId].FrTpTxPduLockStatus== AVAILABLE){
/* Allocate the first free available Pdu, lock the index of used pdu */ /* @req FRTP1045 */
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduId].FrTpTxPduLockStatus = LOCKED_FOR_SF_CF_LF;
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduId].FrTpChannleHandle = runtimeChnlData->FrTpChannelNumber;
}
switch(txFrameType){
case ISO10681_TPCI_CF1:
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
/* Change CF type if retry is in progress*/
if (runtimeChnlData->FrTpuseCF1 == FALSE) {
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[4] = ISO10681_TPCI_CF2 | runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber;
}
else
#endif
{
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[4] = ISO10681_TPCI_CF1 | runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber;
}
txPayloadIndex = FRTP_HEADER_LENGTH_CF;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber = (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber +1) % FRTP_SN_RANGE_MODULO;
break;
case ISO10681_TPCI_CFEOB:
txPayloadIndex = FRTP_HEADER_LENGTH_CF;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[4] = ISO10681_TPCI_CFEOB | runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber;
/* At the end of block wait for the flow control */
runtimeChnlData->FrTpTxChannelState = FRTP_TX_WAIT_FOR_FC;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber = (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber + 1) % FRTP_SN_RANGE_MODULO;
break;
case ISO10681_TPCI_LF:
txPayloadIndex = FRTP_HEADER_LENGTH_STF_LF;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[4] = ISO10681_TPCI_LF;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[6] = FRTP_MSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength + runtimeChnlData->FrTpFramePayloadLength);
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[7] = FRTP_LSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength + runtimeChnlData->FrTpFramePayloadLength);
/* Set state to finished */
runtimeChnlData->FrTpTxChannelState = FRTP_TX_FINISHED;
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
/* Wait for the acknowledge */
runtimeChnlData->FrTpAckPending = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType;
#endif
break;
default:
/* Nothing to do*/
break;
}
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[5] = (uint8) runtimeChnlData->FrTpFramePayloadLength;
return txPayloadIndex;
}
/**
* @brief To identify next frame type
* @param runtimeChnlData Internal runtime data ptr for Channel used for transmit
* @param txFrameType
* @param remainingTxBufferLength
* @return Std_ReturnType
*/
static Std_ReturnType FrTp_Internal_GetNextFrameType(FrTp_Internal_Channel_type* runtimeChnlData,uint8* txFrameType,PduLengthType* remainingTxBufferLength ){
Std_ReturnType status;
PduLengthType txPduLen;
PduLengthType availableTxBufLen;
status = E_OK;
/* Available buffer length is the minimum of Transmitter buffer and Receiver buffer */
if(runtimeChnlData->FrTpFcRecveBuffSize < runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength ){
availableTxBufLen = runtimeChnlData->FrTpFcRecveBuffSize;
} else {
availableTxBufLen = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength;
}
txPduLen = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduLength;
/*@req FRTP1089*/ /* consider different PduLength in the pool */
/** This condition checks if the Remaining bytes > (TxPdu length - CF header length) to decide a CF */
if(availableTxBufLen > (txPduLen -FRTP_HEADER_LENGTH_CF)){
*txFrameType = ISO10681_TPCI_CF1;
runtimeChnlData->FrTpFramePayloadLength = (uint8)(txPduLen - FRTP_HEADER_LENGTH_CF);
} else if(availableTxBufLen <= (txPduLen-FRTP_HEADER_LENGTH_STF_LF)){ /** This condition checks if the remaining bytes
to transfer fits within selected TxPdu. Remaining bytes <= (TxPdu length - LF header length) i.e implies either a LF or CF_EOB */
/** Check Completed Length + Remaining Length = Total Length to decide LF */
if( ((runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength + availableTxBufLen) ==
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength)
/* this is to decide the last frame based on the FrTpCompletedMessageLength */
#if (FRTP_UNKOWN_MSG_LNGT == STD_ON) /* @req FRTP1066 */
|| ((runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength == 0) && (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength == 0))
#endif
){
*txFrameType = ISO10681_TPCI_LF;
runtimeChnlData->FrTpFramePayloadLength = (uint8)availableTxBufLen;
} else if (availableTxBufLen == 0) {
/* The available TxBuffer can not fill out the next Pdu so do not send out this data yet */
status = E_NOT_OK;
}else{/** If Remaining bytes to be transmitted is constrained by the receiver/Transmitter buffer then it is EOB*/
*txFrameType = ISO10681_TPCI_CFEOB;
runtimeChnlData->FrTpFramePayloadLength = (uint8)availableTxBufLen;
}
}else{ /** If we have reached here then Remaining bytes = (TxPdu Length - CF header length) */
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength == availableTxBufLen){
/* If Remaining bytes to be transmitted depends on the transmit buffer then it is CF */
*txFrameType = ISO10681_TPCI_CF1;
runtimeChnlData->FrTpFramePayloadLength = (uint8)availableTxBufLen;
} else {
/* If Remaining bytes to be transmitted depends on the receiver buffer then it is CF_EOB*/
*txFrameType = ISO10681_TPCI_CFEOB;
runtimeChnlData->FrTpFramePayloadLength = (uint8)availableTxBufLen;
}
}
if (status == E_OK) {
* remainingTxBufferLength = availableTxBufLen;
}
return status;
}
/**
* @brief To transmit start frame to lower layers
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @return void
*/
static void FrTp_Internal_TransmitStartFrame(FrTp_Internal_Channel_type* runtimeChnlData){
BufReq_ReturnType buffRetValue;
Std_ReturnType retVal;
PduInfoType pduInfo;
PduLengthType TxBufferLength;
uint8 pdupoolIndex;
boolean breakLoop;
retVal = E_NOT_OK;
buffRetValue = BUFREQ_OK;
pduInfo.SduLength = 0;
pduInfo.SduDataPtr = NULL;
/* @req FRTP1042 */
if(runtimeChnlData->FrTpTxSduAvailable==TRUE){
/* this to get the TxBufferLength from upper layer */
buffRetValue = PduR_FrTpCopyTxData(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, &pduInfo, NULL_PTR, &TxBufferLength);
if (buffRetValue==BUFREQ_OK){
breakLoop = FALSE;
/* @req FRTP1096 */
for (pdupoolIndex = 0; (pdupoolIndex < runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpPoolTxPduCnt) && (FALSE == breakLoop); pdupoolIndex++) {
if(FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pdupoolIndex].FrTpTxPduId].FrTpTxPduLockStatus== AVAILABLE){
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pdupoolIndex].FrTpTxPduId].FrTpTxPduLockStatus= LOCKED_FOR_SF_CF_LF;
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pdupoolIndex].FrTpTxPduId].FrTpChannleHandle = runtimeChnlData->FrTpChannelNumber;
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpMultipleReceiverCon!=FALSE) {
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength <= (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pdupoolIndex].FrTpTxPduLength - FRTP_HEADER_LENGTH_STF_LF)){
/* Assign Pdu to this channel */
/* @req FRTP1046 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pdupoolIndex];
breakLoop = TRUE;
}else{
/* check for the next pdu with enough size to send it unsegmented
* shall not process for segmentation */
/* @req FRTP1068 */
}
}else{
/*@req FRTP1045*/ /*@req FRTP1046*/
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpTxPduPoolRef[pdupoolIndex];
breakLoop = TRUE;
}
}
}
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef != NULL_PTR){
if (TxBufferLength == runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength){ /* this check for known message length during Frtp transmit call */
/*@req FRTP1048*/
/* Physical addressing - If the complete data is available try to send it unsegmented */
if (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength <= (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduLength - FRTP_HEADER_LENGTH_STF_LF)) {
/* FrTpTxChannelState will be modified to FRTP_FRIF_ERROR if FrTp_Internal_PrepareAndSendStartFrame->FrTp_Internal_SendFrame fails to send frame and gets FrIf transmit error */
runtimeChnlData->FrTpTxChannelState = FRTP_TX_FINISHED;
retVal= FrTp_Internal_PrepareAndSendStartFrame(runtimeChnlData,(uint8)runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength);
}else{
/* Pdu isn't large enough to transmit then Segmented transmission */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber = 1u;
/* FrTpTxChannelState will be modified to FRTP_FRIF_ERROR if FrTp_Internal_PrepareAndSendStartFrame->FrTp_Internal_SendFrame fails to send frame and gets FrIf transmit error */
runtimeChnlData->FrTpTxChannelState = FRTP_TX_WAIT_FOR_FC;
retVal= FrTp_Internal_PrepareAndSendStartFrame(runtimeChnlData,(uint8)(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduLength - FRTP_HEADER_LENGTH_STF_LF));
}
if(retVal == E_OK){
#if FRTP_ACK_RETRY_SUPPORT == STD_ON
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType!= FRTP_NO){
/* Wait for the acknowledge */
runtimeChnlData->FrTpAckPending = FRTP_ACK_WITH_RT;
}
#endif
}
}else{ /* this check for unknown message length during Frtp transmit call */
/* FrTpTxChannelState will be modified to FRTP_FRIF_ERROR if FrTp_Internal_PrepareAndSendStartFrame->FrTp_Internal_SendFrame fails to send frame and gets FrIf transmit error */
runtimeChnlData->FrTpTxChannelState = FRTP_TX_WAIT_FOR_FC;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber = 1u;
if (TxBufferLength <= (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduLength - FRTP_HEADER_LENGTH_STF_LF)) {
retVal= FrTp_Internal_PrepareAndSendStartFrame(runtimeChnlData,(uint8)TxBufferLength);
}else{
retVal = FrTp_Internal_PrepareAndSendStartFrame(runtimeChnlData,(uint8)(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduLength - FRTP_HEADER_LENGTH_STF_LF));
}
}
if(retVal == E_OK){
/* @req FRTP1067 */
/* To maintain the total transmitted length */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength += (runtimeChnlData->FrTpTransmitPduLength- FRTP_HEADER_LENGTH_STF_LF);
}
}
}else{
/*Notify error to upper layer */
FrTp_Internal_TxBufferRequestError(runtimeChnlData, buffRetValue);
}
}
}
/**
* @brief To Prepare and send the start frame
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @param framePayloadLength - Start up frame pay load length
* @return void
*/
static Std_ReturnType FrTp_Internal_PrepareAndSendStartFrame(FrTp_Internal_Channel_type* runtimeChnlData, uint8 framePayloadLength) {
/* @req FRTP1049*/ /* @req FRTP1006 */
PduInfoType pduInfo;
BufReq_ReturnType buffRetValue;
Std_ReturnType retVal;
retVal = E_NOT_OK;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[0] = FRTP_MSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpRa);
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[1] = FRTP_LSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpRa);
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[2] = FRTP_MSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpLa);
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[3] = FRTP_LSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpLa);
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[5] = framePayloadLength;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[6] = FRTP_MSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength);
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[7] = FRTP_LSB_U16(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength);
/* @req FRTP1123*/ /* @req FRTP1051 */
/* request upper layer to copy the tx data */
pduInfo.SduDataPtr = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[FRTP_HEADER_LENGTH_STF_LF];
pduInfo.SduLength = framePayloadLength;
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
if (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType != FRTP_NO)
{
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[4] = FRTP_CPCI_STFA;
/* If acknowledge is needed the upper layer must keep the data in the buffer until acknowledge */
runtimeChnlData->FrTpRetryInfo.TpDataState = TP_CONFPENDING;
buffRetValue = PduR_FrTpCopyTxData(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, &pduInfo, &runtimeChnlData->FrTpRetryInfo,&runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength);
}else
#endif
{
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[4] = FRTP_CPCI_STFU;
/* @req FRTP1065*/ /* @req FRTP1123 */
buffRetValue = PduR_FrTpCopyTxData(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, &pduInfo, NULL_PTR,&runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength);
}
if (buffRetValue == BUFREQ_OK)
{
/* Reinitialize buffer retry counter */
/* @req FRTP1105*/ /* @req FRTP1114 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxFCWait;
/* Transmit the complete constructed frame */
pduInfo.SduDataPtr = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[0];
pduInfo.SduLength += FRTP_HEADER_LENGTH_STF_LF;
/* No. of attempts in case a timeout AS occurs*/
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAsTimeoutRetryCounter = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxAs;
/* Send out the start frame */
retVal = FrTp_Internal_SendFrame(runtimeChnlData, &pduInfo,ACTIVE_TX);
}else{
/*Notify error to upper layer */
FrTp_Internal_TxBufferRequestError(runtimeChnlData, buffRetValue);
}
return retVal;
}
/**
* @brief To transmit prepared data to interface layer
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @param txPduInfo - pdu data and length for transmission
* @return Std_ReturnType
*/
static Std_ReturnType FrTp_Internal_SendFrame(FrTp_Internal_Channel_type* runtimeChnlData, PduInfoType *txPduInfo, FrtpCommType commState) {
Std_ReturnType retVal;
retVal = E_NOT_OK;
if(commState == ACTIVE_TX){
runtimeChnlData->FrTpTransmitPduLength = txPduInfo->SduLength;
/* @req FRTP1050 */ /* @req FRTP1051 */
retVal = FrIf_Transmit(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpFrIfTxPduId,txPduInfo);
if(retVal == E_OK ){
/* @req FRTP1091 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPendingCounter++;
/* Start As timer */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterAs = FrTp_ConfigPtr->FrTpConnectionConfig[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex].FrTpConCtrlRef->FrTpTimeoutAs;
if (runtimeChnlData->FrTpTxChannelState == FRTP_FRIF_ERROR)
{
runtimeChnlData->FrTpTxChannelState = runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxPrevChannelState; /* copy the previous state */
/*@req FRTP1105*/ /*@req FRTP1114 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf = FrTp_ConfigPtr->FrTpConnectionConfig[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex].FrTpConCtrlRef->FrTpMaxFrIf;
}
/* @req FRTP1084 */ /* Decoupled Buffer Access */
if (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpImmediateAccess == FALSE)
{
/* Copy the current stae unit trigger transmit */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxPrevChannelState = runtimeChnlData->FrTpTxChannelState;
runtimeChnlData->FrTpTxChannelState = FRTP_WAIT_FOR_TRIGGER_TRANSMIT;
}
}else{
if(FrTp_ConfigPtr->FrTpConnectionConfig[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex].FrTpConCtrlRef->FrTpMaxFrIf== 0){
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_ABORT);
FrTp_Internal_FreeChannel(runtimeChnlData);
}else{
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf == runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxFrIf){
/* Take a copy of current state only for 1st call */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxPrevChannelState = runtimeChnlData->FrTpTxChannelState;
}
/* load the counter with the time waiting for the next try (if retry is activated) to send via FrIf_Transmit*/
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpFrIfTxErrNextTryTimer = (uint8)(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpTimeFrIf);
/* Change state to Tx error sender */
runtimeChnlData->FrTpTxChannelState = FRTP_FRIF_ERROR;
}
}
}else if(commState == ACTIVE_RX){
/* @req FRTP1050 */ /* @req FRTP1051 */
retVal = FrIf_Transmit(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef->FrTpFrIfTxPduId,txPduInfo);
if(retVal == E_OK ){
/* @req FRTP1091 */
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPendingCounter++;
/* Start Ar timer */
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr = runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpTimeoutAr;
if (runtimeChnlData->FrTpRxChannelState == FRTP_FRIF_ERROR)
{
/*@req FRTP1105*/ /*@req FRTP1114 */
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf = runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxFrIf;
runtimeChnlData->FrTpRxChannelState = runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxPrevChannelState;/* copy the previous state */
}
/* @req FRTP1084 */ /* Decoupled Buffer Access */
if (runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef->FrTpImmediateAccess == FALSE)
{
/* Copy the current state unit Trigger transmit */
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxPrevChannelState = runtimeChnlData->FrTpRxChannelState;
runtimeChnlData->FrTpRxChannelState = FRTP_WAIT_FOR_TRIGGER_TRANSMIT;
}
}else{
if(FrTp_ConfigPtr->FrTpConnectionConfig[runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpAssignedRxConnectionIndex].FrTpConCtrlRef->FrTpMaxFrIf== 0){
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULTxPduId, NTFRSLT_E_ABORT);
resetRxChannelConfiguration(runtimeChnlData);
}else{
if(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf == runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxFrIf){
/* Take a copy of current state only for 1st time */
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxPrevChannelState = runtimeChnlData->FrTpRxChannelState;
}
/* load the counter with the time waiting for the next try (if retry is activated) to send via FrIf_Transmit*/
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpFrIfRxErrNextTryTimer = (uint8)(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpTimeFrIf);
/* Change state to Tx error sender */
runtimeChnlData->FrTpRxChannelState = FRTP_FRIF_ERROR;
}
}
}else{
/* do nothing */
}
return retVal;
}
/**
* @brief To decrement flow control time while waiting for FC
* @param runtimeChnlData -Internal runtime data ptr for Channel used for transmit
*/
static void FrTp_Internal_WaitForFlowControl(FrTp_Internal_Channel_type* runtimeChnlData){
/* @req FRTP1099 */
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterBs !=0){
/* Decrement the timer */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterBs--;
/* If timeout expired */
if (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterBs == 0)
{
/* @req FRTP1100 */
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_TIMEOUT_BS);
FrTp_Internal_FreeChannel(runtimeChnlData);
}
}
}
/**
* @brief To handle transmit completed sequence
* @param runtimeChnlData -Internal runtime data ptr for Channel used for transmit
*/
static void FrTp_Internal_TransmitFinished(FrTp_Internal_Channel_type* runtimeChnlData){
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
if(runtimeChnlData->FrTpAckPending == FRTP_NO){
/* Notify upper layer about the successful transmission */
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_OK);
FrTp_Internal_FreeChannel(runtimeChnlData);
}else{
/* @req FRTP1099*/
FrTp_Internal_WaitForFlowControl(runtimeChnlData);
}
#else
/* Notify upper layer about the successful transmission */
/* @req FRTP557 */ /* @req FRTP1058 */
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_OK);
FrTp_Internal_FreeChannel(runtimeChnlData);
#endif
}
/**
* @brief - To get the right connection based on the FrTpTxSduId.
* @param frtpTxSduId - sduId request for transmit
* @param connectionIndex - Identified connection index for sudId
* @return Std_ReturnType
*/
static Std_ReturnType FrTp_Internal_GetConnectionForTxSdu(const PduIdType frtpTxSduId, uint8 *connectionIndex){
uint8 loopIndex;
Std_ReturnType retValue;
retValue = E_NOT_OK;
for (loopIndex = 0; loopIndex < FrTp_ConfigPtr->FrTpConnectionCount; loopIndex++) {
if(FrTp_ConfigPtr->FrTpConnectionConfig[loopIndex].FrTpTxSduId == frtpTxSduId)
{
*connectionIndex = loopIndex;
retValue = E_OK;
break;
}
}
return retValue;
}
/**
* @brief To assign a free channel to the connection for transmission
* @param connectionIndex - index identified for the connection with sduId
* @param runtimeChnlDataAssigned - Channel assignment pointer
*/
static void FrTp_Internal_AssignChannelForTx(const uint8 connectionIndex, const uint8 chnlIndex, FrTp_Internal_Channel_type **runtimeChnlDataAssigned, const PduInfoType* FrTpTxSduInfoPtr){
*runtimeChnlDataAssigned = &FrTp_Internal_RunTime.FrTpChannels[chnlIndex];
if(FrTp_Internal_RunTime.FrTpConnectionLockStatus[connectionIndex]==NOT_ACTIVE){
FrTp_Internal_RunTime.FrTpConnectionLockStatus[connectionIndex]=ACTIVE_TX;
}
(*runtimeChnlDataAssigned)->FrTpChannelNumber = chnlIndex;
/* Attach the connection */
(*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef = &FrTp_ConfigPtr->FrTpConnectionConfig[connectionIndex];
/* Store connection index to be able to free it and for future reference */
(*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex = connectionIndex;
/* Initialize channel variables wait counter and friferror counter */
/* @req FRTP1105 */ /* @req FRTP1114 */
(*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt = (*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxFCWait;
(*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf =(*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxFrIf;
/* Mark channel as busy if channel assignment has been finished */
(*runtimeChnlDataAssigned)->FrTpTxChannelState = FRTP_TX_STARTED; /* @req FRTP1117*/
(*runtimeChnlDataAssigned)->FrTpTxSduAvailable = TRUE; /* @req FRTP1038*/ /* @req FRTP1039 */ /* @req FRTP415 */ /* @req FRTP416 */
/* @req FRTP1044 */ /* @req FRTP1064*/ /* @req FRTP1101*/ /* @req FRTP1102 */ /* @req FRTP1043 */
if(FrTpTxSduInfoPtr->SduLength !=0) {
(*runtimeChnlDataAssigned)->FrTpTxSduUnknownMsgLength = FALSE;
}else{
(*runtimeChnlDataAssigned)->FrTpTxSduUnknownMsgLength = TRUE;
}
/* Store the total message length */
(*runtimeChnlDataAssigned)->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength = FrTpTxSduInfoPtr->SduLength;
}
/**
* @brief To Handle Tx buffer request errors.
* @param runtimeChnlData - Internal runtime data ptr for Channel used for transmit
* @param BufReqResult - Error on the buffer request
*/
static void FrTp_Internal_TxBufferRequestError(FrTp_Internal_Channel_type* runtimeChnlData,BufReq_ReturnType BufReqResult ){
switch (BufReqResult) {
case BUFREQ_E_BUSY:
/* @req FRTP402 */
/* Buffer request shall be retried FrTpMaxFcWait times */
if (runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt == 0) {
/* @req FRTP1113*/ /* @req FRTP557*/ /* @req FRTP555 */
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_WFT_OVRN);
FrTp_Internal_FreeChannel(runtimeChnlData);
}else {
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt--;
}
break;
case BUFREQ_E_NOT_OK:
/* @req FRTP1162 */ /* Abort transmission */
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_ABORT);
FrTp_Internal_FreeChannel(runtimeChnlData);
break;
default:
break;
}
}
/**
* @brief - resets all the channel parameters
* @param runtimeChnlData Internal runtime data ptr for Channel used for transmit
*/
static void FrTp_Internal_FreeChannel(FrTp_Internal_Channel_type* runtimeChnlData) {
uint8 initCount;
/* Remove channel assignment from the connections */
runtimeChnlData->FrTpTxSduAvailable = FALSE; /* @req FRTP1057 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt = 0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf = 0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength = 0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPendingCounter = 0;
runtimeChnlData->FrTpTxSduUnknownMsgLength = 0; /* @req FRTP1124 */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength =0;
runtimeChnlData->FrTpTcRequest = FALSE;
for(initCount=0; initCount < FRTP_PDUARRAY_SIZE; initCount++) {
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[initCount] = 0;
}
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterAs =0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterBs =0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterCs =0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf =0;
runtimeChnlData->FrTpFramePayloadLength=0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength = 0;
runtimeChnlData->FrTpFcRecveBuffSize=0;
runtimeChnlData->FrTpRetryInfo.TpDataState = TP_CONFPENDING;
runtimeChnlData->FrTpRetryInfo.TxTpDataCnt = 0;
runtimeChnlData->FrTpTransmitPduLength = 0;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber = 0;
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef != NULL){
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef->FrTpTxPduId].FrTpTxPduLockStatus= AVAILABLE;
}
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef = NULL_PTR;
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
runtimeChnlData->FrTpAckPending = FRTP_NO;
runtimeChnlData->FrTpuseCF1 = TRUE;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition =0;
#endif
if(FrTp_Internal_RunTime.FrTpConnectionLockStatus[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex] == ACTIVE_TX){
if(runtimeChnlData->FrTpRxChannelState == IDLE){
FrTp_Internal_RunTime.FrTpConnectionLockStatus[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex]=NOT_ACTIVE;
}else{
FrTp_Internal_RunTime.FrTpConnectionLockStatus[runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex]=ACTIVE_RX;
}
}
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex =0xFF;
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef = NULL;
runtimeChnlData->FrTpTxChannelState = IDLE; /* @req FRTP1118 */ /* @req FRTP1056 */
}
/**
* @brief - Handles the As time out parameters and attempts to resend on time out
* @param runtimeChnlData Internal runtime data ptr for Channel used for transmit
*/
static void FrTp_Internal_TimeoutAs(FrTp_Internal_Channel_type* runtimeChnlData) {
PduInfoType pduInfo;
/* @req FRTP1100 */
/* If timer is running*/
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterAs != 0) {
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterAs--;
/* If timeout expired */
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpCounterAs == 0) {
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAsTimeoutRetryCounter == 0) {
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_TIMEOUT_A);
FrTp_Internal_FreeChannel(runtimeChnlData);
} else {
/* retry for after as time out till As max counts configured */
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpAsTimeoutRetryCounter--;
pduInfo.SduLength = runtimeChnlData->FrTpTransmitPduLength;
pduInfo.SduDataPtr = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[0];
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConTxPduPoolRuntimeRef != NULL_PTR) {
(void)FrTp_Internal_SendFrame(runtimeChnlData, &pduInfo,ACTIVE_TX);
}
}
}
}
}
/**
* @brief : Function handles flow control frame received ack and retry.
* @param ChannelInternal
* @param PduInfoPtr
*/
static void FrTp_Internal_HandleRecvdFCAck(FrTp_Internal_Channel_type *ChannelInternal,PduInfoType* PduInfoPtr ) {
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
uint8 recvdBCorACK;
uint16 recvdBytePos;
uint16 calcBytepos;
SchM_Enter_FrTp_EA_0();
if(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpAckType != FRTP_NO) {
recvdBCorACK = PduInfoPtr->SduDataPtr[PCI_BYTE_2];
if(recvdBCorACK == FRTP_NO_RETRY){
ChannelInternal->FrTpAckPending = FRTP_NO;
}else if (recvdBCorACK == FRTP_ACK_WITH_RETRY){
recvdBytePos = (((uint16)(PduInfoPtr->SduDataPtr[PCI_BYTE_3]) << SHIFT_1_BYTE)|(PduInfoPtr->SduDataPtr[PCI_BYTE_4]));
/* If BP points to a buffer not yet transmitted */
if(recvdBytePos > ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition) {
/* Notify upper layer and abort transmission */
/* @req FRTP142 */
PduR_FrTpTxConfirmation(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_FR_WRONG_BP);
FrTp_Internal_FreeChannel(ChannelInternal);
}else{
calcBytepos = ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition - recvdBytePos;
/* Roll-back completed message length until the point of retry */
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength -= calcBytepos;
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpRemainingTxBufferLength += calcBytepos;
ChannelInternal->FrTpFcRecveBuffSize += calcBytepos;
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition = recvdBytePos;
ChannelInternal->FrTpuseCF1 = (ChannelInternal->FrTpuseCF1 != FALSE) ? FALSE : TRUE;
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpSerialNumber = 0;
/* Store the buffer pointer to be able to retry*/
ChannelInternal->FrTpRetryInfo.TxTpDataCnt = ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength -1;
ChannelInternal->FrTpRetryInfo.TpDataState = TP_DATARETRY;
/* Clear pending acknowledge, because of retry request */
ChannelInternal->FrTpAckPending = FRTP_NO;
ChannelInternal->FrTpTxChannelState = FRTP_TX_SEG_ONGOING;
}
}
else{
/* do Nothing */
}
SchM_Exit_FrTp_EA_0();
}
#else
(void)*PduInfoPtr;
(void)*ChannelInternal;
#endif
}
/**
* @brief - Handles the frif transmit attempts till FrTpMaxFrIf on error
* @param runtimeChnlData Internal runtime data ptr for Channel used for transmit
*/
static void FrTp_Internal_HandleFrIfError(FrTp_Internal_Channel_type* runtimeChnlData,FrtpCommType commState) {
PduInfoType pduInfo;
if(commState == ACTIVE_TX){
if( runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpFrIfTxErrNextTryTimer != 0){
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpFrIfTxErrNextTryTimer--;
}
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpFrIfTxErrNextTryTimer == 0){
if(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf != 0) {
runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf--;
pduInfo.SduLength = runtimeChnlData->FrTpTransmitPduLength;
/*@req FRTP1114 */
pduInfo.SduDataPtr = &runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxDataPdu[0];
(void)FrTp_Internal_SendFrame(runtimeChnlData, &pduInfo,ACTIVE_TX);
}
if((runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxCounterFrIf == 0) && (runtimeChnlData->FrTpTxChannelState == FRTP_FRIF_ERROR))
{
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId, NTFRSLT_E_ABORT);
FrTp_Internal_FreeChannel(runtimeChnlData);
}
}
}else if(commState == ACTIVE_RX){
if(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpFrIfRxErrNextTryTimer != 0){
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpFrIfRxErrNextTryTimer--;
}
if(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpFrIfRxErrNextTryTimer == 0){
if(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf != 0) {
runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf--;
pduInfo.SduLength = FLOW_CONTROL_FRAME_PAYLOAD;
/*@req FRTP1114 */
pduInfo.SduDataPtr = &runtimeChnlData->FrTpRxFcDataPdu[0];
(void)FrTp_Internal_SendFrame(runtimeChnlData, &pduInfo,ACTIVE_RX);
}
if((runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf == 0) && (runtimeChnlData->FrTpRxChannelState == FRTP_FRIF_ERROR))
{
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULTxPduId, NTFRSLT_E_ABORT);
resetRxChannelConfiguration(runtimeChnlData);
}
}
}else{
}
}
/**
* @brief - Handles the pdur transmit cancel and resets as per state
* @param runtimeChnlData Internal runtime data ptr for Channel used for transmit
*/
static void FrTp_Internal_HandleTxCanceled(FrTp_Internal_Channel_type* runtimeChnlData) {
#if (FRTP_TRANSMIT_CANCEL_SUPPORT == STD_ON)
/*@req FRTP1116 */ /*@req FRTP424 */
/* reset of state is cleared in FrTp_Internal_FreeChannel */
PduR_FrTpTxConfirmation(runtimeChnlData->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,NTFRSLT_E_CANCELATION_OK);
FrTp_Internal_FreeChannel(runtimeChnlData);
#else
(void)* runtimeChnlData;
#endif
}
/**
* @brief This function identifies the Frame type
* @param sdudataPtr
* @return
*/
static ISO10681FrameType getFrameType(const uint8 *sdudataPtr)
{
uint8 tpci;
ISO10681FrameType res;
tpci = sdudataPtr[PCI_BYTE_1] & ISO10681_TPCI_MASK;
switch(tpci)
{
case ISO10681_TPCI_STF:
res =START_FRAME;
#if (STD_ON == FRTP_ACK_RETRY_SUPPORT)
if( STF_ACK_SET == (sdudataPtr[PCI_BYTE_1] & ISO10681_TPCI_FS_MASK))
{
res =START_FRAME_ACK;
}
#endif
break;
case ISO10681_TPCI_CF1:
res =CONSECUTIVE_FRAME_1;
break;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
case ISO10681_TPCI_CF2:
res =CONSECUTIVE_FRAME_2;
break;
#endif
case ISO10681_TPCI_CFEOB:
res =CONSECUTIVE_FRAME_EOB;
break;
case ISO10681_TPCI_FC:
res =FLOW_CONTROL_FRAME;
break;
case ISO10681_TPCI_LF:
res =LAST_FRAME;
break;
default:
res = INVALID_FRAME;
}
return res;
}
//------------------------------------
/**
*@brief : Function validates the message recived on functional channel
* @param PduInfoPtr
* @param frame
* @return
*/
static boolean validateConnectionType(PduInfoType* PduInfoPtr,ISO10681FrameType frame,uint8 connection_count)
{
boolean status;
uint16 messagelength;
status = TRUE;
messagelength = (uint16) (PduInfoPtr->SduDataPtr[MSG_LNGTH_MSB]) << SHIFT_1_BYTE;
messagelength |= (uint16)PduInfoPtr->SduDataPtr[MSG_LNGTH_LSB];
if(TRUE == FrTp_ConfigPtr->FrTpConnectionConfig[connection_count].FrTpMultipleReceiverCon) /* Check if its a Functional connection */
{
/* @req FRTP598 */
if(((PduInfoPtr->SduLength - FRTP_HEADER_LENGTH_STF_LF) != messagelength)
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
|| (START_FRAME_ACK == frame)
#endif
)
{
status = FALSE; /*Segmented Msg Reception Not Supported on Functional Connection*/
}
}
if (status == TRUE) {
#if(STD_OFF == FRTP_ACK_RETRY_SUPPORT)
(void)frame;
#endif
}
return status;
}
//------------------------------------
/**
*@brief : Function resets the channel parameter
* @param runtimeInternalChnllData
*/
static void resetRxChannelConfiguration(FrTp_Internal_Channel_type *runtimeInternalChnllData)
{
uint8 initCount;
runtimeInternalChnllData->FrTpRxChannelState = IDLE; /* @req FRTP1026 */
runtimeInternalChnllData->FrTpRxPduAvailable = FALSE;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxFcWt = 0;
runtimeInternalChnllData->FrTpRxSizeBuffer = 0;
for(initCount=0;initCount<FRTP_PDUARRAY_SIZE;initCount++)
{
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[initCount] = 0;
}
for(initCount=0;initCount<FLOW_CONTROL_FRAME_PAYLOAD;initCount++)
{
runtimeInternalChnllData->FrTpRxFcDataPdu[initCount] = 0;
}
#if FRTP_ACK_RETRY_SUPPORT == STD_ON
runtimeInternalChnllData->FrTpStfAckFlag = FALSE;
runtimeInternalChnllData->FrTpRxFcRetryFlag = FALSE;
runtimeInternalChnllData->FrTpEobReceivedFlag = FALSE;
runtimeInternalChnllData->FrTpStfReceivedFlag = FALSE;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxBlockPosition = 0;
#endif
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCompletedRxMessageLength = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpFrIfRxErrNextTryTimer = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPendingCounter = 0;
if(runtimeInternalChnllData->FrTpTxChannelState == IDLE){
FrTp_Internal_RunTime.FrTpConnectionLockStatus[runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpAssignedRxConnectionIndex]= NOT_ACTIVE;
}
if(runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef != NULL){
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef->FrTpTxPduId].FrTpTxPduLockStatus= AVAILABLE;
}
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef = NULL_PTR;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef = NULL_PTR;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPendingCounter = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength =0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCompletedRxMessageLength = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRemainingRxBufferLength = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpArTimeoutRetryCounter = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterBr = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf = 0;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTPRxSquenceNumber = 0xFF;
runtimeInternalChnllData->FrTpChannelParams.FrTpRxChannel.FrTpAssignedRxConnectionIndex = 0;
}
//------------------------------------
/**
* @brief : Function extracts the Source and Target address
* @param PduInfoPtr
* @param frameAddressInfo
*/
static void getFrameAddress(const PduInfoType *PduInfoPtr, ISO10681PduAddressType *frameAddressInfo)
{
uint16 address;
address= (uint16)PduInfoPtr->SduDataPtr[TARGET_ADDR_MSB];
frameAddressInfo->Target_Address = (uint16)((address<<SHIFT_1_BYTE) | (uint16)PduInfoPtr->SduDataPtr[TARGET_ADDR_LSB]);
address= (uint16)PduInfoPtr->SduDataPtr[SOURCE_ADDR_MSB];
frameAddressInfo->Source_Address = (uint16)((address<<SHIFT_1_BYTE) | (uint16)PduInfoPtr->SduDataPtr[SOURCE_ADDR_LSB]);
}
//------------------------------------
/**
* @brief Function sends the flow control Frame as per the flowstautus provided
* @param ChannelInternal
* @param flowstatus
* @param Retry_flag
*/
static void sendFlowControlFrame(FrTp_Internal_Channel_type *ChannelInternal, uint8 flowstatus, boolean Retry_flag) {
PduInfoType pduInfo;
uint16 buffersize ;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
uint16 blockposition;
#endif
uint8 *sduData;
uint8 count;
uint8 count1;
uint8 indexcount;
uint8 bandwidthcontrol;
indexcount = 0;
(void)Retry_flag;
pduInfo.SduDataPtr = &ChannelInternal->FrTpRxFcDataPdu[0];
sduData = &ChannelInternal->FrTpRxFcDataPdu[0];
/* FC Frame target Address */ /* @req FRTP1080 */
sduData[indexcount] = (uint8)((ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRa & MSB_BYTE_MASK)>>SHIFT_1_BYTE) ;
indexcount++;
sduData[indexcount] = (uint8)(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRa & LSB_BYTE_MASK) ;
indexcount++;/* FC frane Source address */
sduData[indexcount] = (uint8)((ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpLa & MSB_BYTE_MASK)>>SHIFT_1_BYTE) ;
indexcount++;
sduData[indexcount] = (uint8)(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpLa & LSB_BYTE_MASK) ;
switch(flowstatus) {
case ISO10681_FC_STATUS_CTS :
if(FALSE != ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpBandwidthLimitation){
bandwidthcontrol =(uint8)(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxNbrOfNPduPerCycle << SHIFT_3_BITS);
bandwidthcontrol |= ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpSCexp;
}else{
bandwidthcontrol = 0;
}
buffersize = ChannelInternal->FrTpRxSizeBuffer;
indexcount++;
sduData[indexcount] = ISO10681_TPCI_FC | ISO10681_FC_STATUS_CTS;
indexcount++;
sduData[indexcount] = bandwidthcontrol;
indexcount++;
sduData[indexcount] = (uint8)((buffersize & MSB_BYTE_MASK)>>SHIFT_1_BYTE);
indexcount++;
sduData[indexcount] = (uint8)(buffersize & LSB_BYTE_MASK);
break;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
case ISO10681_FC_STATUS_ACK_RET :
indexcount++;
sduData[indexcount] = ISO10681_TPCI_FC | ISO10681_FC_STATUS_ACK_RET;
indexcount++;
sduData[indexcount] = (uint8)Retry_flag;
if(TRUE == Retry_flag){
blockposition = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxBlockPosition;
ChannelInternal->FrTpRxFcRetryFlag = TRUE;
indexcount++;
sduData[indexcount] = (uint8)((blockposition & MSB_BYTE_MASK)>>SHIFT_1_BYTE);
indexcount++;
sduData[indexcount] = (uint8)(blockposition & LSB_BYTE_MASK);
}else{
indexcount++;
sduData[indexcount] = 0;
indexcount++;
sduData[indexcount] = 0;
}
break;
#endif
case ISO10681_FC_STATUS_WAIT :
indexcount++;
sduData[indexcount] = ISO10681_TPCI_FC | ISO10681_FC_STATUS_WAIT;
break;
case ISO10681_FC_STATUS_ABORT :
indexcount++;
sduData[indexcount] = ISO10681_TPCI_FC | ISO10681_FC_STATUS_ABORT;
break;
case ISO10681_FC_STATUS_OVFL :
indexcount++;
sduData[indexcount] = ISO10681_TPCI_FC | ISO10681_FC_STATUS_OVFL;
break;
default :
break;
}
pduInfo.SduLength = FLOW_CONTROL_FRAME_PAYLOAD;
count1 = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpPoolTxPduCnt;
/* Implementation of FRTP1045 1st free TX PDU*/
for(count=0; (count < count1); count++) {
if ( AVAILABLE == FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpTxPduLockStatus){
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpTxPduLockStatus = LOCKED_FOR_FC;
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpChannleHandle = ChannelInternal->FrTpChannelNumber;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef = &ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count];
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpChannleHandle
= ChannelInternal->FrTpChannelNumber;
break;
}
}
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef != NULL_PTR){
(void)FrTp_Internal_SendFrame(ChannelInternal, &pduInfo,ACTIVE_RX);
}else{
/* @req FRTP1047 */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxPrevChannelState = ChannelInternal->FrTpRxChannelState;
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_FC_SENDING;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterBr = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpTimeBr;
}
}
//------------------------------------
/**
*@brief : This functions either copys the data to upper layer or terminates the connection based on retun_value provided
* @param retun_value
* @param ChannelInternal
* @return
*/
static BufReq_ReturnType copySegmentToPduRRxBuffer(BufReq_ReturnType action_value,FrTp_Internal_Channel_type *ChannelInternal)
{
PduInfoType frTpRxSduDataPtr;
PduIdType frTpRxSduId_lcl;
BufReq_ReturnType actionLcl;
actionLcl = BUFREQ_E_NOT_OK;
switch (action_value)
{
case BUFREQ_OK :
if((FRTP_RX_WAIT_CF == ChannelInternal->FrTpRxChannelState)||(FRTP_EOB_RECEIVED_WAIT_SDU_BUFFER == ChannelInternal->FrTpRxChannelState))
{ /* @req FRTP1079 */
frTpRxSduDataPtr.SduDataPtr = &ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[START_OF_DATA_BYTE_CF];
}
else
{ /* @req FRTP1079 */
frTpRxSduDataPtr.SduDataPtr = &ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[START_OF_DATA_BYTE_STF_LF];
}
frTpRxSduDataPtr.SduLength = (PduLengthType)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE];
/* @req FRTP1138*/
frTpRxSduId_lcl = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId;
actionLcl = PduR_FrTpCopyRxData(frTpRxSduId_lcl, &frTpRxSduDataPtr,&ChannelInternal->FrTpRxSizeBuffer);
break;
case BUFREQ_E_NOT_OK:
/* @req FRTP405 */
if(FRTP_STF_RECEIVED != ChannelInternal->FrTpRxChannelState)
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_E_ABORT);
}
if(FRTP_RX_WAIT_CF != ChannelInternal->FrTpRxChannelState){
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ABORT,FALSE);/* Sending FC with ABORT handle */
ChannelInternal->FrTpRxPduAvailable = FALSE;
}else{
resetRxChannelConfiguration(ChannelInternal);
}
actionLcl = BUFREQ_E_NOT_OK;
break;
case BUFREQ_E_BUSY :
if((FRTP_RX_WAIT_CF != ChannelInternal->FrTpRxChannelState)){
/* @req FRTP1160 */
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_WAIT,FALSE);/* Sending FC with WAIT handle */
}else{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_E_ABORT);
resetRxChannelConfiguration(ChannelInternal);
}
actionLcl = BUFREQ_E_BUSY;
break;
case BUFREQ_E_OVFL :
/* @req FRTP1161 */
if(FRTP_STF_RECEIVED != ChannelInternal->FrTpRxChannelState)
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_E_ABORT);
}
if(FRTP_RX_WAIT_CF != ChannelInternal->FrTpRxChannelState){
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_OVFL,FALSE);/* Sending FC with OVFL handle */
ChannelInternal->FrTpRxPduAvailable = FALSE;
}else{
resetRxChannelConfiguration(ChannelInternal);
}
actionLcl = BUFREQ_E_OVFL;
break;
default :
actionLcl = BUFREQ_E_NOT_OK;
break;
}
return actionLcl;
}
//---------------------------------------------------------
/**
* @brief This function handles the return value of copySegmentToPduRRxBuffer for STF frame
* @param retun_value
* @param ChannelInternal
* @param stf_ack_flag
*/
static void handlePdurReturn(BufReq_ReturnType retun_value,FrTp_Internal_Channel_type *ChannelInternal, boolean stf_ack_flag)
{
(void)stf_ack_flag;
if(BUFREQ_OK == retun_value){
if((PduLengthType)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE] == ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength)/* For Single frame reception*/
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_OK); /* @req FRTP1083 */
#if (STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(TRUE == stf_ack_flag) /* for Single Frame with ACK*/
{
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ACK_RET, FALSE); /* Sending FC with ACK handle */
}else{
resetRxChannelConfiguration(ChannelInternal);
}
#else
resetRxChannelConfiguration(ChannelInternal);
#endif
}
else /* for Segmented Msg Reception frames */
{
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_CF;
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_CTS,FALSE);
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCompletedRxMessageLength += (PduLengthType) ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE]; /* This will be BytePostion in case of SN Error is detected And re-try is required*/
}
ChannelInternal->FrTpRxPduAvailable = FALSE;
}
if(BUFREQ_E_BUSY == retun_value){
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_STF_SDU_BUFFER;
}
}
//------------------------------------
/**
* @brief Function copies STF frame to local buffer and indicates the upper layer of the start of reception
* @param ChannelInternal
* @param PduInfoPtr
* @param channel
*/
static void handleStartFrame(FrTp_Internal_Channel_type *ChannelInternal,PduInfoType *PduInfoPtr )
{
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength = ((((PduLengthType)(PduInfoPtr->SduDataPtr[MSG_LNGTH_MSB]) << SHIFT_1_BYTE )) |(PduLengthType) (PduInfoPtr->SduDataPtr[MSG_LNGTH_LSB]) );
if(PduInfoPtr->SduDataPtr[FPL_BYTE] > MAX_STF_PAYLOAD){
/* FPL Error in STF , IGNORE the Frame */
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return;
}
/* STF with known msg length*/
if( 0 != ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength)
{
/* @req FRTP1077 */
memcpy(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu, &PduInfoPtr->SduDataPtr[0], PduInfoPtr->SduLength);
/* @req FRTP399 */ /* @req FRTP1078 */
ChannelInternal->FrTpUlReturnValue = PduR_FrTpStartOfReception(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId, ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength, &ChannelInternal->FrTpRxSizeBuffer );
}
else
{
/* @req FRTP1077 */ /* @req FRTP1184*/
memcpy(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu, &PduInfoPtr->SduDataPtr[0], PduInfoPtr->SduLength);
ChannelInternal->FrTpUlReturnValue = PduR_FrTpStartOfReception(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId, UKNOWN_MSG_LENGHT, &ChannelInternal->FrTpRxSizeBuffer );
}
if(BUFREQ_E_BUSY == ChannelInternal->FrTpUlReturnValue)
{
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxFCWait == 0u){
resetRxChannelConfiguration(ChannelInternal);
}else{
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_STF_SDU_BUFFER;
}
}
else
{
ChannelInternal->FrTpRxChannelState = FRTP_STF_RECEIVED;
}
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTPRxSquenceNumber = 0;
}
/**
*@brief This functions detect if an Sequence error has occurred in CF reception
* @param ChannelInternal
* @return
*/
static boolean handelSequenceError(FrTp_Internal_Channel_type *ChannelInternal)
{
uint8 cf_sequence_number;
boolean sequenceCorrect;
sequenceCorrect = TRUE;
cf_sequence_number = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[PCI_BYTE_1] & FRTP_MAX_SERIALNUMBER;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(((0 != cf_sequence_number) && (TRUE == ChannelInternal->FrTpRxFcRetryFlag)) ||
(cf_sequence_number != ((ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTPRxSquenceNumber+FRTP_ONE)%0x10)))
{
ChannelInternal->FrTpCounterRxRn++;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTPRxSquenceNumber = 0xFu; /* This helps in correct retry with Sequence No as 0 */
if(ChannelInternal->FrTpCounterRxRn <= ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxRn){
ChannelInternal->FrTpRxFcRetryFlag = TRUE;
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ACK_RET,TRUE); /* In case of Sequence error For ACK Msg */
ChannelInternal->FrTpRxPduAvailable = FALSE;
}else{
/* @req FRTP1113*/
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRxSduId, NTFRSLT_E_WRONG_SN);
resetRxChannelConfiguration(ChannelInternal);
}
sequenceCorrect = FALSE;
}
#else
if(cf_sequence_number != ((ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTPRxSquenceNumber+FRTP_ONE)%0x10)){
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRxSduId, NTFRSLT_E_WRONG_SN);
resetRxChannelConfiguration(ChannelInternal);
sequenceCorrect = FALSE;
}
#endif
return sequenceCorrect;
}
//------------------------------------
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
static void updateBlockPosition(FrTp_Internal_Channel_type *ChannelInternal)
{
if(ChannelInternal->FrTpEobReceivedFlag != TRUE)
{
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxBlockPosition += ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE];
}
else{
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxBlockPosition = 0u;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxBlockPosition += ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE];
ChannelInternal->FrTpEobReceivedFlag = FALSE;
}
}
#endif
//------------------------------------
/**
* @brief : Function handels the CF frames of segmented msg transmission
* @param ChannelInternal
* @param frameType
*/
static void handelconsecutiveframes(FrTp_Internal_Channel_type *ChannelInternal,ISO10681FrameType frameType)
{
BufReq_ReturnType ret_lcl = BUFREQ_E_NOT_OK;
static PduInfoType tempPdu;
boolean sequenceCorrect;
boolean status;
status = TRUE;
sequenceCorrect = handelSequenceError(ChannelInternal);
/* FPL validity to check */
if(TRUE == sequenceCorrect){
if((PduLengthType)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE] <= ChannelInternal->FrTpRxSizeBuffer ) /* When CF Payload is more than remaining Buffersize*/
{
ret_lcl = copySegmentToPduRRxBuffer(BUFREQ_OK,ChannelInternal);
if(BUFREQ_OK == ret_lcl){
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTPRxSquenceNumber++;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCompletedRxMessageLength += (PduLengthType)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE]; /* This will be BytePostion in case of SN Error is detected And re try is required*/
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(FALSE != ChannelInternal->FrTpRxFcRetryFlag){
ChannelInternal->FrTpRxFcRetryFlag = FALSE; /* in case this was a successful retry reset the FC retryflag */
ChannelInternal->FrTpCounterRxRn = 0;
}
updateBlockPosition(ChannelInternal);
#endif
if(CONSECUTIVE_FRAME_EOB == frameType){
ChannelInternal->FrTpRxChannelState = FRTP_EOB_RECEIVED_WAIT_SDU_BUFFER;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
ChannelInternal->FrTpEobReceivedFlag = TRUE;
#endif
tempPdu.SduLength = 0;
tempPdu.SduDataPtr = NULL_PTR;
ret_lcl = PduR_FrTpCopyRxData(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRxSduId, &tempPdu, &ChannelInternal->FrTpRxSizeBuffer);
if(BUFREQ_OK == ret_lcl){
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_CTS,FALSE);
ChannelInternal->FrTpRxPduAvailable = FALSE;
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_CF;
}else{
if(BUFREQ_E_BUSY== ret_lcl){
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxFCWait == 0u){
resetRxChannelConfiguration(ChannelInternal);
status = FALSE;
}else{
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxFcWt++;
}
}
}
}else{
ChannelInternal->FrTpRxPduAvailable = FALSE;
}
}
}else{
ret_lcl = BUFREQ_E_OVFL;
}
if(status == TRUE) {
if(BUFREQ_OK != ret_lcl){
(void)copySegmentToPduRRxBuffer(ret_lcl,ChannelInternal);
}
else{
/*Execution should not reach here */
}
}
}else{
ChannelInternal->FrTpRxPduAvailable = FALSE;
}
}
static void handelLastFrame(FrTp_Internal_Channel_type *ChannelInternal)
{
uint16 lfMsgLengthCount;
BufReq_ReturnType ret_lcl = BUFREQ_E_NOT_OK;
boolean status;
status = TRUE;
lfMsgLengthCount = (((uint16)(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[MSG_LNGTH_MSB]) << SHIFT_1_BYTE ) | (uint16)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[MSG_LNGTH_LSB] );
if((ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength != lfMsgLengthCount) ||
(lfMsgLengthCount != (ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCompletedRxMessageLength + (PduLengthType) ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE])))
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRxSduId, NTFRSLT_E_FR_ML_MISMATCH);
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(TRUE == ChannelInternal->FrTpStfAckFlag){
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ABORT,FALSE);
ChannelInternal->FrTpRxPduAvailable = FALSE;
}else{
resetRxChannelConfiguration(ChannelInternal);
}
#else
resetRxChannelConfiguration(ChannelInternal);
#endif
status = FALSE;
}
else if((PduLengthType)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE] <= ChannelInternal->FrTpRxSizeBuffer ) /* When CF Payload is more than remaining Buffersize*/
{
ret_lcl = copySegmentToPduRRxBuffer(BUFREQ_OK,ChannelInternal);
if(BUFREQ_OK == ret_lcl){
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId,NTFRSLT_OK); /* @req FRTP1083 */
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(TRUE == ChannelInternal->FrTpStfAckFlag){
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ACK_RET,FALSE);
ChannelInternal->FrTpRxPduAvailable = FALSE;
}
else{
resetRxChannelConfiguration(ChannelInternal);
}
#else
resetRxChannelConfiguration(ChannelInternal);
#endif
}
}else{
ret_lcl= BUFREQ_E_OVFL;
}
if (status == TRUE) {
if(BUFREQ_OK != ret_lcl){
if(BUFREQ_E_BUSY == ret_lcl){
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ABORT,FALSE);/* This will not be sent from copySegmentToPduRRxBuffer for BUSY */
ChannelInternal->FrTpRxPduAvailable = FALSE;
#else
resetRxChannelConfiguration(ChannelInternal);
#endif
}else{
(void)copySegmentToPduRRxBuffer(ret_lcl,ChannelInternal);
}
}
}
}
//------------------------------------
/**
* @brief : Function handles the wait scenarios when buffer is not provided by Upper layer
* @param ChannelInternal
*/
static void handelpduRwaitcalls(FrTp_Internal_Channel_type *ChannelInternal)
{
BufReq_ReturnType ret_lcl = BUFREQ_OK;
static PduInfoType tempPdu;
uint8 fplLength;
fplLength = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE];
switch(ChannelInternal->FrTpRxChannelState)
{
case FRTP_RX_WAIT_STF_SDU_BUFFER :
ret_lcl = PduR_FrTpStartOfReception(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId, ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength, &ChannelInternal->FrTpRxSizeBuffer );
if(BUFREQ_OK == ret_lcl)
{
ret_lcl = copySegmentToPduRRxBuffer(BUFREQ_OK, ChannelInternal);
if(BUFREQ_OK == ret_lcl){
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxFcWt = 0;
ChannelInternal->FrTpRxPduAvailable = FALSE; /* @req FRTP421 */
if(fplLength == ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxMessageLength)/* For Single frame reception*/
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRxSduId,NTFRSLT_OK);
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(TRUE == ChannelInternal->FrTpStfAckFlag) /* for Single Frame with ACK*/
{
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_ACK_RET, FALSE); /* Sending FC with ACK handle */
ChannelInternal->FrTpRxPduAvailable = FALSE;
}
#else
resetRxChannelConfiguration(ChannelInternal);
#endif
}else{
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_CF;
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_CTS,FALSE);
ChannelInternal->FrTpRxPduAvailable = FALSE;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCompletedRxMessageLength += (PduLengthType)ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu[FPL_BYTE];
}
}
}
break;
case FRTP_EOB_RECEIVED_WAIT_SDU_BUFFER :
tempPdu.SduLength = 0;
tempPdu.SduDataPtr = NULL_PTR;
ret_lcl = PduR_FrTpCopyRxData(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULRxPduId, &tempPdu, &ChannelInternal->FrTpRxSizeBuffer);
if(BUFREQ_OK == ret_lcl){
ChannelInternal->FrTpRxChannelState = FRTP_RX_WAIT_CF;
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_CTS,FALSE);
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxFcWt = 0;
ChannelInternal->FrTpRxPduAvailable = FALSE; /* @req FRTP421 */
}
break;
default:
break;
}
if(BUFREQ_E_BUSY == ret_lcl){
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxFcWt++;
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxFcWt > ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxFCWait)
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRxSduId, NTFRSLT_E_WFT_OVRN);
resetRxChannelConfiguration(ChannelInternal);
}
else /* @req FRTP1113 */
{
sendFlowControlFrame(ChannelInternal,ISO10681_FC_STATUS_WAIT,FALSE);
}
}
else if((BUFREQ_E_OVFL == ret_lcl) || (BUFREQ_E_NOT_OK == ret_lcl)){
(void)copySegmentToPduRRxBuffer(ret_lcl, ChannelInternal);
}
else{
/* Execution should not reach here */
}
}
/**
*@brief The function handles Cr Timing Parameter
* @param ChannelInternal
*/
static void handelCrTimeout(FrTp_Internal_Channel_type *ChannelInternal){
/* @req FRTP1100 */ /* Time out for CR */
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr != 0)
{
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr --;
}
else
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULTxPduId, NTFRSLT_E_TIMEOUT_CR);
resetRxChannelConfiguration(ChannelInternal);
}
}
/**
*@brief The function handles Ar Timing Parameter
* @param ChannelInternal
*/
static void handelArTimeout(FrTp_Internal_Channel_type *ChannelInternal){
/* @req FRTP1100 */ /* Time out for AR */
PduInfoType pduInfo;
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr != 0){
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr --;
}
if(0 == ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterAr){
if(0 == ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpArTimeoutRetryCounter){
PduR_FrTpTxConfirmation(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULTxPduId, NTFRSLT_E_TIMEOUT_A);
resetRxChannelConfiguration(ChannelInternal);
}else{
/* retry after timeout */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpArTimeoutRetryCounter --;
pduInfo.SduLength = FLOW_CONTROL_FRAME_PAYLOAD;
pduInfo.SduDataPtr = &ChannelInternal->FrTpRxFcDataPdu[0];
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPendingCounter--;
/* Not searching new Tx Pdu_ID since we already have one locked for our FC Transmission*/
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef != NULL_PTR) {
(void)FrTp_Internal_SendFrame(ChannelInternal, &pduInfo,ACTIVE_RX);
}
}
}
}
static void handelBrTimeout(FrTp_Internal_Channel_type *ChannelInternal){
/* @req FRTP1100 */ /* Time out for BR */
PduInfoType pduInfo;
boolean fcSent;
uint8 count;
uint8 txPduPoolCount;
fcSent = FALSE;
pduInfo.SduDataPtr = &ChannelInternal->FrTpRxFcDataPdu[0];
pduInfo.SduLength = FLOW_CONTROL_FRAME_PAYLOAD;
txPduPoolCount = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpPoolTxPduCnt;
/* Implementaion of FRTP1045 1st free TX PDU*/
for(count=0; (count < txPduPoolCount); count++) {
if ( AVAILABLE == FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpTxPduLockStatus){
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpTxPduLockStatus = LOCKED_FOR_FC;
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpChannleHandle = ChannelInternal->FrTpChannelNumber;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef = &ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count];
FrTp_Internal_RunTime.FrTpTxPduStatusInfo[ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpTxPduPoolRef[count].FrTpFrIfTxPduId].FrTpChannleHandle
= ChannelInternal->FrTpChannelNumber;
fcSent = TRUE;
break;
}
}
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPoolRuntimeRef != NULL_PTR){
ChannelInternal->FrTpRxChannelState = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxPrevChannelState;
(void)FrTp_Internal_SendFrame(ChannelInternal, &pduInfo,ACTIVE_RX);
}
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterBr --;
if(fcSent == TRUE){
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterBr = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpTimeBr;
}
else if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterBr == 0)
{
PduR_FrTpRxIndication(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpULTxPduId, NTFRSLT_E_ABORT);
resetRxChannelConfiguration(ChannelInternal);
}else{
/* do nothing */
}
}
/**
* @brief : Function handles flow control frame received when acting as sender.
* @param ChannelInternal
* @param PduInfoPtr
*/
static void handelflowcontrolframe(FrTp_Internal_Channel_type *ChannelInternal,PduInfoType* PduInfoPtr )
{
switch((PduInfoPtr->SduDataPtr[PCI_BYTE_1] & ISO10681_TPCI_FS_MASK)) {
case ISO10681_FC_STATUS_CTS :
if(ChannelInternal->FrTpTxChannelState == FRTP_TX_WAIT_FOR_FC){
ChannelInternal->FrTpFcRecveBuffSize = (((PduLengthType)(PduInfoPtr->SduDataPtr[PCI_BYTE_3]) << SHIFT_1_BYTE)|(PduLengthType)(PduInfoPtr->SduDataPtr[PCI_BYTE_4]));
ChannelInternal->FrTpBandwidthcontol = PduInfoPtr->SduDataPtr[PCI_BYTE_2];
if(ChannelInternal->FrTpFcRecveBuffSize == 0) {
#if (FRTP_UNKOWN_MSG_LNGT == STD_ON)
if(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength != 0) {
#endif
/* If BfS is 0 and remaining message can be sent in one burst so only transmit buffer limits the transmission */
ChannelInternal->FrTpFcRecveBuffSize = ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength - ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength;
#if (FRTP_UNKOWN_MSG_LNGT == STD_ON)
}else{
ChannelInternal->FrTpFcRecveBuffSize = 0xFFFF;
}
#endif
}else{
if(
#if (FRTP_UNKOWN_MSG_LNGT == STD_ON)
(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength != 0) &&
#endif
(ChannelInternal->FrTpFcRecveBuffSize > (ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength - ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength)) ) {
ChannelInternal->FrTpFcRecveBuffSize = ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpMessageLength - ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpCompletedMessageLength;
}
}
#if (FRTP_ACK_RETRY_SUPPORT == STD_ON)
/* If FlowControl CTS received the previous block is acknowledged */
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxBlockPosition = 0;
ChannelInternal->FrTpRetryInfo.TpDataState = TP_DATACONF;
#endif
/* Reset Wait Counter */
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxFcWt = ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpMaxFCWait;
ChannelInternal->FrTpTxChannelState = FRTP_TX_SEG_ONGOING;
}
break;
case ISO10681_FC_STATUS_ACK_RET:
FrTp_Internal_HandleRecvdFCAck(ChannelInternal,PduInfoPtr);
break;
case ISO10681_FC_STATUS_WAIT:
if(ChannelInternal->FrTpTxChannelState == FRTP_TX_WAIT_FOR_FC) {
/* Restart Bs timer */
ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpCounterBs = ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpConCtrlRef->FrTpTimeoutBs;
}
break;
case ISO10681_FC_STATUS_ABORT:
PduR_FrTpTxConfirmation(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,NTFRSLT_E_ABORT);
FrTp_Internal_FreeChannel(ChannelInternal);
break;
case ISO10681_FC_STATUS_OVFL:
PduR_FrTpTxConfirmation(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,NTFRSLT_E_NO_BUFFER);
FrTp_Internal_FreeChannel(ChannelInternal);
break;
default:
/* Abort transmission if invalid FS */
PduR_FrTpTxConfirmation(ChannelInternal->FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpULTxPduId,NTFRSLT_E_INVALID_FS);
FrTp_Internal_FreeChannel(ChannelInternal);
break;
}
}
/**
*
* @return
*/
static uint8 frtpRxStfAssignConnections(PduInfoType* PduInfoPtr,uint8 connection_count,ISO10681FrameType frameTypelcl){
uint8 count;
uint8 ret;
boolean status;
status = TRUE;
ret = 0u;
FrTp_Internal_Channel_type *ChannelInternal;
if(FrTp_Internal_RunTime.FrTpConnectionLockStatus[connection_count]== NOT_ACTIVE){
for(count = 0; count< FRTP_CHANNEL_NUM ; count++){
if(IDLE == FrTp_Internal_RunTime.FrTpChannels[count].FrTpRxChannelState){
FrTp_Internal_RunTime.FrTpConnectionLockStatus[connection_count] = ACTIVE_RX;
break;
}
}
}else{
for(count = 0;count<FRTP_CHANNEL_NUM;count++){
if((FrTp_Internal_RunTime.FrTpChannels[count].FrTpChannelParams.FrTpRxChannel.FrTpAssignedRxConnectionIndex == connection_count )
||(FrTp_Internal_RunTime.FrTpChannels[count].FrTpChannelParams.FrTpTxChannel.FrTpAssignedConnectionIndex == connection_count)){
ChannelInternal = &FrTp_Internal_RunTime.FrTpChannels[count];
#if(STD_OFF == FRTP_FULL_DUPLEX_ENABLE)
if(ChannelInternal->FrTpTxChannelState != IDLE){
ret = FRTP_CHANNEL_NUM; /* since returning this value will result in DET error E_NO_CHANNEL */
status = FALSE;
break;
}
#endif
if(ChannelInternal->FrTpRxChannelState != IDLE){
resetRxChannelConfiguration(ChannelInternal);
}
/*lint -e{9011} break is used to terminate the loop*/
break;
}
}
}
/*lint -e{774} if evaluated to FALSE depending on FRTP_FULL_DUPLEX_ENABLE is STD_ON or STD_OFF */
if (status == TRUE) {
if(count < FRTP_CHANNEL_NUM){
ChannelInternal = &FrTp_Internal_RunTime.FrTpChannels[count];
(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef) = &FrTp_ConfigPtr->FrTpConnectionConfig[connection_count];
ChannelInternal->FrTpRxChannelState = BUSY; /* @req FRTP1025 */
ChannelInternal->FrTpRxPduAvailable = TRUE; /* @req FRTP1074 */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpAssignedRxConnectionIndex = connection_count;
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxCounterFrIf = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxFrIf;
/* Set Ar Counter To Max */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpArTimeoutRetryCounter = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxAr;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
if(START_FRAME_ACK == frameTypelcl)
{
ChannelInternal->FrTpStfAckFlag = TRUE;
}
#else
(void)frameTypelcl;
#endif
handleStartFrame(ChannelInternal,PduInfoPtr);
}
} else {
count = ret;
}
/*lint -e{438} ret is updated depending on FRTP_FULL_DUPLEX_ENABLE is STD_ON or STD_OFF */
return count;
}
//------------------------------------
/**
* @brief : Function Manages the connection for the STF frame received.
* @param PduInfoPtr
* @param RxPduId
* @param frameTypelcl
* @param frameAddressInfo
* @return
*/
static uint8 frtpManageStfConnections(PduInfoType* PduInfoPtr,PduIdType RxPduId,ISO10681FrameType frameTypelcl,
ISO10681PduAddressType frameAddressInfo)
{
uint8 count;
uint8 pduCnt;
uint8 connection_count;
boolean frtpconnectionfound;
boolean frameValidity;
connection_count = INVALID_CONNECTION;
frtpconnectionfound = FALSE;
for(count= 0; (count < FrTp_ConfigPtr->FrTpConnectionCount ) && (FALSE==frtpconnectionfound);count++)
{
if((frameAddressInfo.Target_Address == FrTp_ConfigPtr->FrTpConnectionConfig[count].FrTpLa)
&& (frameAddressInfo.Source_Address == FrTp_ConfigPtr->FrTpConnectionConfig[count].FrTpRa))
{ /* @req FRTP1069 */
for(pduCnt = 0; (pduCnt < FrTp_ConfigPtr->FrTpConnectionConfig[count].FrTpRxPduRefCount) && (FALSE==frtpconnectionfound); pduCnt ++)
{
if(RxPduId == FrTp_ConfigPtr->FrTpConnectionConfig[count].FrTpRxPduPoolRef[pduCnt].FrTpRxPduId){
frtpconnectionfound = TRUE; /**/
connection_count = count;/* @req FRTP1071*/
}
}
/* @req FRTP1075*/
FRTP_DET_REPORTERROR((frtpconnectionfound == TRUE),FRTP_SERVICE_ID_RX_INDICATION,FRTP_E_INVALID_PDU_SDU_ID,connection_count);
}
}
if(frtpconnectionfound==TRUE){
frameValidity = validateConnectionType(PduInfoPtr,frameTypelcl,connection_count);
if(frameValidity == TRUE){
connection_count = frtpRxStfAssignConnections(PduInfoPtr,connection_count,frameTypelcl);
}
}
return connection_count;
}
/**
* @brief : Function Manages the connection for the CF frame received.
* @param PduInfoPtr
* @param frameTypelcl
* @param frameAddressInfo
*/
static void frtpManageCfConnections(PduInfoType* PduInfoPtr, ISO10681FrameType frameTypelcl, ISO10681PduAddressType frameAddressInfo)
{
FrTp_Internal_Channel_type *ChannelInternal;
uint8 channel_count;
for(channel_count = 0; channel_count< FRTP_CHANNEL_NUM; channel_count++) {
if(FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpChannelParams.FrTpRxChannel.FrTpRxConRef!=NULL_PTR){
if((frameAddressInfo.Target_Address == FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpLa)
&& (frameAddressInfo.Source_Address == FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpRa)) {
if((FRTP_RX_WAIT_CF == FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpRxChannelState)) {
ChannelInternal = &FrTp_Internal_RunTime.FrTpChannels[channel_count];
ChannelInternal->FrTpRxPduAvailable = TRUE; /* @req FRTP1074*/
memcpy(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu, &PduInfoPtr->SduDataPtr[0], PduInfoPtr->SduLength);
/* Restart Cr timer */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpTimeoutCr;
if(LAST_FRAME == frameTypelcl){
ChannelInternal->FrTpRxChannelState = RX_LAST_FRAME; /* Assigning it here helps in FrTp_CancelReceive function */
/* Set Ar Counter To Max */ /*@req FRTP1114 */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpArTimeoutRetryCounter = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxAr;
/* Last Frame Received Stop this timer */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpCounterCr = 0u;
}else if(CONSECUTIVE_FRAME_EOB == frameTypelcl){
/* Set Ar Counter To Max */
ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpArTimeoutRetryCounter = ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConRef->FrTpConCtrlRef->FrTpMaxAr;
}else{
/* do nothing */
}
break;
}
}
}
}
}
/**
* @brief : Function Manages the connection for the FC frame received.
* @param PduInfoPtr
* @param frameTypelcl
* @param frameAddressInfo
*/
static void frtpManageFcConnections(PduInfoType* PduInfoPtr, ISO10681PduAddressType frameAddressInfo)
{
FrTp_Internal_Channel_type *ChannelInternal;
uint8 channel_count;
for(channel_count = 0; channel_count< FRTP_CHANNEL_NUM; channel_count++) {
if(FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpChannelParams.FrTpTxChannel.FrTpTxConRef != NULL_PTR){
if((frameAddressInfo.Target_Address == FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpLa)
&& (frameAddressInfo.Source_Address == FrTp_Internal_RunTime.FrTpChannels[channel_count].FrTpChannelParams.FrTpTxChannel.FrTpTxConRef->FrTpRa)){
ChannelInternal = &FrTp_Internal_RunTime.FrTpChannels[channel_count];
handelflowcontrolframe(ChannelInternal,PduInfoPtr);
break;
}
}
}
}
/**
*@brief : This function handles the Frames received.
*/
static void handleReceivedFrame(FrTp_Internal_Channel_type *ChannelInternal)
{
BufReq_ReturnType ret_lcl;
ISO10681FrameType frameTypelcl;
if(TRUE == ChannelInternal->FrTpRxPduAvailable){
/*Check if any data copy to PDUR is Pending */
if((ChannelInternal->FrTpRxChannelState == FRTP_RX_WAIT_STF_SDU_BUFFER )||(ChannelInternal->FrTpRxChannelState == FRTP_EOB_RECEIVED_WAIT_SDU_BUFFER)){
handelpduRwaitcalls(ChannelInternal); /* @req FRTP1136 */
}else{
frameTypelcl = getFrameType(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxDataPdu);
switch (frameTypelcl){
case START_FRAME :
ret_lcl = copySegmentToPduRRxBuffer(ChannelInternal->FrTpUlReturnValue,ChannelInternal);
if((BUFREQ_OK == ret_lcl)||(BUFREQ_E_BUSY == ret_lcl)){
handlePdurReturn(ret_lcl,ChannelInternal,FALSE); /*last parameter is FALSE since STF without ACK*/
}
break;
#if (STD_ON == FRTP_ACK_RETRY_SUPPORT)
case START_FRAME_ACK :
ret_lcl = copySegmentToPduRRxBuffer(ChannelInternal->FrTpUlReturnValue,ChannelInternal);
if((BUFREQ_OK == ret_lcl)||(BUFREQ_E_BUSY == ret_lcl)){
handlePdurReturn(ret_lcl,ChannelInternal,TRUE); /*last parameter is TRUE since STF with ACK*/
}
break;
#endif
case CONSECUTIVE_FRAME_1:
handelconsecutiveframes(ChannelInternal,frameTypelcl);
break;
#if(STD_ON == FRTP_ACK_RETRY_SUPPORT)
case CONSECUTIVE_FRAME_2:
handelconsecutiveframes(ChannelInternal,frameTypelcl);
break;
#endif
case CONSECUTIVE_FRAME_EOB:
handelconsecutiveframes(ChannelInternal,frameTypelcl);
break;
case LAST_FRAME:
handelLastFrame(ChannelInternal);
break;
case INVALID_FRAME:
break;
default:
/*Can come here only for FC frame which is handled directly in Rx_indication */
break;
}
}
} else {
if(FRTP_RX_WAIT_CF == ChannelInternal->FrTpRxChannelState){
if(ChannelInternal->FrTpChannelParams.FrTpRxChannel.FrTpRxConTxPduPendingCounter != 0){
/*Manage Ar*/
handelArTimeout(ChannelInternal);
}else{
/*Manage Cr*/
handelCrTimeout(ChannelInternal);
}
}else if(FRTP_RX_WAIT_FC_SENDING == ChannelInternal->FrTpRxChannelState){
handelBrTimeout(ChannelInternal);
}else if(FRTP_FRIF_ERROR == ChannelInternal->FrTpRxChannelState){
FrTp_Internal_HandleFrIfError(ChannelInternal,ACTIVE_RX);
}else{
/* do nothing */
}
}
}
#ifdef HOST_TEST
FrTp_Internal_RunTimeType* readInternal_FrTpChnlStatus(void);
FrTp_Internal_RunTimeType* readInternal_FrTpChnlStatus(void){
return &FrTp_Internal_RunTime ;
}
#endif
/*lint -restore */
|
2301_81045437/classic-platform
|
communication/FrTp/src/FrTp.c
|
C
|
unknown
| 138,338
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef FRTP_INTERNAL_TYPES_H_
#define FRTP_INTERNAL_TYPES_H_
#include "FrTp_Types.h"
#include "FrTp_Cfg.h"
#define FLOW_CONTROL_FRAME_PAYLOAD 8u
#define FR_PDU_LENGTH 254u /* Flexray Frame length */
#define SHIFT_1_BYTE 8u
#define SHIFT_3_BITS 3u
#define ISO10681_TPCI_MASK 0xF0u
#define ISO10681_TPCI_STF 0x40u
#define ISO10681_TPCI_STFA 0x41u
#define ISO10681_TPCI_CF1 0x50u
#define ISO10681_TPCI_CF2 0x60u
#define ISO10681_TPCI_CFEOB 0x70u
#define ISO10681_TPCI_FC 0x80u
#define ISO10681_TPCI_LF 0x90u
#define ISO10681_TPCI_FS_MASK 0x0Fu /* Flow control status mask */
#define ISO10681_FC_STATUS_CTS 0x03u
#define ISO10681_FC_STATUS_ACK_RET 0x04u
#define ISO10681_FC_STATUS_WAIT 0x05u
#define ISO10681_FC_STATUS_ABORT 0x06u
#define ISO10681_FC_STATUS_OVFL 0x07u
#define CF_LAST_INDEX 0xfu
#define STF_ACK_SET 1u
#define TARGET_ADDR_MSB 0u
#define TARGET_ADDR_LSB 1u
#define SOURCE_ADDR_MSB 2u
#define SOURCE_ADDR_LSB 3u
#define PCI_BYTE_1 4u
#define PCI_BYTE_2 5u
#define PCI_BYTE_3 6u
#define PCI_BYTE_4 7u
#define START_OF_DATA_BYTE 8u
#define FPL_BYTE PCI_BYTE_2
#define MSG_LNGTH_MSB PCI_BYTE_3
#define MSG_LNGTH_LSB PCI_BYTE_4
#define UKNOWN_MSG_LENGHT 0u
#define MAX_STF_PAYLOAD 246u /* 254 - 4 byte address info - 4 byte PCI*/
#define MSB_BYTE_MASK 0xFF00u
#define LSB_BYTE_MASK 0x00FFu
#define START_OF_DATA_BYTE_CF 6u
#define START_OF_DATA_BYTE_STF_LF 8u
#define INVALID_CONNECTION 0xFF
#define FRTP_PDUARRAY_SIZE 254
#define FRTP_ONE 1
#define FRTP_MAX_USEG_UL_FPL 246 /*max FPL from upper layer not included C_PCI and C_AI 8 Bytes */
#define FRTP_MAX_SERIALNUMBER 0x0Fu
#define FRTP_SN_RANGE_MODULO 0x10u
#define FRTP_HEADER_LENGTH_STF_LF 8u
#define FRTP_HEADER_LENGTH_CF 6u
#define FRTP_CPCI_STFA 0x41u /* Start Frame with acknowledge */
#define FRTP_CPCI_STFU 0x40u /* Start Frame - Normal */
#define FRTP_MSB_U16(x) (uint8)((x)>>8u)
#define FRTP_LSB_U16(x) (uint8)((x) & 0x00FFu)
typedef struct{
const FrTp_ConnectionConfigType *FrTpTxConRef;
const FrTp_TxPduPoolType *FrTpTxConTxPduPoolRuntimeRef;
FrTpChnlStateType FrTpTxPrevChannelState; /* holds the Previous state of TX channel */
uint16 FrTpTxConTxPduPendingCounter; /* @req FRTP1090*/
PduLengthType FrTpMessageLength;
PduLengthType FrTpCompletedMessageLength;
PduLengthType FrTpRemainingTxBufferLength;
uint16 FrTpCounterAs; /* As */
uint16 FrTpAsTimeoutRetryCounter;
uint16 FrTpCounterBs; /* Bs */
uint16 FrTpCounterCs; /* Cs */
#if FRTP_ACK_RETRY_SUPPORT == STD_ON
uint16 FrTpTxBlockPosition; /* Block position in case a retry is recived as FC status */
#endif
uint8 FrTpFrIfTxErrNextTryTimer;
uint8 FrTpTxCounterFrIf;
uint8 FrTpSerialNumber;
uint8 FrTpTxFcWt;
uint8 FrTpAssignedConnectionIndex;
uint8 FrTpTxDataPdu[FR_PDU_LENGTH];
}FrTpTxType;
typedef struct{
const FrTp_ConnectionConfigType *FrTpRxConRef;
const FrTp_TxPduPoolType *FrTpRxConTxPduPoolRuntimeRef;
FrTpChnlStateType FrTpRxPrevChannelState; /* holds the Previous state of RX channel*/
uint16 FrTpRxConTxPduPendingCounter;
PduLengthType FrTpRxMessageLength; /* This is the ML*/
PduLengthType FrTpCompletedRxMessageLength;
PduLengthType FrTpRemainingRxBufferLength;
uint16 FrTpCounterAr; /* Ar */
uint16 FrTpArTimeoutRetryCounter;
uint16 FrTpCounterBr; /* Br */
uint16 FrTpCounterCr; /* Cr */
#if FRTP_ACK_RETRY_SUPPORT == STD_ON
uint16 FrTpRxBlockPosition;
#endif
uint8 FrTpFrIfRxErrNextTryTimer;
uint8 FrTpRxCounterFrIf;
uint8 FrTPRxSquenceNumber;
uint8 FrTpRxFcWt;
uint8 FrTpAssignedRxConnectionIndex;
uint8 FrTpRxDataPdu[FR_PDU_LENGTH]; /*local Rx buffer*/
}FrTpRxType;
#if(FRTP_FULL_DUPLEX_ENABLE == STD_OFF)
typedef union
{
FrTpTxType FrTpTxChannel;
FrTpRxType FrTpRxChannel;
} FrTpChannelType;
#else
typedef struct
{
FrTpTxType FrTpTxChannel;
FrTpRxType FrTpRxChannel;
} FrTpChannelType;
#endif
typedef struct{
/* Need to Add description for all the parameters */
FrTpChannelType FrTpChannelParams;
FrTpChnlStateType FrTpTxChannelState;
FrTpChnlStateType FrTpRxChannelState; /* holds the current processing state of RX channel*/
RetryInfoType FrTpRetryInfo;
BufReq_ReturnType FrTpUlReturnValue; /* holds the upper layer return value*/
PduLengthType FrTpTransmitPduLength; /* for keep track of trigger transmit */
PduLengthType FrTpRxSizeBuffer; /* This value is provided by the upper layer*/
PduLengthType FrTpFcRecveBuffSize; /* This value is provided by the Receiver via FC When we r transmitting */
uint8 FrTpFramePayloadLength;
uint8 FrTpCounterRxRn;
uint8 FrTpChannelNumber;
uint8 FrTpBandwidthcontol;
uint8 FrTpRxFcDataPdu[FLOW_CONTROL_FRAME_PAYLOAD];
boolean FrTpTxSduUnknownMsgLength; /* @req FRTP1101 */ /* FRTP1102 */
boolean FrTpRxPduAvailable; /* RX Pdu Available flag */
boolean FrTpTxSduAvailable; /* @req FRTP415 */
boolean FrTpTcRequest;
#if FRTP_ACK_RETRY_SUPPORT == STD_ON
FrTp_AckType FrTpAckPending; /* Flag to identify ack is received */
boolean FrTpuseCF1;
boolean FrTpStfAckFlag; /* flag indicates if STF was recieved with Ack */
boolean FrTpRxFcRetryFlag; /* Set this flag when sending FC with Retry Flag Set*/
boolean FrTpStfReceivedFlag;
boolean FrTpEobReceivedFlag;
#endif
}FrTp_Internal_Channel_type;
typedef struct{
FrtpTxPduLockType FrTpTxPduLockStatus;
uint8 FrTpChannleHandle;
}FrTp_TxPduStatusInfoType;
typedef struct {
FrTp_StateType FrTpState; /* @req FRTP1029*/
FrtpCommType FrTpConnectionLockStatus[FRTP_CONFIGURED_CONNECTION_CNT];
FrTp_TxPduStatusInfoType FrTpTxPduStatusInfo[FRTP_MAX_TXPDU_COUNT]; /* this show the tx pdu locked by a channel for transmission*/
FrTp_Internal_Channel_type FrTpChannels[FRTP_CHANNEL_NUM]; /* @req FRTP088*/ /* @req FRTP228*/
}FrTp_Internal_RunTimeType;
#ifdef HOST_TEST
FrTp_Internal_RunTimeType* readInternal_ChnlStatus(void);
#endif
#endif /* FRTP_INTERNAL_TYPES_H_ */
|
2301_81045437/classic-platform
|
communication/FrTp/src/FrTp_Internal.h
|
C
|
unknown
| 8,675
|
# IpduM
obj-$(USE_IPDUM) += IpduM.o
obj-$(USE_IPDUM) += IpduM_PbCfg.o
inc-$(USE_IPDUM) += $(ROOTDIR)/communication/IpduM/inc
vpath-$(USE_IPDUM) += $(ROOTDIR)/communication/IpduM/src
|
2301_81045437/classic-platform
|
communication/IpduM/IpduM.mod.mk
|
Makefile
|
unknown
| 189
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef IPDUM_H_
#define IPDUM_H_
/* @req 4.0.3/IPDUM076 The IpduM module can use macros instead of functions where source code is used and runtime is critical.*/
/* @req 4.0.3/IPDUM105 optional interfaces*/
/* @req 4.0.3/IPDUM011 Values in selector field does not have to be the whole range of possible values*/
/* @req 4.0.3/IPDUM004 A multiplexed I-PDU can contain a static part and a dynamic part.*/
/* @req 4.0.3/IPDUM005 The position of the static and the dynamic part of the multiplexer is arbitrary*/
/* @req 4.0.3/IPDUM006 The static and the dynamic part consist of more than one element.*/
/* @req 4.0.3/IPDUM007 There shall be only one selector field within one multiplexed I-PDU*/
/* @req 4.0.3/IPDUM009 The selector field of one I-PDU shall have a configurable size between one and eight contiguous bits*/
/* @req 4.0.3/IPDUM010 The position of the selector field within the I-PDU shall be defined by configuration*/
/* @req 4.0.3/IPDUM097 The IpduM shall be implemented so that no other modules depend on it*/
/* @req 4.0.3/IPDUM098 The IpduM module shall not set the selector field*/
/* @req 4.0.3/IPDUM084 The behavior of the IpduM is unspecified until a correct call to IpduM_Init is called*/
/* @req 4.0.3/IPDUM074 The code of the IpduM module shall avoid direct use of compiler and platform specific keywords*/
/* @req 4.0.3/IPDUM075 The code of the IpduM module shall indicate all global data with read-only purposes by explicitly assigning the const keyword*/
/* @req 4.0.3/IPDUM077 The IpduM module shall not define global data in the header files.*/
/* @req 4.0.3/IPDUM073 HIS compliance */
/* @req 4.0.3/IPDUM096 Satisfied by generator */
/* @req 4.0.3/IPDUM150 Satisfied by generator */
/* !req 4.0.3/IPDUM140 Optimized COM access via macros controlled by IpduMRxDirectComInvocation */
/* !req 4.0.3/IPDUM144 AUTOSAR debugging */
/* !req 4.0.3/IPDUM145 AUTOSAR debugging */
/* !req 4.0.3/IPDUM146 AUTOSAR debugging */
/* !req 4.0.3/IPDUM147 AUTOSAR debugging */
/* !req 4.0.3/IPDUM155 Satisfied by validator */
/* @req 4.0.3/IPDUM151 */
/* @req 4.0.3/IPDUM102 */
#include "ComStack_Types.h"
#include "MemMap.h"
#include "SchM_IpduM.h"
#define IPDUM_SW_MAJOR_VERSION 1u
#define IPDUM_SW_MINOR_VERSION 0u
#define IPDUM_SW_PATCH_VERSION 0u
#define IPDUM_VENDOR_ID 60u
#define IPDUM_AR_RELEASE_MAJOR_VERSION 4u
#define IPDUM_AR_RELEASE_MINOR_VERSION 0u
#define IPDUM_AR_RELEASE_REVISION_VERSION 3u
#define IPDUM_MODULE_ID 52u
#define IPDUM_AR_MAJOR_VERSION IPDUM_AR_RELEASE_MAJOR_VERSION
#define IPDUM_AR_MINOR_VERSION IPDUM_AR_RELEASE_MINOR_VERSION
#define IPDUM_AR_PATCH_VERSION IPDUM_AR_RELEASE_REVISION_VERSION
#include "IpduM_PbCfg.h"
#include "IpduM_Cfg.h"
/* @req 4.0.3/IPDUM106 */
#define IPDUM_E_PARAM 0x10u /* @req 4.0.3/IPDUM026 */
#define IPDUM_E_PARAM_POINTER 0x11u /* @req 4.0.3/IPDUM162 */
#define IPDUM_E_UNINIT 0x20u /* @req 4.0.3/IPDUM153 */
#define IPDUM_API_INIT 0x00u
#define IPDUM_API_MAIN 0x10u
#define IPDUM_API_GET_VERSION_INFO 0x01u
#define IPDUM_API_TRANSMIT 0x03u
#define IPDUM_API_RX_INDICATION 0x42u
#define IPDUM_API_TX_CONFIRMATION 0x40u
#define IPDUM_API_TRIGGER_TRANSMIT 0x41u
typedef enum {
IPDUM_STATIC,
IPDUM_DYNAMIC
} IpduM_PartType;
typedef enum {
IPDUM_STATIC_PART_TRIGGER,
IPDUM_DYNAMIC_PART_TRIGGER,
IPDUM_STATIC_OR_DYNAMIC_PART_TRIGGER,
IPDUM_NONE
} IpduM_TriggerType;
typedef enum {
IPDUM_BIG_ENDIAN,
IPDUM_LITTLE_ENDIAN
} IpduM_SignalEndianess_type;
typedef struct {
PduLengthType startByte;
const uint8 * mask;
uint8 maskLength;
} IpduM_Segment;
typedef struct {
IpduM_PartType type;
PduIdType IpduMOutgoingPduId;
uint8 IpduMRxSelectorValue;
uint8 nSegments;
const IpduM_Segment * segments;
} IpduM_RxPart;
typedef struct IpduM_TxPart IpduM_TxPart;
typedef struct IpduM_TxPathway IpduM_TxPathway;
struct IpduM_TxPart {
IpduM_PartType type;
PduIdType pduId;
boolean IpduMJitUpdate;
boolean useConfirmation;
const IpduM_TxPathway * txPathway;
uint8 nSegments;
const IpduM_Segment * segments;
};
struct IpduM_TxPathway {
PduIdType IpduMOutgoingPduId;
uint8 IpduMIPduUnusedAreasDefault;
IpduM_TriggerType trigger;
uint32 IpduMTxConfirmationTimeout;
uint32 *timeoutCounter;
uint8 nParts;
const IpduM_TxPart * const *parts;
const IpduM_TxPart * staticPart;
const IpduM_TxPart **activeDynamicPart;
PduLengthType pduSize;
uint8 *buffer;
};
typedef struct {
PduIdType IpduMSelectorFieldLength;
PduIdType IpduMSelectorFieldPosition;
const uint8* IpduMSelectorMask;
PduIdType IpduMSelectorMasklength;
const IpduM_RxPart *staticPart;
uint8 nDynamicParts;
const IpduM_RxPart * const *dynamicParts;
uint8 pduSize;
uint8 *buffer;
IpduM_SignalEndianess_type IpduMRxIndicationEndianess;
} IpduM_RxPathway;
typedef struct { /* @req 4.0.3/IPDUM159 */
const IpduM_TxPathway *txPathways;
const IpduM_RxPathway *rxPathways;
uint8 *txBuffer;
const IpduM_TxPart *txParts;
} IpduM_ConfigType;
typedef enum {
IPDUM_UNINIT,
IPDUM_INIT
} IpduM_InitState;
extern const IpduM_ConfigType IpduMConfigData;
void IpduM_Init(const IpduM_ConfigType *config); /* @req 4.0.3/IPDUM032 */
Std_ReturnType IpduM_Transmit(PduIdType IpduMTxPduId, const PduInfoType *PduInfoPtr); /* @req 4.0.3/IPDUM043 */
Std_ReturnType IpduM_TriggerTransmit(PduIdType TxPduId, PduInfoType *PduInfoPtr); /* @req 4.0.3/IPDUM060 */
void IpduM_MainFunction(void); /* @req 4.0.3/IPDUM103 */
void IpduM_GetVersionInfo( Std_VersionInfoType* versioninfo );
#endif /*IPDUM_H_*/
|
2301_81045437/classic-platform
|
communication/IpduM/inc/IpduM.h
|
C
|
unknown
| 6,712
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef IPDUM_CBK_H_
#define IPDUM_CBK_H_
void IpduM_RxIndication(PduIdType RxPduId, PduInfoType *PduInfoPtr); /* @req 4.0.3/IPDUM040 */
void IpduM_TxConfirmation(PduIdType TxPduId); /* @req 4.0.3/IPDUM044 */
#endif /*IPDUM_CBK_H_*/
|
2301_81045437/classic-platform
|
communication/IpduM/inc/IpduM_Cbk.h
|
C
|
unknown
| 990
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "arc_assert.h"
#include <string.h>
/* @req 4.0.3/IPDUM148 */
#include "IpduM.h"
#include "IpduM_Cbk.h"
#include "PduR_IpduM.h"
#include "IpduM_Cfg.h"
#include "Det.h"
/*#include "Com.h" */
#include "Cpu.h"
#include "SchM_IpduM.h"
static IpduM_InitState ipdum_state = IPDUM_UNINIT;
static const IpduM_ConfigType *IpduM_Config;
/*lint -emacro(904,VALIDATE_PARAM_POINTER_NO_RV,VALIDATE_NO_RV,VALIDATE_INIT,VALIDATE_PARAM_POINTER,VALIDATE_TX_PART_ID,VALIDATE_TX_PATHWAY_ID)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
#if (IPDUM_DEV_ERROR_DETECT == STD_ON ) /* @req 4.0.3/IPDUM028*/ /* @req 4.0.3/IPDUM026 */
#define VALIDATE(_exp,_api,_err) \
if (!(_exp)) { \
(void)Det_ReportError(IPDUM_MODULE_ID, 0, _api, _err); \
return E_NOT_OK; \
}
#define VALIDATE_NO_RV(_exp,_api,_err ) \
if( !(_exp) ) { \
(void)Det_ReportError(IPDUM_MODULE_ID, 0, _api, _err); \
return; \
}
#define VALIDATE_NO_RETURN(_exp,_api,_err ) \
if( !(_exp) ) { \
(void)Det_ReportError(IPDUM_MODULE_ID, 0, _api, _err); \
}
#define VALIDATE_INIT(_api) VALIDATE(ipdum_state == IPDUM_INIT, _api, IPDUM_E_UNINIT) /* @req 4.0.3/IPDUM153 */
#define VALIDATE_INIT_NO_RV(_api) VALIDATE_NO_RV(ipdum_state == IPDUM_INIT, _api, IPDUM_E_UNINIT) /* @req 4.0.3/IPDUM153 */
#define VALIDATE_PARAM_POINTER(_api, _pointer) VALIDATE(_pointer != NULL, _api, IPDUM_E_PARAM_POINTER) /* @req 4.0.3/IPDUM162 */
#define VALIDATE_PARAM_POINTER_NO_RV(_api, _pointer) VALIDATE_NO_RV(_pointer != NULL, _api, IPDUM_E_PARAM_POINTER) /* @req 4.0.3/IPDUM162 */
#define VALIDATE_RX_ID(_api, _id) VALIDATE(_id < IPDUM_N_RX_PATHWAYS, _api, IPDUM_E_PARAM) /* @req 4.0.3/IPDUM026 */
#define VALIDATE_RX_ID_NO_RV(_api, _id) VALIDATE_NO_RV(_id < IPDUM_N_RX_PATHWAYS, _api, IPDUM_E_PARAM) /* @req 4.0.3/IPDUM026 */
#if IPDUM_N_TX_PATHWAYS > 0
#define VALIDATE_TX_PART_ID(_api, _id) VALIDATE(_id < IPDUM_N_TX_PARTS, _api, IPDUM_E_PARAM) /* @req 4.0.3/IPDUM026 */
#define VALIDATE_TX_PATHWAY_ID(_api, _id) VALIDATE(_id < IPDUM_N_TX_PATHWAYS, _api, IPDUM_E_PARAM) /* @req 4.0.3/IPDUM026 */
#define VALIDATE_TX_PATHWAY_ID_NO_RV(_api, _id) VALIDATE_NO_RV(_id < IPDUM_N_TX_PATHWAYS, _api, IPDUM_E_PARAM) /* @req 4.0.3/IPDUM026 */
#else
#define VALIDATE_TX_PART_ID(_api, _id)
#define VALIDATE_TX_PATHWAY_ID(_api, _id)
#define VALIDATE_TX_PATHWAY_ID_NO_RV(_api, _id)
#endif
#define DET_REPORTERROR(_x,_y,_z,_q) Det_ReportError(_x, _y, _z, _q)
#else /* @req 4.0.3/IPDUM027 */
#define VALIDATE(_exp,_api,_err )
#define VALIDATE_NO_RV(_exp,_api,_err )
#define VALIDATE_NO_RETURN(_exp,_api,_err )
#define VALIDATE_INIT(_api)
#define VALIDATE_INIT_NO_RV(_api)
#define VALIDATE_PARAM_POINTER(_api, _pointer)
#define VALIDATE_PARAM_POINTER_NO_RV(_api, _pointer)
#define VALIDATE_RX_ID(_api, _id)
#define VALIDATE_RX_ID_NO_RV(_api, _id)
#define VALIDATE_TX_PART_ID(_api, _id)
#define VALIDATE_TX_PATHWAY_ID(_api, _id)
#define VALIDATE_TX_PATHWAY_ID_NO_RV(_api, _id)
#define DET_REPORTERROR(_x,_y,_z,_q)
#endif
#define GETBITS(source, pos, mask) (( *( (uint8 *)source + (pos / 8) ) >> (pos % 8)) & mask)
#define HAS_STATIC_PART(_pathway) (_pathway->staticPart != NULL)
static void CopySegments(const IpduM_Segment *segments, uint8 nSegments, uint8 *dest, const uint8 *source) {
uint8 byteNr;
uint8 mask;
SchM_Enter_IpduM_EA_0();
for (uint16 i = 0; i < nSegments; i++) {
const IpduM_Segment *segment = &(segments[i]);
byteNr = 0;
mask = 0;
while (byteNr < segment->maskLength) {
mask = segment->mask[byteNr];
uint8 dest1 = dest[byteNr + segment->startByte];
uint8 source1 = source[byteNr + segment->startByte];
dest[byteNr + segment->startByte] = (source1 & mask) | (dest1 & ~mask);
byteNr++;
}
}
SchM_Exit_IpduM_EA_0();
}
static Std_ReturnType FetchTxPart(const IpduM_TxPart *txPart) {
Std_ReturnType ret;
PduInfoType pduInfo = {
.SduDataPtr = IpduM_Config->txBuffer,
.SduLength = txPart->txPathway->pduSize
};
SchM_Enter_IpduM_EA_0();
ret = PduR_IpduMTriggerTransmit(txPart->pduId, &pduInfo);
CopySegments(txPart->segments, txPart->nSegments, txPart->txPathway->buffer, pduInfo.SduDataPtr);
SchM_Exit_IpduM_EA_0();
return ret;
}
/* @req 4.0.3/IPDUM033 */
/* @req 4.0.3/IPDUM083 */
void IpduM_Init(const IpduM_ConfigType *config) {
/* Com_Init() and PduR_Init() has to be called before IpduM_Init(), see chapter 7.3 of IpduM SRS. */
VALIDATE_PARAM_POINTER_NO_RV(IPDUM_API_INIT, config);
IpduM_Config = config;
for (uint16 i = 0; i < IPDUM_N_TX_PATHWAYS; i++) {
const IpduM_TxPathway *txPathway = &(IpduM_Config->txPathways[i]);
/* @req 4.0.3/IPDUM067 */
memset(txPathway->buffer, txPathway->IpduMIPduUnusedAreasDefault, txPathway->pduSize);
/* @req 4.0.3/IPDUM068 */
/* Return value ignored because all PDUs are stopped at initialization, so
* the PduR_IpduMTriggerTransmit will return an error. (The data is however copied) */
/*lint -e{534} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 17.7, required] */
FetchTxPart(*(txPathway->activeDynamicPart));
if (HAS_STATIC_PART(txPathway)) {
/* @req 4.0.3/IPDUM143 */
/* Return value ignored because all PDUs are stopped at initialization, so
* the PduR_IpduMTriggerTransmit will return an error. (The data is however copied) */
/*lint -e{534} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 17.7, required] */
FetchTxPart(txPathway->staticPart);
}
}
ipdum_state = IPDUM_INIT;
}
/* @req 4.0.3/IPDUM037 */
/* @req 4.0.3/IPDUM038 */
#if IPDUM_VERSION_INFO_API == STD_ON /* @req 4.0.3/IPDUM039 */
void IpduM_GetVersionInfo( Std_VersionInfoType* versioninfo ){
VALIDATE_NO_RV((NULL != versioninfo),IPDUM_API_GET_VERSION_INFO,IPDUM_E_PARAM_POINTER);
versioninfo->moduleID = IPDUM_MODULE_ID; /* Module ID of IPDUM */
versioninfo->vendorID = IPDUM_VENDOR_ID; /* Vendor Id (ARCCORE) */
/* return the Software Version numbers*/
versioninfo->sw_major_version = IPDUM_SW_MAJOR_VERSION;
versioninfo->sw_minor_version = IPDUM_SW_MINOR_VERSION;
versioninfo->sw_patch_version = IPDUM_SW_PATCH_VERSION;
}
#endif
static boolean shouldTransmit(const IpduM_TxPart *txPart) {
const IpduM_TxPathway *txPathway = txPart->txPathway;
return ((txPathway->trigger == IPDUM_STATIC_OR_DYNAMIC_PART_TRIGGER)
|| ((txPathway->trigger == IPDUM_STATIC_PART_TRIGGER) && (txPart->type == IPDUM_STATIC))
|| ((txPathway->trigger == IPDUM_DYNAMIC_PART_TRIGGER) && (txPart->type == IPDUM_DYNAMIC)));
}
/* @req 4.0.3/IPDUM015 */
/* @req 4.0.3/IPDUM017 */
/* @req 4.0.3/IPDUM021 */
/* @req 4.0.3/IPDUM019 */
/* @req 4.0.3/IPDUM020 */
/* @req 4.0.3/IPDUM152 */
/* @req 4.0.3/IPDUM168 */
/* @req 4.0.3/IPDUM023 */
Std_ReturnType IpduM_Transmit(PduIdType IpduMTxPduId, const PduInfoType *PduInfoPtr) {
/* Is called with a COM IPdu ID */
Std_ReturnType status;
Std_ReturnType ret;
VALIDATE_INIT(IPDUM_API_TRANSMIT);
VALIDATE_PARAM_POINTER(IPDUM_API_TRANSMIT, PduInfoPtr);
VALIDATE_TX_PART_ID(IPDUM_API_TRANSMIT, IpduMTxPduId);
const IpduM_TxPart *txPart = &(IpduM_Config->txParts[IpduMTxPduId]);
const IpduM_TxPathway *txPathway = txPart->txPathway;
/* Do not transmit if we are waiting for a tx confirmation */
if ((txPathway->IpduMTxConfirmationTimeout > 0) && (*(txPathway->timeoutCounter) > 0)) {
ret = E_NOT_OK;
} else {
/* Copy the part that we received. */
CopySegments(txPart->segments, txPart->nSegments, txPart->txPathway->buffer, PduInfoPtr->SduDataPtr);
/* If this is a dynamic part, set to the current active dynamic part. */
if (txPart->type == IPDUM_DYNAMIC) {
(*(txPathway->activeDynamicPart)) = txPart;
}
/* Should we trigger a transmit? */
if (FALSE == shouldTransmit(txPart)) {
ret = E_OK;
} else {
/* If this is the static part, then update the dynamic part if it has JIT. */
if ((txPart->type == IPDUM_STATIC) && (TRUE == ((*(txPathway->activeDynamicPart))->IpduMJitUpdate))) {
status = FetchTxPart(*(txPathway->activeDynamicPart));
/* Need to do something with return value - seems appropriate to set DET error */
VALIDATE_NO_RETURN(status == E_OK, IPDUM_API_TRANSMIT, IPDUM_E_PARAM);
}
/* If this is the dynamic part, then update the static part if it has JIT. */
if ((txPart->type == IPDUM_DYNAMIC) && (HAS_STATIC_PART(txPathway)) && (TRUE == (txPathway->staticPart->IpduMJitUpdate))) {
status = FetchTxPart(txPathway->staticPart);
/* Need to do something with return value - seems appropriate to set DET error */
VALIDATE_NO_RETURN(status == E_OK, IPDUM_API_TRANSMIT, IPDUM_E_PARAM);
}
/* Start timeout for TX-confirmation observation */
if (txPathway->IpduMTxConfirmationTimeout > 0) {
*(txPathway->timeoutCounter) = txPathway->IpduMTxConfirmationTimeout;
}
/* Trigger the transmit */
PduInfoType pduInfo = {
.SduLength = PduInfoPtr->SduLength,
.SduDataPtr = txPathway->buffer
};
ret = PduR_IpduMTransmit(txPathway->IpduMOutgoingPduId, &pduInfo);
}
}
return ret;
}
/* @req 4.0.3/IPDUM041 */
/* @req 4.0.3/IPDUM042 */
/* @req 4.0.3/IPDUM086 */
/*lint -e{818} Pointer parameter 'PduInfoPtr' could be declared as pointing to const, this is updated in version 4.2.2 */
void IpduM_RxIndication(PduIdType RxPduId, PduInfoType *PduInfoPtr) {
uint8 selectBytePos;
VALIDATE_INIT_NO_RV(IPDUM_API_RX_INDICATION);
VALIDATE_PARAM_POINTER_NO_RV(IPDUM_API_RX_INDICATION, PduInfoPtr);
VALIDATE_RX_ID_NO_RV(IPDUM_API_RX_INDICATION, RxPduId);
if (PduInfoPtr->SduLength == 0) {
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return; /* Silently ignore pdus of size 0. See chapter 7.5 of IpduM specification. */
}
const IpduM_RxPathway *rxPath = &(IpduM_Config->rxPathways[RxPduId]);
PduInfoType pduInfo = {
.SduLength = PduInfoPtr->SduLength,
.SduDataPtr = rxPath->buffer
};
if (HAS_STATIC_PART(rxPath)) {
memset(rxPath->buffer, 0, rxPath->pduSize);
CopySegments(rxPath->staticPart->segments, rxPath->staticPart->nSegments, rxPath->buffer, PduInfoPtr->SduDataPtr);
PduR_IpduMRxIndication(rxPath->staticPart->IpduMOutgoingPduId, &pduInfo);
}
const uint8 * SelbytePos;
uint8 selector,bitPos;
SelbytePos = &(PduInfoPtr->SduDataPtr[(rxPath->IpduMSelectorFieldPosition/8)]);
bitPos = (rxPath->IpduMSelectorFieldPosition%8);
selector = 0;
if (rxPath->IpduMSelectorMasklength == 2) {
if (IPDUM_LITTLE_ENDIAN == rxPath->IpduMRxIndicationEndianess) {
selector = (*SelbytePos & rxPath->IpduMSelectorMask[0]) >> bitPos;
SelbytePos++;
selectBytePos = (*SelbytePos & rxPath->IpduMSelectorMask[1]);
/*lint -e{701} selectBytePos is unsigned quantity and 8-bitPos is designed such that it always gives the positive value.Hence lint exception is made */
selector |= (uint8)(selectBytePos << (8u-bitPos));
} else {
selector = (*SelbytePos & rxPath->IpduMSelectorMask[1]) >> bitPos;
SelbytePos--;
selectBytePos = (*SelbytePos & rxPath->IpduMSelectorMask[0]);
/*lint -e{701} selectBytePos1 is unsigned quantity and 8-bitPos is designed such that it always gives the positive value.Hence lint exception is made */
selector |= (uint8)(selectBytePos << (8u-bitPos));
}
} else {
selector = (*SelbytePos & rxPath->IpduMSelectorMask[0]) >> bitPos;
}
for (uint8 i = 0; i < rxPath->nDynamicParts; i++) {
const IpduM_RxPart *dynamicPart = rxPath->dynamicParts[i];
if (dynamicPart->IpduMRxSelectorValue == selector) {
memset(rxPath->buffer, 0, rxPath->pduSize);
CopySegments(dynamicPart->segments, dynamicPart->nSegments, rxPath->buffer, PduInfoPtr->SduDataPtr);
PduR_IpduMRxIndication(dynamicPart->IpduMOutgoingPduId, &pduInfo);
break;
}
}
}
/* @req 4.0.3/IPDUM088 */
/* @req 4.0.3/IPDUM087 */
/* @req 4.0.3/IPDUM022 */
/* @req 4.0.3/IPDUM024 */
void IpduM_TxConfirmation(PduIdType TxPduId) {
VALIDATE_INIT_NO_RV(IPDUM_API_TX_CONFIRMATION);
VALIDATE_TX_PATHWAY_ID_NO_RV(IPDUM_API_TX_CONFIRMATION, TxPduId);
const IpduM_TxPathway *txPathway = &(IpduM_Config->txPathways[TxPduId]);
/* Ignore unexpected tx confirmations */
if ((txPathway->IpduMTxConfirmationTimeout > 0) && (*(txPathway->timeoutCounter) == 0)) {
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return;
}
if (TRUE == (*(txPathway->activeDynamicPart))->useConfirmation) {
PduR_IpduMTxConfirmation((*(txPathway->activeDynamicPart))->pduId);
}
if ((HAS_STATIC_PART(txPathway)) && (TRUE == txPathway->staticPart->useConfirmation)) {
PduR_IpduMTxConfirmation(txPathway->staticPart->pduId);
}
/* Rest tx confirmation timeout */
if (txPathway->IpduMTxConfirmationTimeout > 0) {
SchM_Enter_IpduM_EA_0();
*(txPathway->timeoutCounter) = 0;
SchM_Exit_IpduM_EA_0();
}
}
/* @req 4.0.3/IPDUM090 */
/* @req 4.0.3/IPDUM091 */
/* @req 4.0.3/IPDUM089 */
/* @req 4.0.3/IPDUM169 */
Std_ReturnType IpduM_TriggerTransmit(PduIdType TxPduId, PduInfoType *PduInfoPtr) {
Std_ReturnType status;
VALIDATE_INIT(IPDUM_API_TRIGGER_TRANSMIT);
VALIDATE_PARAM_POINTER(IPDUM_API_TRIGGER_TRANSMIT, PduInfoPtr);
VALIDATE_TX_PATHWAY_ID(IPDUM_API_TRIGGER_TRANSMIT, TxPduId);
const IpduM_TxPathway *txPathway = &(IpduM_Config->txPathways[TxPduId]);
SchM_Enter_IpduM_EA_0();
if (TRUE == (*(txPathway->activeDynamicPart))->IpduMJitUpdate) {
status = FetchTxPart(*(txPathway->activeDynamicPart));
/* Need to do something with return value - seems appropiate to set DET error */
VALIDATE_NO_RETURN(status == E_OK, IPDUM_API_TRIGGER_TRANSMIT, IPDUM_E_PARAM);
}
if ((HAS_STATIC_PART(txPathway)) && (TRUE == (txPathway->staticPart->IpduMJitUpdate))){
status = FetchTxPart(txPathway->staticPart);
/* Need to do something with return value - seems appropiate to set DET error */
VALIDATE_NO_RETURN(status == E_OK, IPDUM_API_TRIGGER_TRANSMIT, IPDUM_E_PARAM);
}
memcpy(PduInfoPtr->SduDataPtr, txPathway->buffer, txPathway->pduSize);
SchM_Exit_IpduM_EA_0();
PduInfoPtr->SduLength = txPathway->pduSize;
return E_OK;
}
/* @req 4.0.3/IPDUM101 */
void IpduM_MainFunction(void) {
VALIDATE_INIT_NO_RV(IPDUM_API_MAIN);
for (uint16 i = 0; i < IPDUM_N_TX_PATHWAYS; i++) {
const IpduM_TxPathway *txPathway = &(IpduM_Config->txPathways[i]);
SchM_Enter_IpduM_EA_0();
if ((txPathway->IpduMTxConfirmationTimeout > 0) && (*(txPathway->timeoutCounter) > 0)) {
(*(txPathway->timeoutCounter))--;
}
SchM_Exit_IpduM_EA_0();
}
}
|
2301_81045437/classic-platform
|
communication/IpduM/src/IpduM.c
|
C
|
unknown
| 16,699
|
#J1939Tp
obj-$(USE_J1939TP) += J1939Tp.o
obj-$(USE_J1939TP) += J1939Tp_PBcfg.o
inc-$(USE_J1939TP) += $(ROOTDIR)/communication/J1939Tp/inc
vpath-$(USE_J1939TP) += $(ROOTDIR)/communication/J1939Tp/src
|
2301_81045437/classic-platform
|
communication/J1939Tp/J1939Tp.mod.mk
|
Makefile
|
unknown
| 204
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.1.2 */
/** Global requirements */
#ifndef J1939TP_H_
#define J1939TP_H_
/** @req SWS_J1939Tp_00230 *//** @req SWS_J1939Tp_00085 */
#include "Std_Types.h"
/** @req J1939TP0016 */
#include "ComStack_Types.h"
#include "J1939Tp_ConfigTypes.h"
#include "CanIf.h"
#define J1939TP_VENDOR_ID 60u
#define J1939TP_MODULE_ID 37u
#define J1939TP_AR_MAJOR_VERSION 4u
#define J1939TP_AR_MINOR_VERSION 1u
#define J1939TP_AR_PATCH_VERSION 2u
#define J1939TP_SW_MAJOR_VERSION 1u
#define J1939TP_SW_MINOR_VERSION 0u
#define J1939TP_SW_PATCH_VERSION 0u
#include "J1939Tp_Cfg.h"
#if (J1939TP_VERSION_INFO_API == STD_ON)
/** Returns the version info of J1939Tp */
/** @req SWS_J1939Tp_00089 */
#define J1939Tp_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,J1939TP)
#endif
/** Initializes the module */
void J1939Tp_Init(const J1939Tp_ConfigType* ConfigPtr);
/** Close down communication, usually called by EcuM */
void J1939Tp_Shutdown(void);
/** Used to request the transfer of a J1939Tp N-SDU*/
Std_ReturnType J1939Tp_Transmit(PduIdType TxSduId, const PduInfoType* TxInfoPtr);
/** Used to cancel the ongoing transmission of a J1939Tp N-SDU */
Std_ReturnType J1939Tp_CancelTransmit(PduIdType TxSduId);
/** Used to cancel the ongoing reception of a J1939Tp N-SDU */
Std_ReturnType J1939Tp_CancelReceive(PduIdType RxSduId);
/** Used to change reception or transmission parameters of J1939Tp for a specific N-SDU */
Std_ReturnType J1939Tp_ChangeParameter(PduIdType SduId, TPParameterType Parameter, uint16 Value);
/** Main function, used for scheduling purpose and timeout supervision */
void J1939Tp_MainFunction(void);
#endif
|
2301_81045437/classic-platform
|
communication/J1939Tp/inc/J1939Tp.h
|
C
|
unknown
| 2,488
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef J1939TP_CBK_H_
#define J1939TP_CBK_H_
/** @req J1939TP0102 **/
/** Indication of a received I-PDU from a lower layer communication module */
void J1939Tp_RxIndication(PduIdType RxPduId, PduInfoType* PduInfoPtr);
/** The lower layer communication module confirms the transmission of an I-PDU */
void J1939Tp_TxConfirmation(PduIdType TxPduId);
#endif
|
2301_81045437/classic-platform
|
communication/J1939Tp/inc/J1939Tp_Cbk.h
|
C
|
unknown
| 1,125
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.1.2 */
#ifndef J1939TP_CONFIGTYPES_H_
#define J1939TP_CONFIGTYPES_H_
#include "ComStack_Types.h"
/**
* @brief Protocol variant used when transferring data larger than 8 bytes.
* @note This information is stored inside a channel structure of type
* J1939Tp_ChannelType.
*/
typedef enum {
J1939TP_PROTOCOL_BAM, /**< Broadcast Announce Message */
J1939TP_PROTOCOL_CMDT /**< Connection Mode Data Transfer (peer-to-peer) */
} J1939Tp_ProtocolType;
/** @brief Transfer direction of a channel.
* @note A channel can have only one direction: transmitting or receiving.
* This direction is stored in J1939Tp_ChannelType
*/
typedef enum {
J1939TP_RX, /**< Receiving */
J1939TP_TX /**< Transmitting */
} J1939Tp_DirectionType;
/** @brief State of a transmission channel.
* @note Used in J1939Tp_Internal_TxChannelInfoType.
*/
typedef enum {
/** @brief Idle state. */
J1939TP_TX_IDLE,
/** @brief Waiting for CanIf to confirm the transmission
* of a BAM Connection Management PDU. */
J1939TP_TX_WAIT_BAM_CANIF_CONFIRM,
/** @brief Waiting for CanIf to confirm a sent RTS message. */
J1939TP_TX_WAIT_RTS_CANIF_CONFIRM,
/** @brief Waiting for Clear To Send command from receiver. */
J1939TP_TX_WAITING_FOR_CTS,
/** @brief Wait for CanIf to confirm sending a TP.DT packet
* which we send using CMDT. */
J1939TP_TX_WAIT_DT_CANIF_CONFIRM,
/** @brief Wait for CanIf to confirm sending a TP.DT packet
* which we send by means of BAM. */
J1939TP_TX_WAIT_DT_BAM_CANIF_CONFIRM,
/** @brief Waiting for the BAM interval to expire before we
* send another data packet.
* @note When using BAM, data packets are sent in intervals
* of time with no other conection management */
J1939TP_TX_WAITING_FOR_BAM_DT_SEND_TIMEOUT,
/* Waiting for End of Message Aknowledge*/
J1939TP_TX_WAITING_FOR_END_OF_MSG_ACK
} J1939Tp_Internal_TxChannelStateType;
/** @brief State of a reception channel. */
typedef enum {
/** @brief Idle state. */
J1939TP_RX_IDLE,
/** @brief Waiting for CanIf to confirm the transmission of a CTS message. */
J1939TP_RX_WAIT_CTS_CANIF_CONFIRM,
/** @brief Receiving data. */
J1939TP_RX_RECEIVING_DT,
/** @brief Waiting for CanIf to confirm the transmission of a
* 'End Of Message Aknowledge' message. */
J1939TP_RX_WAIT_ENDOFMSGACK_CANIF_CONFIRM,
} J1939Tp_Internal_RxChannelStateType;
/** @brief Timer structure. */
typedef struct {
/** @brief Timer counter */
uint32 Timer;
/** @brief Expire value.
*
* The timer expires when Timer reaches a value => TimerExpire. */
uint32 TimerExpire;
} J1939Tp_Internal_TimerType;
/** @brief Represents a Parameter Group Number. */
typedef uint32 J1939Tp_Internal_PgnType;
/** @brief Represents the size in bytes of a data payload. */
typedef uint32 J1939Tp_Internal_DtPayloadSizeType;
/** @see J1939Tp_ChannelType_ */
typedef struct J1939Tp_ChannelType_ J1939Tp_ChannelType;
/** @see J1939Tp_PgType_*/
typedef struct J1939Tp_PgType_ J1939Tp_PgType;
/** @brief Parameter Group Number */
typedef uint32 J1939Tp_PgnType;
/**
* @brief Represents a received (Rx) or transmitted (Tx) Parameter Group which
* was associated to a channel.
*
* The content of such a structure is setup with BSW Builder when allocating
* PGs to the single channels during configuration of the J1939 module.
*/
struct J1939Tp_PgType_
{
/** @brief True when this PG has dynamic length.
* @details Dynamic length means that the Sdu data can have any length in
* range [0, 8]. This also means, that the Sdu has to be
* tranmitted or received as direct frame (with no connection
* management). */
const boolean DynLength;
/** @brief Parameter Group Number (PGN) of this Parameter Group.
* @note The PGNs are listed in the J1939 specification. */
const J1939Tp_Internal_PgnType Pgn;
/** @brief ID of the PDU frame used for a PG with payload size
* equal or less than 8 bytes.
* @note This ID is used for calls to CanIf when transmitting PGs
* with data size equal less 8 bytes (direct frames).
* @note Set only when DynLength is set to true. */
const PduIdType DirectNPdu;
/** @brief ID of the Service Data Unit (SDU) used for this parameter group.
* @note This ID is used for calls to PduR functions. */
const PduIdType NSdu;
/** @brief Channel used to transfer this PG.
* @note The channel also has a pointer to this PG structure. */
const J1939Tp_ChannelType* Channel;
/** @brief Value of the parameter Metadatalength setup for the NSdu
* associated with this parameter group */
const uint8 NSdu_MetaDataLength;
};
/**
* @brief Description of a communication channel.
*
* A single channel is used to transfer PDUs containing the same sender and
* receiver addresses.
*
* @note The contents of a channel structure are setup when configuring a Tx or
* Rx channel of the J1939Tp module with BSW Builder.
* @note The PDUs are setup when configuring the EcuC module.
*/
struct J1939Tp_ChannelType_ {
/** @brief Protocol used by this channel (BAM or CMDT).
* @details This is the protocol setup by the user and does not change at
* runtime.
*/
const J1939Tp_ProtocolType Protocol;
/** @brief ID of the TP.DT frame used by BAM and CMDT to transfer
* the contents of an N-SDU. */
const PduIdType DtNPdu;
/** @brief ID of the Connection Management (TP.CM) PDU used
* with BAM and CMDT. */
const PduIdType CmNPdu;
/** @brief ID of the Flow Control PDU used for Abort, CTS, EndOfMsgAck
* messages (reverse connection management).
* @note: Only set when Protocol is J1939TP_PROTOCOL_CMDT.
*/
const PduIdType FcNPdu;
/** @brief Receive or transmit direction of this channel. */
const J1939Tp_DirectionType Direction;
/** @brief Length of the array Pgs.
*
* How many PGs are transferred through this channel. */
const uint16 PgCount;
/** @brief Array of pointers to Parameter Group structures.
*
* This is the list of PGs transferred through this channel, be it received
* or transmitted. */
const J1939Tp_PgType** Pgs;
/*--------[Setup MetaDataLength]------------------------------------------*/
/** @brief Value of the parameter MetaDataLength setup for the
* Connection Management Pdu */
const uint8 CmNPdu_MetaDataLength;
/** @brief Value of the parameter MetaDataLength setup for the
* Data NPdu */
const uint8 DtNPdu_MetaDataLength;
/** @brief Value of the parameter MetaDataLength setup for the
* Flow Control NPdu */
const uint8 FcNPdu_MetaDataLength;
};
/**
* @brief Types of PDUs.
*
* @note This type is checked in J1939Tp_RxIndication and
* J1939Tp_TxConfirmation.
*/
typedef enum {
/** @brief Reverse Connection Management.
*
* Connection Management Messages in reverse direction are sent by the
* receiving note to the sending node. Indicates an Abort, CTS or
* EndOfMsgAck message (Flow Control messages).
*/
J1939TP_REVERSE_CM,
/** @brief Connection Management frame (TP.CM).
*
* TP.CM is used by the BAM and CMDT protocols to initialize a connection
* (BAM and RTS messages) or when the sender aborts transmission. */
J1939TP_CM,
/** @brief Data Transfer frame (TP.DT). */
J1939TP_DT,
/** @brief Direct transfer of PDUs with data (payload) less equal 8 bytes.
*
* For this kind of messages, there is no segmentation and no
* connection management. They are forwarded to CanIf without further
* logic. */
J1939TP_DIRECT
} J1939Tp_RxPduType;
/** @brief Description of a transferred PDU from the point of view of the
* J1939 protocol.
*/
typedef struct {
/** @brief Type of PDU.
* @see J1939Tp_RxPduType */
const J1939Tp_RxPduType PacketType;
/** @brief Channel number (index). */
const uint8 ChannelIndex;
/** @brief Pointer to received Parameter Group structure. */
const J1939Tp_PgType* PgPtr;
} J1939Tp_RxPduInfoType;
/**
* @brief Contains an array of J1939Tp_RxPduInfoType structures
* (PDU descriptions) and the corresponding array size.
*
* Every used PDU ID is associated with a structure of this type, that is with
* a list of PDU descriptions.
*/
typedef struct {
/** @brief Array of pointers to PDU descriptions. */
const J1939Tp_RxPduInfoType** RxPdus;
/** @brief Length of array RxPdus */
const PduIdType RxPduCount;
} J1939Tp_RxPduInfoRelationsType;
/** @req J1939TP0175 */
/**
* @brief Stores the configuration of module J1939Tp.
*
* The array 'RxPduRelations' is meant to be indexed by PDU ID: to each PDU ID
* being used in the module J1939 there is a list of PDU description structures,
* where every structure contains information about a channel index, parameter
* group transmitted and message type (connection management, data etc).
* This is necessary because a certain PDU might be used on more than one
* channel and with more than one role (for instance direct transmission and
* segmented data transmission), depending on the user configuration.
*
* Here is an example of how to iterate over all channel objects associated with
* a certain PDU ID:
* @code
* PduIdType pduid = ...;
* J1939Tp_ConfigType* config = ...;
*
* J1939Tp_RxPduInfoRelationsType *pduList = config->RxPduRelations[pduid];
* J1939Tp_RxPduInfoType *pduInfo = 0;
* J1939Tp_ChannelType *channel = 0;
* uint8 channelIndex = 0;
* PduIdType i;
* for (i = 0; i < pduList->RxPduCount; i++)
* {
* pduInfo = pduList->RxPdus[i];
* channelIndex = pduInfo->ChannelIndex;
* channel = config -> Channels[channelIndex];
* }
* @endcode
*/
typedef struct {
const J1939Tp_RxPduInfoRelationsType* RxPduRelations;
const J1939Tp_ChannelType* Channels;
const J1939Tp_PgType* Pgs;
} J1939Tp_ConfigType;
#endif
|
2301_81045437/classic-platform
|
communication/J1939Tp/inc/J1939Tp_ConfigTypes.h
|
C
|
unknown
| 11,761
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.1.2 */
#include "J1939Tp.h"
/** @req SWS_J1939Tp_00172 */
#include "CanIf.h"
#include "J1939Tp_Cbk.h"
#include "J1939Tp_Internal.h"
#include "PduR.h"
/** @req SWS_J1939Tp_00015 */
#include "PduR_J1939Tp.h"
/** @req J1939TP0193 */
/** @req SWS_J1939Tp_00193 */
#if (defined(USE_DET))
#include "Det.h"
#endif
#include "SchM_J1939Tp.h"
#if (J1939TP_DEV_ERROR_DETECT == STD_ON)
/* @req SWS_J1939Tp_00060 */
#define J1939TP_DET_REPORT_ERROR(_ApiId, _ErrorId) (void)Det_ReportError(J1939TP_MODULE_ID, 0, (_ApiId), (_ErrorId))
#else
#define J1939TP_DET_REPORT_ERROR(_ApiId, _ErrorId)
#endif
/* Globally fulfilled requirements */
/** @req SWS_J1939Tp_00123 */
/** @req SWS_J1939Tp_00165 */
/** @req SWS_J1939Tp_00097 */
/** @req SWS_J1939Tp_00019 *//*The J1939Tp module shall have two global states, J1939TP_ON and J1939TP_OFF*/
/** @req SWS_J1939Tp_00007 */
/** @req SWS_J1939Tp_00018 */
/** @req SWS_J1939Tp_00155 */
/** @req SWS_J1939Tp_00125 */
/** @req SWS_J1939Tp_00041 */
/** @req SWS_J1939Tp_00192 */
/** @req SWS_J1939Tp_00121 */
/** @req SWS_J1939Tp_00226 */
/** @req SWS_J1939Tp_00035 */
/** @req SWS_J1939Tp_00071 */
/** @req SWS_J1939Tp_00076 */
/** @req SWS_J1939Tp_00116 */
/** @req SWS_J1939Tp_00157 */
/** @req SWS_J1939Tp_00198 */
/** @req SWS_J1939Tp_00023 */
/** @req SWS_J1939Tp_00062 */
/** @req SWS_J1939Tp_00020 */
/** @brief State of this module.
* @details The state is set to J1939TP_ON when the J1939Tp_Init function is
* called and to J1939TP_OFF when the function J1939Tp_Shutdown is
* called. */
static J1939Tp_Internal_GlobalStateInfoType globalState = {
.State = J1939TP_OFF,
};
/*==================[internal data]===============================================================*/
/* Module Configuration. The content of the pointed struct is being generated. */
static const J1939Tp_ConfigType* J1939Tp_ConfigPtr = NULL_PTR;
/* Runtime channel information */
static J1939Tp_Internal_ChannelInfoType channelInfos [J1939TP_CHANNEL_COUNT];
/* Transmission states of the transmission channels. */
static J1939Tp_Internal_TxChannelInfoType txChannelInfos [J1939TP_TX_CHANNEL_COUNT];
/* Reception states of the reception channels. */
static J1939Tp_Internal_RxChannelInfoType rxChannelInfos [J1939TP_RX_CHANNEL_COUNT];
/* Array of PG descriptions indexed by SDU ID. */
static J1939Tp_Internal_PgInfoType pgInfos [J1939TP_PG_COUNT];
/** Block size declared in CTS and RTS messages.
*
* To support to function J1939Tp_ChangeParameter, which is supposed to change the parameter
* J1939TpPacketsPerBlock, we define this internal variable and
* initialize it with the value of J1939TP_PACKETS_PER_BLOCK.
* @see J1939Tp_ChangeParameter */
#if defined (J1939TP_PACKETS_PER_BLOCK)
static uint16 Internal_J1939TpPacketsPerBlock = J1939TP_PACKETS_PER_BLOCK;
#else
/* The configuration parameter J1939TpPacketsPerBlock has the default value 16 */
static uint16 Internal_J1939TpPacketsPerBlock = 16;
#endif
/*==================[functions]===================================================================*/
/*------------------[Initialize the J1939Tp module]-----------------------------------------------*/
/** @req SWS_J1939Tp_00087 */
void J1939Tp_Init(const J1939Tp_ConfigType* ConfigPtr) {
/** @req SWS_J1939Tp_00021 */
/** @req SWS_J1939Tp_00024 */
/** !req SWS_J1939Tp_00187 */
boolean status = TRUE;
#if (J1939TP_DEV_ERROR_DETECT == STD_ON)
if (globalState.State == J1939TP_ON) {
/** !req SWS_J1939Tp_00026 */
J1939TP_DET_REPORT_ERROR(J1939TP_INIT_ID, J1939TP_E_REINIT);
}
#endif
J1939Tp_ConfigPtr = ConfigPtr;
int rxCount = 0;
int txCount = 0;
for (int i = 0; i < J1939TP_CHANNEL_COUNT; i++)
{
if (ConfigPtr->Channels[i].Direction == J1939TP_TX)
{
/* channelInfos[i] points to a channel configuration */
channelInfos[i].ChannelConfPtr = &(ConfigPtr->Channels[i]);
channelInfos[i].TxState = &(txChannelInfos[txCount]);
channelInfos[i].TxState->State = J1939TP_TX_IDLE;
channelInfos[i].RxState = 0;
txCount++;
}
else if (ConfigPtr->Channels[i].Direction == J1939TP_RX)
{
channelInfos[i].ChannelConfPtr = &(ConfigPtr->Channels[i]);
channelInfos[i].TxState = 0;
channelInfos[i].RxState = &(rxChannelInfos[rxCount]);
channelInfos[i].RxState->State = J1939TP_RX_IDLE;
rxCount++;
}
else
{
status = FALSE;
break; // unexpected
}
/* Reset metadata information */
J1939Tp_Internal_Reset_Channel_Metadata(&(channelInfos[i]));
}
if (status == TRUE) {
for (int i = 0; i < J1939TP_PG_COUNT; i++) {
pgInfos[i].PgConfPtr = &(ConfigPtr->Pgs[i]);
uint8 channelIndex = ConfigPtr->Pgs[i].Channel - ConfigPtr->Channels;
pgInfos[i].ChannelInfoPtr = &(channelInfos[channelIndex]);
pgInfos[i].TxState = J1939TP_PG_TX_IDLE;
}
/* Reinitialize packets per block in case someone decides for some
* reason to reinitialize the module. */
#if defined (J1939TP_PACKETS_PER_BLOCK)
Internal_J1939TpPacketsPerBlock = J1939TP_PACKETS_PER_BLOCK;
#else
/* The configuration parameter J1939TpPacketsPerBlock has the
* default value 16 */
Internal_J1939TpPacketsPerBlock = 16;
#endif
globalState.State = J1939TP_ON; /** @req SWS_J1939Tp_00022 */
}
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Shutdown the J1939Tp module]-------------------------------------------------*/
/** @req SWS_J1939Tp_00093 */
/**
* @brief Shutdown the J1939Tp module.
*
* The shutdown function puts all communication channels into idle state and stops all timers.
* It does not reset any internal pointers.
*
*
* @see Items SWS_J1939Tp_00093, SWS_J1939Tp_00094 and SWS_J1939Tp_00094
* of the Autosar specification of the J1939Tp module, R4.1 Rev 1.
*/
void J1939Tp_Shutdown(void)
{
/** @req SWS_J1939Tp_00094 */
/* Put every channel into idle state and stop it's timer. */
for (int i = 0; i < J1939TP_CHANNEL_COUNT; i++)
{
J1939Tp_Internal_Reset_Channel(&(channelInfos[i]));
}
/* Put the PGs in idle state and stop their timers */
for (int i = 0; i < J1939TP_PG_COUNT; i++)
{
pgInfos[i].TxState = J1939TP_PG_TX_IDLE;
J1939Tp_Internal_StopTimer(&(pgInfos[i].TimerInfo));
}
/* Shutdown */
globalState.State = J1939TP_OFF;
/** @req SWS_J1939Tp_00095 */
}
/*------------------------------------------------------------------------------------------------*/
/**
* Callback function used by the underlying layer (CanIf) to inform J1939Tp
* when a Pdu has been received.
*
* @param RxPduId ID of the received I-PDU.
* This may be the PduId of a CM, FC, DT or direct
* frame. Note: this number should not be an Sdu Id.
* @param PduInfoPtr Contains the length (SduLength) of the received
* I-PDU and a pointer to a buffer (SduDataPtr)
* containing the I-PDU.
* @returns none
* @note The argument RxPduId should be a PduId in the J1939Tp namespace.
*/
/* @req SWS_J1939Tp_00108 */
void J1939Tp_RxIndication(PduIdType RxPduId, PduInfoType* PduInfoPtr)
{
/* @req SWS_J1939Tp_00109 */
/* @req SWS_J1939Tp_00110 */
Std_ReturnType metadata_match = E_NOT_OK;
if (globalState.State == J1939TP_ON)
{
const J1939Tp_RxPduInfoRelationsType* RxPduRelationsInfo = NULL_PTR;
/* Get the usages of this PDU */
Std_ReturnType status = J1939Tp_Internal_GetRxPduRelationsInfo(RxPduId, &RxPduRelationsInfo);
if (status == E_OK)
{
/* For all usages (relations to some channel) of this PduId check
* the usage type and handle accordingly. */
for (PduIdType i = 0; i < RxPduRelationsInfo->RxPduCount; i++)
{
SchM_Enter_J1939Tp_EA_0();
const J1939Tp_RxPduInfoType* RxPduInfo = RxPduRelationsInfo->RxPdus[i];
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr = J1939Tp_Internal_GetChannelState(RxPduInfo);
/* Use eventual metadata to filter incoming PDUs. For BAM and
* RTS messages the channel's addressing information is setup,
* otherwise, if there is any metadata, it is matched against
* the current channel addressing information. Non matching PDUs
* are ignored. */
/* @req SWS_J1939Tp_00064 */
/* @req SWS_J1939Tp_00057 */
metadata_match = J1939Tp_Internal_Filter_RxPdu_Metadata(RxPduId, PduInfoPtr, RxPduInfo->PacketType, ChannelInfoPtr);
if (metadata_match == E_OK)
{
switch (RxPduInfo->PacketType)
{
/* CTS, Connection Abort, End of Msg Ack */
case J1939TP_REVERSE_CM:
J1939Tp_Internal_RxIndication_ReverseCm(PduInfoPtr, ChannelInfoPtr);
break;
/* data transmission*/
case J1939TP_DT:
J1939Tp_Internal_RxIndication_Dt(PduInfoPtr, ChannelInfoPtr);
break;
/* BAM, RTS, Connection Abort */
case J1939TP_CM:
J1939Tp_Internal_RxIndication_Cm(PduInfoPtr, ChannelInfoPtr);
break;
/* direct transmission of data less equal 8 bytes */
case J1939TP_DIRECT:
J1939Tp_Internal_RxIndication_Direct(PduInfoPtr,RxPduInfo);
break;
default:
break;
}
}
SchM_Exit_J1939Tp_EA_0();
}
}
}
}
/* This function is being called periodically J1939TP_MAIN_FUNCTION_PERIOD
* times in a second. */
/* @req SWS_J1939Tp_00104 */
void J1939Tp_MainFunction(void) {
/** @req SWS_J1939Tp_00030 */
if (globalState.State == J1939TP_ON) {
/* Handle timeout of segmented transmission */
/* Check every communication channel if its timer has expired.
* The PGs transferred through these channels are either BAM or CMDT frames. */
for (uint16 i = 0; i < J1939TP_CHANNEL_COUNT; i++) {
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr = &(channelInfos[i]);
const J1939Tp_ChannelType* Channel = ChannelInfoPtr->ChannelConfPtr;
J1939Tp_Internal_TimerStatusType timer = J1939TP_NOT_EXPIRED;
if (Channel->Direction == J1939TP_TX) {
/* Transmission channel */
SchM_Enter_J1939Tp_EA_0();
timer = J1939Tp_Internal_IncAndCheckTimer(&(ChannelInfoPtr->TxState->TimerInfo));
if (timer == J1939TP_EXPIRED) {
/* transmission timer has timed out, reset it */
J1939Tp_Internal_StopTimer(&(ChannelInfoPtr->TxState->TimerInfo));
/* transmission state machine */
switch (ChannelInfoPtr->TxState->State) {
case J1939TP_TX_WAIT_BAM_CANIF_CONFIRM:
case J1939TP_TX_WAIT_RTS_CANIF_CONFIRM:
/* CanIf failed to send the initial connection management frame. */
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
PduR_J1939TpTxConfirmation(ChannelInfoPtr->TxState->CurrentPgPtr->NSdu, NTFRSLT_E_NOT_OK);
break;
case J1939TP_TX_WAITING_FOR_CTS:
case J1939TP_TX_WAIT_DT_CANIF_CONFIRM:
case J1939TP_TX_WAITING_FOR_END_OF_MSG_ACK:
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
/** @req SWS_J1939Tp_00100 */
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_CM, Channel->CmNPdu, CONNABORT_REASON_TIMEOUT);
PduR_J1939TpTxConfirmation(ChannelInfoPtr->TxState->CurrentPgPtr->NSdu,NTFRSLT_E_NOT_OK);
break;
case J1939TP_TX_WAITING_FOR_BAM_DT_SEND_TIMEOUT:
/* It's time to send the next BAM data packet */
ChannelInfoPtr->TxState->State = J1939TP_TX_WAIT_DT_BAM_CANIF_CONFIRM;
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo), J1939TP_TX_CONF_TIMEOUT);
if (J1939Tp_Internal_SendDt(ChannelInfoPtr) == E_NOT_OK) {
/* CanIf failed to send next data packet */
J1939Tp_Internal_Reset_Channel(ChannelInfoPtr);
/** @req SWS_J1939Tp_00048 */
/** @req SWS_J1939Tp_00032 */
PduR_J1939TpTxConfirmation(ChannelInfoPtr->TxState->CurrentPgPtr->NSdu, NTFRSLT_E_NOT_OK);
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_CM,
ChannelInfoPtr->TxState->CurrentPgPtr->Pgn,
CONNABORT_REASON_TIMEOUT);
}
break;
default:
break;
}
}
SchM_Exit_J1939Tp_EA_0();
}
else if (Channel->Direction == J1939TP_RX) {
/* Reception channel */
SchM_Enter_J1939Tp_EA_0();
/* Switch on reception status */
switch (ChannelInfoPtr->RxState->State) {
case J1939TP_RX_WAIT_CTS_CANIF_CONFIRM:
case J1939TP_RX_RECEIVING_DT:
case J1939TP_RX_WAIT_ENDOFMSGACK_CANIF_CONFIRM:
timer = J1939Tp_Internal_IncAndCheckTimer
(&(ChannelInfoPtr->RxState->TimerInfo));
break;
default:
break;
}
if (timer == J1939TP_EXPIRED) {
/* Reception timer has expired: stop timer and set channel in idle state */
J1939Tp_Internal_Reset_Channel(ChannelInfoPtr);
if (ChannelInfoPtr->Protocol == J1939TP_PROTOCOL_CMDT) {
/** @req SWS_J1939Tp_00159 */
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_REVERSE_CM,
ChannelInfoPtr->RxState->CurrentPgPtr->Pgn,
CONNABORT_REASON_TIMEOUT);
}
/** @req SWS_J1939Tp_00031 */
PduR_J1939TpRxIndication(ChannelInfoPtr->RxState->CurrentPgPtr->NSdu,NTFRSLT_E_NOT_OK);
}
SchM_Exit_J1939Tp_EA_0();
}
}
/* Handle timeout of direct transmission */
/* Check timer expiration for all parameter groups (PG) being transferred directly. */
for (uint16 i = 0; i < J1939TP_PG_COUNT; i++) {
SchM_Enter_J1939Tp_EA_0();
if (pgInfos[i].TxState != J1939TP_PG_TX_IDLE) {
if (J1939Tp_Internal_IncAndCheckTimer(&(pgInfos[i].TimerInfo)) == J1939TP_EXPIRED) {
/* Timer expired, abort direct transmission. */
pgInfos[i].TxState = J1939TP_PG_TX_IDLE;
PduR_J1939TpTxConfirmation(pgInfos[i].PgConfPtr->NSdu, NTFRSLT_E_NOT_OK);
}
}
SchM_Exit_J1939Tp_EA_0();
}
}
}
/**
* @brief CanIf calls this function to confirm the successful transmission
* of a N-PDU, be it a CM, DT or direct frame.
*
* @param RxPdu ID of the sent N-PDU.
* @returns nothing
*/
/* @req SWS_J1939Tp_00112 */
void J1939Tp_TxConfirmation(PduIdType RxPdu)
{
/** @req SWS_J1939Tp_00030 */
/* @req SWS_J1939Tp_00113 */
/* @req SWS_J1939Tp_00114 */
if (globalState.State == J1939TP_ON)
{
const J1939Tp_RxPduInfoRelationsType* RxPduRelationsInfo = 0;
if (J1939Tp_Internal_GetRxPduRelationsInfo(RxPdu, &RxPduRelationsInfo) == E_OK)
{
/* RxPdu is a valid PDU ID */
SchM_Enter_J1939Tp_EA_0();
/* Handle all PGs associated with this PDU ID
* (a SDU/PDU ID can be used in more than one role) */
for (PduIdType i = 0; i < RxPduRelationsInfo->RxPduCount; i++)
{
const J1939Tp_RxPduInfoType* RxPduInfo = RxPduRelationsInfo->RxPdus[i];
const J1939Tp_ChannelType* Channel = J1939Tp_Internal_GetChannel(RxPduInfo);
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr = J1939Tp_Internal_GetChannelState(RxPduInfo);
switch (Channel->Direction)
{
case J1939TP_TX:
J1939Tp_Internal_TxConfirmation_TxChannel(ChannelInfoPtr, RxPduInfo);
break;
case J1939TP_RX:
J1939Tp_Internal_TxConfirmation_RxChannel(ChannelInfoPtr, RxPduInfo);
break;
default:
break;
}
}
SchM_Exit_J1939Tp_EA_0();
}
}
}
static inline const J1939Tp_ChannelType* J1939Tp_Internal_GetChannel
(const J1939Tp_RxPduInfoType* RxPduInfo)
{
return &(J1939Tp_ConfigPtr->Channels[RxPduInfo->ChannelIndex]);
}
static inline J1939Tp_Internal_ChannelInfoType* J1939Tp_Internal_GetChannelState
(const J1939Tp_RxPduInfoType* RxPduInfo)
{
return &(channelInfos[RxPduInfo->ChannelIndex]);
}
static inline Std_ReturnType J1939Tp_Internal_ValidatePacketType(const J1939Tp_RxPduInfoType* RxPduInfo) {
Std_ReturnType status;
status = E_OK;
const J1939Tp_ChannelType* ChannelPtr = J1939Tp_Internal_GetChannel(RxPduInfo);
switch (RxPduInfo->PacketType) {
case J1939TP_REVERSE_CM:
if (ChannelPtr->Direction != J1939TP_TX ) {
status = E_NOT_OK;
}
break;
case J1939TP_DT:
if (ChannelPtr->Direction != J1939TP_RX) {
status = E_NOT_OK;
}
break;
case J1939TP_CM:
if (ChannelPtr->Direction != J1939TP_RX) {
status = E_NOT_OK;
}
break;
default:
status = E_NOT_OK;
}
return status;
}
/*------------------[Handle reception of Direct Frames]-------------------------------------------*/
/**
* @brief Handle reception of direct frames.
*
* Direct frames are used for messages (PGs) with data less or equal 8 bytes,
* where no segmentation is necessary.
*
* @param PduInfoPtr Pointer to the received PDU structure
* @param RxPduInfoPtr Pointer to the associated PG meta information holding the packet type,
* channel index and the actual PG description.
*/
static inline void J1939Tp_Internal_RxIndication_Direct
(
PduInfoType* PduInfoPtr, const J1939Tp_RxPduInfoType* RxPduInfoPtr
)
{
PduLengthType messageSize = PduInfoPtr->SduLength;
const J1939Tp_PgType* Pg = 0;
PduLengthType remainingBuffer = 0;
BufReq_ReturnType PduR_startOK = BUFREQ_NOT_OK;
BufReq_ReturnType r = BUFREQ_NOT_OK;
if (messageSize <= DIRECT_TRANSMIT_SIZE)
{
Pg = RxPduInfoPtr->PgPtr;
PduR_startOK = PduR_J1939TpStartOfReception(Pg->NSdu, PduInfoPtr, messageSize, &remainingBuffer);
/** @req SWS_J1939Tp_00040 */
if ((PduR_startOK == BUFREQ_OK) && (remainingBuffer >= messageSize))
{
r = PduR_J1939TpCopyRxData(Pg->NSdu, PduInfoPtr, &remainingBuffer);
if (r == BUFREQ_OK)
{
PduR_J1939TpRxIndication(Pg->NSdu, NTFRSLT_OK);
}
else
{
PduR_J1939TpRxIndication(Pg->NSdu, NTFRSLT_E_NOT_OK);
/* SWS_J1939Tp_00040 says we should abort connection if
* "the PduR_J1939TpCopyRxData function returns BUFREQ_E_NOT_OK"
* but here we cannot send the connection abort message because
* direct frames are not connection managed. */
}
}
}
/* No need to abort connection for reception of direct frames */
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Get number of DT packets for next CTS]---------------------------------------*/
/**
* @brief Get the number of TP.DT packets to declare in the next CTS message.
*
* This function computes how many packets to declare in the next Clear To Send
* (CTS) message based on how many packets were received and the total amount of
* packets to receive.
*
* This function is used before sending a CTS message.
*
* @param receivedDtPackets how many packets received currently
* @param totalDtPacketsToReceive total amount of packets to receive
*
* @returns how many packets to declare in the next CTS message
*/
static inline uint8 J1939Tp_Internal_GetDtPacketsInNextCts
(
uint8 receivedDtPackets, uint8 totalDtPacketsToReceive
)
{
uint8 status;
/* Packets left until we get all of them */
uint8 packetsLeft = totalDtPacketsToReceive - receivedDtPackets;
/* J1939TP_PACKETS_PER_BLOCK is how many packets maximal we declare in a
* CTS message. A block is a sequence of packets we receive between two CTS
* messages.
* We don't use the symbolic value J1939TP_PACKETS_PER_BLOCK but the variable
* Internal_J1939TpPacketsPerBlock, because the function J1939Tp_ChangeParameter
* might change this parameter. */
if (packetsLeft < (Internal_J1939TpPacketsPerBlock)) {
status = packetsLeft;
} else {
status = Internal_J1939TpPacketsPerBlock;
}
return status;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Handle reception of Data frames]---------------------------------------------*/
/**
* Handle reception of data packet.
*
* @param PduInfoPtr received packet
* @param ChannelInfoPtr reception channel
*/
static inline void J1939Tp_Internal_RxIndication_Dt
(PduInfoType* PduInfoPtr, J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr)
{
if ((ChannelInfoPtr == NULL_PTR) || (ChannelInfoPtr->RxState == NULL_PTR) ||
(ChannelInfoPtr->RxState->CurrentPgPtr == NULL_PTR) || (ChannelInfoPtr->RxState->State != J1939TP_RX_RECEIVING_DT)) {
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return;
}
/* Get the SDU ID of the received data packet */
PduIdType PduRSdu = ChannelInfoPtr->RxState->CurrentPgPtr->NSdu;
/* Get the protocol used to transfer the packet
* (there is a protocol because direct frames are handled in another function) */
const J1939Tp_ProtocolType protocol = ChannelInfoPtr->Protocol;
/* Increment number of received packets through this channel */
ChannelInfoPtr->RxState->ReceivedDtCount++;
/* Which packet number we expect */
uint8 expectedSeqNumber = ChannelInfoPtr->RxState->ReceivedDtCount;
/* Which packet number is has been effectively received.
* The packet number is stored in the first data byte */
uint8 seqNumber = PduInfoPtr->SduDataPtr[DT_BYTE_SEQ_NUM];
if (seqNumber != expectedSeqNumber) {
/* The received packet number does not match the expected packet number.
* See item SWS_J1939Tp_00216 of the Autosar J1939 specification v4.1 */
ChannelInfoPtr->RxState->State = J1939TP_RX_IDLE;
if (protocol == J1939TP_PROTOCOL_CMDT) {
J1939Tp_PgnType pgn = ChannelInfoPtr->RxState->CurrentPgPtr->Pgn;
/** @req SWS_J1939Tp_00216 */
/** @req SWS_J1939Tp_00192 */
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_REVERSE_CM, pgn, CONNABORT_REASON_SEQUENCE_ERR);
}
PduR_J1939TpRxIndication(ChannelInfoPtr->RxState->CurrentPgPtr->NSdu, NTFRSLT_E_NOT_OK);
} else {
PduLengthType remainingBytesInRxBuffer = 0;
PduInfoType PduInfoRxCopy;
PduInfoRxCopy.SduLength = J1939Tp_Internal_GetDtDataSize(seqNumber,ChannelInfoPtr->RxState->TotalMessageSize);
PduInfoRxCopy.SduDataPtr = &(PduInfoPtr->SduDataPtr[DT_BYTE_DATA_1]);
/** @req SWS_J1939Tp_00162 */
if (BUFREQ_OK != PduR_J1939TpCopyRxData(ChannelInfoPtr->RxState->CurrentPgPtr->NSdu, &PduInfoRxCopy, &remainingBytesInRxBuffer)) {
/* PduR could not copy the received data into the buffers of the upper layer.
* Abort connection if CMDT is in usage. */
/* Note: J1939Tp does not use internal PDU buffers, but calls PduR_J1939TpCopyTxData and
* PduR_J1939TpCopyRxData to transfer data to upper layers.
* See Autosar specification v4.1 of the J1939Tp module,
* chapter 7.5.5 N-SDU Buffer Management. */
if (protocol == J1939TP_PROTOCOL_CMDT) {
J1939Tp_PgnType pgn = ChannelInfoPtr->RxState->CurrentPgPtr->Pgn;
/** @req SWS_J1939Tp_00040 */
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_REVERSE_CM, pgn, CONNABORT_REASON_NO_RESOURCES);
}
/* set reception state of the channel to idle */
ChannelInfoPtr->RxState->State = J1939TP_RX_IDLE;
} else {
/* If this is the last data packet before we should send another CTS message,
* then send the new CTS message */
if (protocol == J1939TP_PROTOCOL_CMDT && J1939Tp_Internal_IsLastDtBeforeNextCts(ChannelInfoPtr->RxState) ) {
J1939Tp_PgnType pgn = ChannelInfoPtr->RxState->CurrentPgPtr->Pgn;
/* How many DT packets should we request in the CTS message */
uint8 requestPackets =
J1939Tp_Internal_GetDtPacketsInNextCts(ChannelInfoPtr->RxState->ReceivedDtCount, ChannelInfoPtr->RxState->DtToReceiveCount);
if (Internal_J1939TpPacketsPerBlock < requestPackets) {
requestPackets = Internal_J1939TpPacketsPerBlock;
}
/* Change reception channel state to 'wait for CanIf to transmit the CTS' */
ChannelInfoPtr->RxState->State = J1939TP_RX_WAIT_CTS_CANIF_CONFIRM;
/* Transmit the CTS message */
J1939Tp_Internal_SendCts(ChannelInfoPtr, pgn, ChannelInfoPtr->RxState->ReceivedDtCount+1, requestPackets);
}
/* If this the last DT packet (no new CTS needed) */
else if (J1939Tp_Internal_IsLastDt(ChannelInfoPtr->RxState)) {
/* Send the Acknowledge message if were using CMTD, not needed for BAM */
if (ChannelInfoPtr->Protocol == J1939TP_PROTOCOL_CMDT) {
J1939Tp_Internal_SendEndOfMsgAck(ChannelInfoPtr);
}
/* Change state to idle */
ChannelInfoPtr->RxState->State = J1939TP_RX_IDLE;
/* Tell PduR we're ready */
/* @req SWS_J1939Tp_00118 */
PduR_J1939TpRxIndication(PduRSdu, NTFRSLT_OK);
} else {
/* Wait until we send the next packet */
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->RxState->TimerInfo), J1939TP_T1_TIMEOUT_MS);
}
}
}
}
/*------------------------------------------------------------------------------------------------*/
static inline uint8 J1939Tp_Internal_GetDtDataSize(uint8 currentSeqNum, uint8 totalSize) {
uint8 status;
if (currentSeqNum*DT_DATA_SIZE <= totalSize) {
status = DT_DATA_SIZE;
} else {
status = DT_DATA_SIZE - ((currentSeqNum*DT_DATA_SIZE) - totalSize);
}
return status;
}
/*------------------[Handle reception of RTS, BAM and ConnAbort]----------------------------------*/
/**
* @brief Handle reception of Connection Management frames.
*
* This function handles the reception of TP.CM frames,
* i.e. of RTS, BAM and ConnAbort messages.
*
*
* @param PduInfoPtr Pointer to received Pdu Info structure.
* @param ChannelInfoPtr Reception channel
*/
static inline void J1939Tp_Internal_RxIndication_Cm
(
PduInfoType *PduInfoPtr,
J1939Tp_Internal_ChannelInfoType *ChannelInfoPtr
)
{
/* Do nothing if the reception channel is not in idle state */
if ( (ChannelInfoPtr->RxState == NULL_PTR) || (ChannelInfoPtr->RxState->State != J1939TP_RX_IDLE) ) {
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return;
}
/* Get the PGN from the PDU data buffer */
J1939Tp_PgnType pgn = J1939Tp_Internal_GetPgn(&(PduInfoPtr->SduDataPtr[CM_PGN_BYTE_1]));
const J1939Tp_PgType* pg = NULL_PTR;
/* Get the PG structure correspoding to the received PGN */
if (E_OK == J1939Tp_Internal_GetPgFromPgn(ChannelInfoPtr->ChannelConfPtr, pgn ,&pg)) {
/* The command byte is the first one in the received data.
* It makes the difference between the different messages. */
uint8 Command = PduInfoPtr->SduDataPtr[CM_BYTE_CONTROL];
/* The message size contained in BAM or RTS */
J1939Tp_Internal_DtPayloadSizeType messageSize = J1939Tp_Internal_GetRtsMessageSize(PduInfoPtr);
/** @req J1939TP0043**/
/** @req SWS_J1939Tp_00043 */
if ( (Command == RTS_CONTROL_VALUE) || (Command == BAM_CONTROL_VALUE) ) {
/* We have received a BAM or RTS message */
/* Setup the reception metadata of the channel */
ChannelInfoPtr->RxState->ReceivedDtCount = 0;
ChannelInfoPtr->RxState->DtToReceiveCount = PduInfoPtr->SduDataPtr[BAM_BYTE_NUM_PACKETS];
ChannelInfoPtr->RxState->TotalMessageSize = messageSize;
ChannelInfoPtr->RxState->CurrentPgPtr = pg;
/* Protocol used on the channel */
J1939Tp_ProtocolType channelProtocol = ChannelInfoPtr->Protocol;
if (Command == RTS_CONTROL_VALUE) {
/* RTS - Request To Send */
/** @req SWS_J1939Tp_00173 */
/* According to SWS_J1939Tp_00173:
* abort the reception silently if the protocol chosen based on
* Command does not match the transport protocol configured for the
* transported PGN */
/** !req SWS_J1939Tp_00225 *//* Cancel if already active? */
if (channelProtocol == J1939TP_PROTOCOL_CMDT) {
/* CMDT && RTS */
PduLengthType remainingBuffer = 0;
/** @req SWS_J1939Tp_00038 */
BufReq_ReturnType PduR_startOK = PduR_J1939TpStartOfReception(pg->NSdu, PduInfoPtr, messageSize, &remainingBuffer);
/** @req SWS_J1939Tp_00040 */
/* Abort reception if
* "The value returned by PduR_J1939TpStartOfReception via bufferSizePtr
* is smaller than the total data length of the N-SDU"*/
if ((PduR_startOK != BUFREQ_OK) || (remainingBuffer < messageSize)) {
/* PduR failed start of reception or the available buffer
* in the upper layer is not large enough so abort transfer */
/** @req SWS_J1939Tp_00173*/
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_CM, pgn, CONNABORT_REASON_BUSY);
}
else {
/* Buffer ok and PduR did not fail,
* so send the CTS message in response to the RTS message*/
/* how many packets to declare in the CTS message i.e. how many packets
* can we receive in the next block.
* We intitialize this value to the number of packets the sender wants to send. */
uint8 receive_packets = PduInfoPtr->SduDataPtr[RTS_BYTE_NUM_PACKETS];
/* Add support for dynamic block size calculation */
#if (J1939TP_DYNAMIC_BLOCK_CALCULATION == STD_ON)
/* dynamic block size calculation is enabled */
#if defined(J1939TP_PACKETS_PER_BLOCK)
/** @req SWS_J1939Tp_00210 */
receive_packets = J1939TP_Internal_GetNumDtPacketsToSend(remainingBuffer);
if (Internal_J1939TpPacketsPerBlock < receive_packets) {
receive_packets = Internal_J1939TpPacketsPerBlock;
}
#else
/** @req SWS_J1939Tp_00211 */
receive_packets = J1939TP_Internal_GetNumDtPacketsToSend(remainingBuffer);
#endif
#else
/* dynamic block size calculation is disabled */
#if defined(J1939TP_PACKETS_PER_BLOCK)
/** @req SWS_J1939Tp_00213 */
if (Internal_J1939TpPacketsPerBlock < receive_packets) {
receive_packets = Internal_J1939TpPacketsPerBlock;
}
#endif
#endif
/* Set the reception state to
* 'waiting for CanIf to confirm sending of CTS message' */
ChannelInfoPtr->RxState->State = J1939TP_RX_WAIT_CTS_CANIF_CONFIRM;
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->RxState->TimerInfo), J1939TP_TX_CONF_TIMEOUT);
/* Send the Clear To Send message i.e.
* instruct the sending node to start sending */
J1939Tp_Internal_SendCts(ChannelInfoPtr, pgn, CTS_START_SEQ_NUM, receive_packets);
}
}
else {
/* Protocols do not match */
/* RTS not setup with CMDT */
/* see SWS_J1939Tp_00173 */
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_CM, pgn, CONNABORT_REASON_BUSY);
}
}
else if (Command == BAM_CONTROL_VALUE && channelProtocol == J1939TP_PROTOCOL_BAM) {
/* BAM */
PduLengthType remainingBuffer = 0;
/** @req SWS_J1939Tp_00038 */
if (BUFREQ_OK == PduR_J1939TpStartOfReception(pg->NSdu, PduInfoPtr, messageSize, &remainingBuffer)) {
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->RxState->TimerInfo),J1939TP_T2_TIMEOUT_MS);
/* Set the reception channel to state 'Receiving data'
* because after the BAM announce message the sending node starts sending. */
ChannelInfoPtr->RxState->State = J1939TP_RX_RECEIVING_DT;
}
}
} /* No BAM or RTS message */
else if (Command == CONNABORT_CONTROL_VALUE) {
/* Connection Abort message, set the channel into idle state */
/* !req SWS_J1939Tp_00163 */
ChannelInfoPtr->RxState->State = J1939TP_RX_IDLE;
}
}
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Handle CTS, EndOfMsgAck and ConnAbort]---------------------------------------*/
/**
* @brief Handle control flow messages CTS, EndOfMsgAck and ConnAbort.
*
* @details J1939Tp_RxIndication branches to this function when the receiver of CMDT data transfer
* sends control flow messages. Within the message, the receiver sends a command byte,
* which is one of the following (defined in J1939Tp_Internal_Packets.h):
* - CTS_CONTROL_VALUE : Clear To Send, the acknowledging party is
* ready to receive more data.
* - ENDOFMSGACK_CONTROL_VALUE : Aknowledge (confirm) the End of Message
* - CONNABORT_CONTROL_VALUE : Connection Abort
* Other command values are ignored.
*/
static inline void J1939Tp_Internal_RxIndication_ReverseCm
(PduInfoType* PduInfoPtr, J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr)
{
const J1939Tp_PgType* pg = NULL_PTR;
J1939Tp_PgnType pgn = J1939Tp_Internal_GetPgn(&(PduInfoPtr->SduDataPtr[CM_PGN_BYTE_1]));
if (J1939Tp_Internal_GetPgFromPgn(ChannelInfoPtr->ChannelConfPtr,pgn,&pg) != E_OK) {
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return;
}
/* the command byte is the first byte of the data */
uint8 Command = PduInfoPtr->SduDataPtr[CM_BYTE_CONTROL];
switch (Command) {
case CTS_CONTROL_VALUE:
/* Clear To Send: other party is ready to receive more data */
/* !req SWS_J1939Tp_00224 *//* Cancel if not in J1939TP_TX_WAITING_FOR_CTS? */
if (ChannelInfoPtr->TxState->State == J1939TP_TX_WAITING_FOR_CTS)
{
/* how many packets can the other party receive */
uint8 NumPacketsToSend = PduInfoPtr->SduDataPtr[CTS_BYTE_NUM_PACKETS];
/* next packet number the receiver expects */
uint8 NextPacket = PduInfoPtr->SduDataPtr[CTS_BYTE_NEXT_PACKET];
/* Handle wait frame */
if (NumPacketsToSend == 0)
{
// Receiver wants to keep the connection open but cant receive packets
/** @req J1939TP0195 */
/** @req SWS_J1939Tp_00195 */
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),
J1939TP_T4_TIMEOUT_MS);
}
else if(J1939Tp_Internal_IsDtPacketAlreadySent(NextPacket,ChannelInfoPtr->TxState->SentDtCount))
{
/** @req SWS_J1939Tp_00194 */
/** @req SWS_J1939Tp_00032 */
/* receiver expects a packet we already sent */
PduR_J1939TpTxConfirmation(pg->NSdu,NTFRSLT_E_NOT_OK);
/** @req SWS_J1939Tp_00097 */
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_CM, pgn, CONNABORT_REASON_MAX_RETRY_LIMIT);
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
}
else
{
/** !req SWS_J1939Tp_00223 */
ChannelInfoPtr->TxState->DtToSendBeforeCtsCount = NumPacketsToSend;
ChannelInfoPtr->TxState->State = J1939TP_TX_WAIT_DT_CANIF_CONFIRM;
if (J1939Tp_Internal_SendDt(ChannelInfoPtr) == E_NOT_OK)
{
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
/** @req SWS_J1939Tp_00048 */
/** @req SWS_J1939Tp_00032 */
PduR_J1939TpTxConfirmation(ChannelInfoPtr->TxState->CurrentPgPtr->NSdu, NTFRSLT_E_NOT_OK);
J1939Tp_Internal_SendConnectionAbort(ChannelInfoPtr, J1939TP_CM,
ChannelInfoPtr->TxState->CurrentPgPtr->Pgn,
CONNABORT_REASON_NO_RESOURCES);
} else {
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_TX_CONF_TIMEOUT);
}
}
}
break;
case ENDOFMSGACK_CONTROL_VALUE:
if (ChannelInfoPtr->TxState->State == J1939TP_TX_WAITING_FOR_END_OF_MSG_ACK)
{
/** @req SWS_J1939Tp_00119 */
PduR_J1939TpTxConfirmation(pg->NSdu,NTFRSLT_OK);
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
}
break;
case CONNABORT_CONTROL_VALUE:
if (ChannelInfoPtr->TxState->State != J1939TP_TX_IDLE) {
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
/* @req SWS_J1939Tp_00098 */
PduR_J1939TpTxConfirmation(pg->NSdu,NTFRSLT_E_NOT_OK);
}
break;
default:
break;
}
}
/*------------------[Change Parameter]------------------------------------------------------------*/
/** @req SWS_J1939Tp_00180 */
/**
* @brief Change reception or transmission parameters for a specific N-SDU.
*
*
* @param SduId SDU ID for which parameters should be changed.
* Currently this parameter is only checked to be valid but not used.
* @param Parameter Parameter-ID.
* Currently only the parameter TP_BS is supported (defined in ComStack_Types.h).
* @param Value New value for changed parameter.
*
*
* @retval E_OK The request has been accepted.
* @retval E_NOT_OK The request failed.
*
* @see Specification of a Transport Layer for SAE J1939, V1.3.0, R4.1 Rev 1
* Items SWS_J1939Tp_00180, SWS_J1939Tp_00206 and ECUC_J1939Tp_00061.
*/
Std_ReturnType J1939Tp_ChangeParameter
(
PduIdType SduId,
TPParameterType Parameter,
uint16 Value
)
{
Std_ReturnType status = E_NOT_OK;
J1939Tp_Internal_PgInfoType* PgInfo = NULL_PTR;
/** @req SWS_J1939Tp_00206 */
if (globalState.State == J1939TP_ON)
{
/* This sets status to E_OK if SduId is a valid ID,
* otherwise to E_NOT_OK */
status = J1939Tp_Internal_GetPg(SduId, &PgInfo);
if (status == E_OK)
{
if (Parameter != TP_BS)
{
/* v4.1 of Autosar supports only changing the block size,
* see SWS_J1939Tp_00206 */
status = E_NOT_OK;
}
else if (Value > (uint16) 255u)
{
/* The new value has to be no larger than 255 because this value takes in
* CTS and RTS messages a single byte. */
status = E_NOT_OK;
}
else if (status == E_OK)
{
/* Item SWS_J1939Tp_00180 sais we should change the parameter
* for a specific N-SDU but at the same time the item SWS_J1939Tp_00205
* specifies we should change the value of J1939TpPacketsPerBlock,
* which is a global value and not specific to a N-SDU.
* So at this point we effectively ignore SduId and change a global variable. */
Internal_J1939TpPacketsPerBlock = Value;
}
}
}
return status;
}
/*------------------------------------------------------------------------------------------------*/
/**
* @brief Handle transmission confirmation on a reception channel.
*
* CTS messages are sent using a reception channel for flow control.
*
* @param ChannelInfoPtr reception channel
* @param RxPduInfo PDU description, containing the packet type,
* channel index and a pointer to a PG description.
*/
static inline void J1939Tp_Internal_TxConfirmation_RxChannel
(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr, const J1939Tp_RxPduInfoType* RxPduInfo)
{
switch (RxPduInfo->PacketType) {
case J1939TP_REVERSE_CM:
if (ChannelInfoPtr->RxState->State == J1939TP_RX_WAIT_CTS_CANIF_CONFIRM) {
/* the transmitted PDU is used for reverse direction
* flow control and we are waiting for CanIf to confirm that
* it sent a CTS message */
/* Start the channel timer with value T2.
* If the timer expires, then we didn't get any data frames
* althought we sent the CTS message. */
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->RxState->TimerInfo),J1939TP_T2_TIMEOUT_MS);
/* Put the reception channel into receiving state */
ChannelInfoPtr->RxState->State = J1939TP_RX_RECEIVING_DT;
}
break;
default:
break;
}
}
static inline boolean J1939Tp_Internal_IsDtPacketAlreadySent(uint8 nextPacket, uint8 totalPacketsSent) {
return nextPacket < totalPacketsSent;
}
/*------------------[Get PDU relations info]------------------------------------------------------*/
/**
* Get a pointer to the J1939Tp_RxPduInfoRelationsType structure
* with index RxPdu.
*
* @param PduId ID of a received or transmitted I-PDU.
* @param RxPduInfo Address where to store the found PDU relations
* structure.
* @retval E_OK PduId is a valid PDU ID
* @retval E_NOT_OK PduId is not a valid PDU ID
*
* @note The returned J1939Tp_RxPduInfoRelationsType holds a list of
* J1939Tp_RxPduInfoType describing the relation of the PDU with ID
* PduId with a channel, PG and packet type.
*/
static inline Std_ReturnType J1939Tp_Internal_GetRxPduRelationsInfo
(PduIdType PduId, const J1939Tp_RxPduInfoRelationsType** RxPduInfo)
{
Std_ReturnType r = E_NOT_OK;
if (PduId < J1939TP_RX_PDU_COUNT) {
/* J1939Tp_ConfigPtr is the one passed to the init function */
*RxPduInfo = &(J1939Tp_ConfigPtr->RxPduRelations[PduId]);
r = E_OK;
}
return r;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Get PG with PGN on channel]--------------------------------------------------*/
/**
* @brief Get the PG associated with the PGN on a certain channel.
*
* This function searches for a Parameter Group (PG) structure with the
* specified Parameter Group Number (PGN) in the list of PGs of the specified
* channel. If it finds such a PG, it stores its address at address *Pg and
* returns E_OK. If it finds no such PG structure, it returns E_NOT_OK without
* writing to *Pg.
*
* @param channel Channel storing the PG list.
* @param Pgn PGN to search for.
* @param Pg Address where to store a pointer to PG if the PGN was
* found.
*
* @retval E_OK The PG with the specified PGN has been found and its
* address is stored in *Pg.
* @retval E_NOT_OK The requested PGN has not been found.
*/
static inline Std_ReturnType J1939Tp_Internal_GetPgFromPgn
(
const J1939Tp_ChannelType *channel,
J1939Tp_Internal_PgnType Pgn,
const J1939Tp_PgType **Pg
)
{
Std_ReturnType found = E_NOT_OK;
/* Current PG struct while searching, here we read the PGN from */
const J1939Tp_PgType *current_PG = 0;
/* Current PGN while searching, is read fro current_PG */
J1939Tp_Internal_PgnType current_PGN = 0;
/* Index in the PG list of channel, loop control */
uint16 pg_index = 0;
/* List size i.e. how many PGs are there on the channel */
uint16 pg_count = channel->PgCount;
/* Search the list */
while (pg_index < pg_count && found != E_OK)
{
current_PG = channel->Pgs[pg_index];
current_PGN = current_PG->Pgn;
if (current_PGN == Pgn)
{
/* Found! */
*Pg = current_PG;
found = E_OK;
}
pg_index++;
}
return found;
#if 0
/* Old code for reference.
* Deleted because not MISRA conform: only one return */
for (int i = 0; i < channel->PgCount; i++) {
if (channel->Pgs[i]->Pgn == Pgn) {
*Pg = channel->Pgs[i];
return E_OK;
}
}
return E_NOT_OK;
#endif
}
/*------------------------------------------------------------------------------------------------*/
/*
* Returns true, if the last received Data Transfer message is the last one
* before we send a new CTS message.
* This implies that when this functions returns true, a new CTS message should
* be sent to the data sender.
* See AUTOSAR_SWS_SAEJ1939TransportLayer.pdf, "7.5.4.2 Data Flow using CMDT"
* for more information about the Clear To Send (CTS) frame.
*/
static inline boolean J1939Tp_Internal_IsLastDtBeforeNextCts
(J1939Tp_Internal_RxChannelInfoType* rxChannelInfo)
{
/* if Data Transfer (DT) Messages received until now
* equals expected Data Transfer messages, that is if we got all expected DTs */
boolean finalDt = rxChannelInfo->ReceivedDtCount == rxChannelInfo->DtToReceiveCount;
/* if number of DTs fills one packet block */
boolean sendNewCts = rxChannelInfo->ReceivedDtCount % Internal_J1939TpPacketsPerBlock == 0;
return ( (!finalDt) && sendNewCts );
}
/*------------------[Is it the last received DT?]-------------------------------------------------*/
/**
* Returns true, if the last received Data Transfer message (DT) is the last one
* we expect.
*
* After this last frame we don't expect any new data messages.
*/
static inline boolean J1939Tp_Internal_IsLastDt
(
J1939Tp_Internal_RxChannelInfoType* rxChannelInfo
)
{
return (rxChannelInfo->DtToReceiveCount == rxChannelInfo->ReceivedDtCount);
}
/*------------------------------------------------------------------------------------------------*/
static inline void J1939Tp_Internal_TxConfirmation_TxChannel
(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr, const J1939Tp_RxPduInfoType* RxPduInfo)
{
J1939Tp_Internal_TxChannelStateType State = ChannelInfoPtr->TxState->State;
J1939Tp_Internal_PgInfoType* PgInfo = J1939Tp_GetPgInfo(RxPduInfo->PgPtr);
switch (RxPduInfo->PacketType)
{
case J1939TP_REVERSE_CM:
break;
case J1939TP_CM:
if (State == J1939TP_TX_WAIT_RTS_CANIF_CONFIRM)
{/* The RTS message has been sent. Begin to wait for the CTS message */
ChannelInfoPtr->TxState->State = J1939TP_TX_WAITING_FOR_CTS;
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_T3_TIMEOUT_MS);
}
else if (State == J1939TP_TX_WAIT_BAM_CANIF_CONFIRM)
{
ChannelInfoPtr->TxState->State = J1939TP_TX_WAITING_FOR_BAM_DT_SEND_TIMEOUT;
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_DT_BROADCAST_MIN_INTERVAL);
}
break;
case J1939TP_DT:
if (State == J1939TP_TX_WAIT_DT_CANIF_CONFIRM)
{
/* Data packet was sent with CMDT */
ChannelInfoPtr->TxState->SentDtCount++;
if (J1939Tp_Internal_LastDtSent(ChannelInfoPtr->TxState))
{
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_T3_TIMEOUT_MS);
ChannelInfoPtr->TxState->State = J1939TP_TX_WAITING_FOR_END_OF_MSG_ACK;
}
else if (J1939Tp_Internal_WaitForCts(ChannelInfoPtr->TxState))
{
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_T3_TIMEOUT_MS);
ChannelInfoPtr->TxState->State = J1939TP_TX_WAITING_FOR_CTS;
}
else
{
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_TX_CONF_TIMEOUT);
//lint -save -e534
J1939Tp_Internal_SendDt(ChannelInfoPtr);
//lint -restore
}
}
else if (State == J1939TP_TX_WAIT_DT_BAM_CANIF_CONFIRM)
{
/* We get the confirmation of a TP.DT frame transmitted
* during BAM transmission */
ChannelInfoPtr->TxState->SentDtCount++;
if (J1939Tp_Internal_LastDtSent(ChannelInfoPtr->TxState)) {
/* The confirmed message was the last one we had to send.
* Put the channel into idle state. */
ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
/* Tell PduR the transmission was ok */
/** @req SWS_J1939Tp_00119 */
PduR_J1939TpTxConfirmation(ChannelInfoPtr->TxState->CurrentPgPtr->NSdu, NTFRSLT_OK);
} else {
/* There is more BAM data, so wait for the next cycle
* to send the next packet. Note: as BAM is not connection
* managed, data must be send in intervals of time.
* This is where we wait for this interval to expire. */
ChannelInfoPtr->TxState->State = J1939TP_TX_WAITING_FOR_BAM_DT_SEND_TIMEOUT;
/* Start the channel timer with the minimal BAM interval.
* When this timer expires, we send the next data frame. */
J1939Tp_Internal_StartTimer(&(ChannelInfoPtr->TxState->TimerInfo),J1939TP_DT_BROADCAST_MIN_INTERVAL);
}
}
break;
case J1939TP_DIRECT:
if (PgInfo->TxState == J1939TP_PG_TX_WAIT_DIRECT_SEND_CANIF_CONFIRM)
{
PgInfo->TxState = J1939TP_PG_TX_IDLE;
/** @req SWS_J1939Tp_00119 */
PduR_J1939TpTxConfirmation(RxPduInfo->PgPtr->NSdu, NTFRSLT_OK);
}
/* PgInfo->TxState is already in idle state */
break;
default:
break;
}
}
/*------------------[Get Parameter Group]---------------------------------------------------------*/
/**
* @brief Get the Parameter Group structure associated with the specified SDU ID.
*
* The returned pointer points to a structure containing information about the channel used to
* transfer the PG, the PG itself, transmission state and a timer.
*
* @param SduId SDU ID
* @param PgInfo PG structure where to store the associated PG.
*
* @retval E_OK SduId is a valid SDU ID
* @retval E_NOT_OK SduId is not a valid SDU ID
*/
static inline Std_ReturnType J1939Tp_Internal_GetPg
(PduIdType SduId, J1939Tp_Internal_PgInfoType** PgInfo)
{
Std_ReturnType ret = E_NOT_OK;
if (SduId < J1939TP_PG_COUNT) {
*PgInfo = &(pgInfos[SduId]);
ret = E_OK;
}
return ret;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Cancel Transmission]---------------------------------------------------------*/
/** @req SWS_J1939Tp_00214 */
#if (J1939TP_CANCELLATION_SUPPORT == STD_ON)
/** @req SWS_J1939Tp_00177 */
/**
* @brief Cancel the transmission of the SDU with ID TxSduId.
*
* This function will fail and return E_NOT_OK under the following conditions:
* - the J1939Tp module was not initialized (function J1939Tp_Init)
* - TxSduId is not a valid SDU ID
* - The PG associated with this SDU is not being used on a transmission channel
* which means, TxSduId points to reception SDU.
* - The transmission state of the used channel is not set (internal or configuration error).
* - TxSduId points to a direct frame. Direct frames are simple, not segmented 8 bytes frames.
* - The last message was has already been sent through BAM.
*
* @param TxSduId The SDU ID of the J1939Tp N-SDU to be canceled.
* @retval E_OK Cancelation ok.
* @retval E_NOT_OK Cancelation failed.
*
* @note The requirements to this function are specified in item SWS_J1939Tp_00203 of the
* Autosar R4.1 Rev 1.
*/
Std_ReturnType J1939Tp_CancelTransmit(PduIdType TxSduId)
{
/* Control variable used to monitor the correct functioning.
* We also return the value of it. */
Std_ReturnType status = E_OK;
/* Meta information about the PG. Also contains information about the used channel. */
J1939Tp_Internal_PgInfoType* PgInfo = 0;
if (globalState.State == J1939TP_OFF) {
status = E_NOT_OK;
/* Module was not initialised */
}
/** @req SWS_J1939Tp_00203 */
/* Check if TxSduId is a valid SDU ID.
* If TxSduId is invalid, the following call returns E_NOT_OK. */
if (status == E_OK) {
status = J1939Tp_Internal_GetPg(TxSduId, &PgInfo);
}
/* Check if "currently a direct frame is transmitted".
* We check if the specified SDU ID is used to transmit a direct frame.
* Direct frames cannot be canceled because they are not segmented.
* Once the Can controller has been instructed to transmit the direct frame,
* we cannot take the message back from the network. */
if ((status == E_OK )&& (PgInfo != NULL)) {
if ((PgInfo->PgConfPtr->DynLength == TRUE) || (PgInfo->PgConfPtr->DirectNPdu != ((PduIdType) -1)) ) {
status = E_NOT_OK;
}
}
/* Check that the used channel is indeed a transmission channel
* (and not a reception one) */
if ((status == E_OK )&& (PgInfo != NULL)) {
if (PgInfo->ChannelInfoPtr->ChannelConfPtr->Direction != J1939TP_TX) {
status = E_NOT_OK;
}
if (! PgInfo->ChannelInfoPtr->TxState) {
/* For some reason the transmission state pointer is null
* and we don't want to dereference the null pointer later */
status = E_NOT_OK;
}
}
/* Check "if TxSduId is currently not active".
* I interpret this as "if the channel used to transmit the associated PG
* is idle", meaning the message was already transmitted so we cannot cancel
* it anylonger. */
if ((status == E_OK )&& (PgInfo != NULL)) {
if (PgInfo->ChannelInfoPtr->TxState->State == J1939TP_TX_IDLE) {
/* Nothing going on on the channel, so nothing to cancel. */
status = E_NOT_OK;
}
}
/* Check if "the last TP.DT frame has already been transmitted during BAM
* transmission". Here we have a point where the specification is not very
* clear. If the last BAM data frame has been successfully transmitted, then
* the channel is idle and the SduId is not active - which we already
* checked. I interpret the specification as: if the last BAM data frame
* was already commited to CanIf, which didn't yet confirmed sending. So the
* last data frame was commited but we cannot say for sure, that the message
* was entirely sent, because the channel is not yet idle and CanIf didn't
* confirm the last packet yet.
*/
if ((status == E_OK )&& (PgInfo != NULL)) {
boolean isBAM = (PgInfo->ChannelInfoPtr->ChannelConfPtr->Protocol == J1939TP_PROTOCOL_BAM);
J1939Tp_Internal_DtPayloadSizeType totalMessageSize = PgInfo->ChannelInfoPtr->TxState->TotalMessageSize;
J1939Tp_Internal_DtPayloadSizeType sentDtCount = PgInfo->ChannelInfoPtr->TxState->SentDtCount;
/* If the next confirmed packet with number sentDtCount + 1 would be
* the last data packet, then we must be waiting for the confirmation
* of the last data packet. */
boolean waitingForLastDtConfirm = (sentDtCount + 1) * DT_DATA_SIZE >= totalMessageSize;
if (isBAM && waitingForLastDtConfirm) {
status = E_NOT_OK;
/* Cannot cancel transmission after having commited to CanIf the
* last data packet. */
}
}
/* Here we should check
* "if the TP.CM_EOMAck frame has already been received during CMDT transmission".
* However, when we receive the TP.CM_EOMAck message, we set the transmission channel into
* idle mode and we already have checked this mode.
* See J1939Tp_Internal_RxIndication_ReverseCm, where we check the command byte to be
* ENDOFMSGACK_CONTROL_VALUE.
*/
/** @req SWS_J1939Tp_00048 */
if ((status == E_OK )&& (PgInfo != NULL)) {
/* According to SWS_J1939Tp_00032 in v4.1, we should use the value NTFRSLT_E_NOT_OK
* when aborting transmission. NTFRSLT_E_CANCELATION_NOT_OK was used in
* version 4.0 to indicate that the implementation has chosen to do nothing. The item
* J1939TP0179 however, which allowed J1939Tp_CancelTransmit to do nothing, has been
* removed and replaced with SWS_J1939Tp_00203. */
/** @req SWS_J1939Tp_00032 */
PduR_J1939TpTxConfirmation(PgInfo->PgConfPtr->NSdu, NTFRSLT_E_NOT_OK);
//PduR_J1939TpTxConfirmation(PgInfo->PgConfPtr->NSdu, NTFRSLT_E_CANCELATION_NOT_OK);
/* SWS_J1939Tp_00048 wants us to send connection abort when
* J1939Tp_CancelTransmit is called.
* NOTE: In R4.1 Rev 1 there is a bug in SWS_J1939Tp_00048:
* it is J1939Tp_CancelTransmit (this function) and not J1939Tp_CancelReceive. */
J1939Tp_ProtocolType proto = PgInfo->ChannelInfoPtr->ChannelConfPtr->Protocol;
if (proto == J1939TP_PROTOCOL_CMDT) {
/* Get the Parameter Group Number PGN transfered through this PDU */
J1939Tp_PgnType PGN = PgInfo->PgConfPtr->Pgn;
/* Send connection abort message */
J1939Tp_Internal_SendConnectionAbort (PgInfo->ChannelInfoPtr, J1939TP_CM, PGN, CONNABORT_REASON_NO_RESOURCES);
}
/* Put the transmission channel into idle mode. */
PgInfo->ChannelInfoPtr->TxState->State = J1939TP_TX_IDLE;
}
return status;
}
#endif /*J1939TP_CANCELLATION_SUPPORT */
/*------------------------------------------------------------------------------------------------*/
/*------------------[Cancel Reception]------------------------------------------------------------*/
/** @req SWS_J1939Tp_00215 */
#if (J1939TP_CANCELLATION_SUPPORT == STD_ON)
/** @req SWS_J1939Tp_00176 */
/**
* @brief Cancel the ongoing reception of a J1939Tp N-SDU.
*
* This function will fail and return E_NOT_OK if one of the following conditions are met:
* - The module was not initialized by calling J1939Tp_Init.
* - RxSduId is not a valid SDU ID.
* - The channel use to recept the PG associated with the SDU RxSduId is not a reception channel.
* - The reception state of the channel used to recept the SDU RxSduId is not setup (configuration
* or logic error).
* - The channel used to recept RxSduId is in idle state (not receiving).
* - The SDU with ID RxSduId is used to recept a direct frame. Direct reception consists of single
* frames with no connection management and cannot be canceled after reception.
* - The received PDU is the last frame received using BAM. The reception cannot be canceled
* because there are no following frames to receive.
*
* In all other cases this function indication PduR about the canceled reception and if the
* protocol used to recept the SDU with ID RxSduId is CMDT, it transmits a connection abort message
* to the sending node.
*
* @param RxSduId ID of the J1939Tp N-SDU whose reception to cancel.
*
* @retval E_OK Cancelation request accepted.
* @retval E_NOT_OK Cancelation request failed.
*
* @see AUTOSAR specification for J1939Tp module, item SWS_J1939Tp_00176.
*/
Std_ReturnType J1939Tp_CancelReceive(PduIdType RxSduId)
{
J1939Tp_Internal_PgInfoType* PgInfo = NULL_PTR;
/* What we return from this function.
* MISRA C2012 rule 15.5 requieres one single return statement.
* This is why the following code seems so convoluted. */
Std_ReturnType status = E_OK;
if (globalState.State == J1939TP_OFF) {
status = E_NOT_OK;
/* Module was not initialised */
}
/** @req SWS_J1939Tp_00204 */
/* Get the PG structure corresponding to the Sdu Id RxSduId.
* If this fails, then RxSduId is an invalid Sdu ID. */
if (status == E_OK) {
status = J1939Tp_Internal_GetPg(RxSduId, &PgInfo);
}
/* Check if RxSduId corresponds to a direct frame:
* We cannot cancel direct frames because they are single frames and there
* is no session to cancel.
* Normally, the generator checks that every SduId is used only once, so
* RxSduId should not be used as Pdu Id of a direct frame. But we check
* anyway. We can see that RxSduId is used as index of a parameter group
* whose Sdu is <= 8 bytes long if for the pointed PG was dynamic length
* enabled or - in case of an older generator - if the direct Pdu is not
* -1, which is a symbolic value we use for Pdu and Sdu Ids which were not
* setup.
*/
if ((status == E_OK ) && (PgInfo != NULL)) {
if ((PgInfo->PgConfPtr->DynLength == TRUE) || (PgInfo->PgConfPtr->DirectNPdu != ((PduIdType) -1))) {
status = E_NOT_OK;
}
}
/* Check that we are speaking about a reception channel after all. */
if ((status == E_OK ) && (PgInfo != NULL)) {
if (PgInfo->ChannelInfoPtr->ChannelConfPtr->Direction != J1939TP_RX) {
/* not a reception channel so we cannot cancel reception on a
* transmission channel */
status = E_NOT_OK;
}
if (!PgInfo->ChannelInfoPtr->RxState) {
/* The reception pointer is null! */
status = E_NOT_OK;
}
}
/* OK, the PDU is associated with a reception channel. */
/* The specification of the J1939Tp module v4.1 (item SWS_J1939Tp_00204)
* sais that we "shall return E_NOT_OK [...] if RxSduId is currently not
* active".
* I interpret this as "if the channel use to transmit the PDU with ID
* RxSduId is in idle state". */
if ((status == E_OK )&& (PgInfo != NULL)) {
if (PgInfo->ChannelInfoPtr->RxState->State == J1939TP_RX_IDLE) {
/* channel used for PG with index RxSduId is idle, nothing to
* cancel. */
status = E_NOT_OK;
}
}
/* Check if the last TP.DT frame has already been received during BAM
* reception. */
if ((status == E_OK )&& (PgInfo != NULL)) {
/* Do we use BAM to receive this PG? */
boolean isBAM = (PgInfo->ChannelInfoPtr->ChannelConfPtr->Protocol == J1939TP_PROTOCOL_BAM);
/* Did we already received the last data packet? */
boolean isLastDt = J1939Tp_Internal_IsLastDt(PgInfo->ChannelInfoPtr->RxState);
if (isBAM && isLastDt) {
status = E_NOT_OK;
}
}
/* The next check required by item SWS_J1939Tp_00204 in the Autosar
* specification v4.1 of the J1939Tp module is to prove if we already sent
* the TP.CM_EOMAck. However, when we send this message, we also put the
* channel used to receive the pdu into idle mode and we
* already have checked this mode. So we can ommit this requirement.
*
* See J1939Tp_Internal_RxIndication_Dt, where we call
* J1939Tp_Internal_SendEndOfMsgAck.
*/
if ((status == E_OK ) && (PgInfo != NULL)) {
/** @req SWS_J1939Tp_00031*/
PduR_J1939TpRxIndication(PgInfo->PgConfPtr->NSdu, NTFRSLT_E_NOT_OK);
/** @req SWS_J1939Tp_00040 */
/* SWS_J1939Tp_00040 specifies a Connection Abort message in case of
* a CMDT connection. */
/* Get the protocol used to receive this PG */
J1939Tp_ProtocolType proto = PgInfo->ChannelInfoPtr->ChannelConfPtr->Protocol;
if (proto == J1939TP_PROTOCOL_CMDT) {
/* Get the Parameter Group Number PGN transfered through this PDU */
J1939Tp_PgnType PGN = PgInfo->PgConfPtr->Pgn;
/* Send connection abort message */
J1939Tp_Internal_SendConnectionAbort(PgInfo->ChannelInfoPtr, J1939TP_CM, PGN, CONNABORT_REASON_NO_RESOURCES);
}
/* Put the channel into idle mode because after cancelation we do not
* expect data anymore. */
PgInfo->ChannelInfoPtr->RxState->State = J1939TP_RX_IDLE;
}
return status;
}
#endif /* J1939TP_CANCELLATION_SUPPORT */
/*------------------------------------------------------------------------------------------------*/
/*------------------[Transmit Parameter Group]----------------------------------------------------*/
/** @req SWS_J1939Tp_00096 */
/** @req SWS_J1939Tp_00045 */
/**
* @brief Transmit a J1939Tp N-SDU.
*
* @param TxSduId ID of the SDU to be transmitted.
* @param TxInfoPtr Pointer to struture containing the data length of the SDU to
* transmit and the metadata information.
* If TxInfoPtr->SduDataPtr is NULL_PTR, then the
* SDU was setup with no metadata. Otherwise it is assumed that
* it contains only the addressing information (metadata) of
* the SDU. The size of this buffer is the setup parameter
* MetaDataLength.
* @retval E_OK Transmission request has been accepted.
* @retval E_NOT_OK Transmission failed.
*/
Std_ReturnType J1939Tp_Transmit(PduIdType TxSduId, const PduInfoType* TxInfoPtr)
{
Std_ReturnType status = E_NOT_OK;
uint8 metadatalength = 0;
J1939Tp_Internal_PgInfoType* PgInfo = NULL_PTR;
const J1939Tp_PgType* Pg = NULL_PTR;
uint8 MaxNumPackets = RTS_MAX_NUM_PACKETS_VALUE;
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr = NULL_PTR;
J1939Tp_Internal_TxChannelInfoType* TxState = NULL_PTR;
if (globalState.State == J1939TP_ON) {
status = E_OK;
}
#if (J1939TP_DEV_ERROR_DETECT == STD_ON)
else {
J1939TP_DET_REPORT_ERROR(J1939TP_TRANSMIT_ID, J1939TP_E_UNINIT);
}
#endif
if (status == E_OK) {
/* Get the information about the parameter group to transmit: this
* contains the PG and the channel. The PG is associated with
* the Sdu Id.
* If this call returns E_NOT_OK, then the SduId is not valid. */
status = J1939Tp_Internal_GetPg(TxSduId, &PgInfo);
}
if ((status == E_OK ) && (PgInfo != NULL)) {
/* Sdu Id is valid, decide whether we do direct or segmented
* transmission based on the data length of the Sdu. */
if (TxInfoPtr->SduLength <= DIRECT_TRANSMIT_SIZE) {
/* data length is less equal 8 bytes, do direct transmission */
status = J1939Tp_Internal_DirectTransmit(TxInfoPtr, PgInfo);
}
else {
/* Segmented transmission, extract the PG, used channel,
* transmission state and protocol */
Pg = PgInfo -> PgConfPtr;
ChannelInfoPtr = PgInfo -> ChannelInfoPtr;
TxState = ChannelInfoPtr -> TxState;
metadatalength = Pg -> NSdu_MetaDataLength;
SchM_Enter_J1939Tp_EA_0(); /* save interrupts mask */
if (TxState->State == J1939TP_TX_IDLE) {
/* Transmission channel is idle */
/* Setup transmission state */
TxState->TotalMessageSize = TxInfoPtr->SduLength;
TxState->PduRPdu = TxSduId;
TxState->CurrentPgPtr = Pg;
TxState->SentDtCount = 0;
/* Set the channel addressing information */
J1939Tp_Internal_Set_Channel_Metadata(ChannelInfoPtr, TxInfoPtr->SduDataPtr, metadatalength);
/** @req SWS_J1939Tp_00047 */
switch (ChannelInfoPtr->Protocol) {
case J1939TP_PROTOCOL_BAM:
TxState->State = J1939TP_TX_WAIT_BAM_CANIF_CONFIRM;
J1939Tp_Internal_StartTimer(&(TxState->TimerInfo), J1939TP_TX_CONF_TIMEOUT);
status = J1939Tp_Internal_SendBam(ChannelInfoPtr, TxInfoPtr);
if (status != E_OK) {
/* Cannot sent the BAM message, abort */
J1939Tp_Internal_Reset_Channel(ChannelInfoPtr);
PduR_J1939TpTxConfirmation(TxState->CurrentPgPtr->NSdu, NTFRSLT_E_NOT_OK);
}
break;
case J1939TP_PROTOCOL_CMDT:
TxState->State = J1939TP_TX_WAIT_RTS_CANIF_CONFIRM;
/** @req SWS_J1939Tp_00165 */
#if (J1939TP_DYNAMIC_BLOCK_CALCULATION == STD_ON)
/* dynamic block size calculation is enabled */
/* Dummy PDU with no data and zero data length used to request
* the buffer size of a specific SDU from PduR. */
PduInfoType zeroSDU = {
.SduDataPtr = NULL_PTR,
.SduLength = 0
};
/* Available buffer size of the data to be transmitted.
* This size is requested from PduR before sending the
* RTS message. */
PduLengthType availableBufferSize = 0;
/* Request from PduR the buffer size of the SDU we transmit */
BufReq_ReturnType size_request_ret = PduR_J1939TpCopyTxData(TxSduId, &zeroSDU, NULL_PTR, &availableBufferSize);
if (size_request_ret == BUFREQ_OK) {
#if defined(J1939TP_MAX_PACKETS_PER_BLOCK)
/** @req SWS_J1939Tp_00207 */
/* "compare the available amount of data returned
* by PduR_J1939TpCopyTxData to J1939TpMaxPacketsPerBlock
* and use use the smaller of these two values to calculate
* the maximum number of packets field of the
* TP.CM_RTS message". */
MaxNumPackets = J1939TP_Internal_GetNumDtPacketsToSend(availableBufferSize);
//lint -e685
if (MaxNumPackets > J1939TP_MAX_PACKETS_PER_BLOCK) {
MaxNumPackets = J1939TP_MAX_PACKETS_PER_BLOCK;
}
#else
/** @req SWS_J1939Tp_00208 */
MaxNumPackets = J1939TP_Internal_GetNumDtPacketsToSend(availableBufferSize);
#endif
}
#else
/* dynamic block size calculation is disabled */
#if defined(J1939TP_MAX_PACKETS_PER_BLOCK)
/** @req SWS_J1939Tp_00209 */
MaxNumPackets = J1939TP_MAX_PACKETS_PER_BLOCK;
#endif
#endif
J1939Tp_Internal_StartTimer(&(TxState->TimerInfo), J1939TP_TX_CONF_TIMEOUT);
status = J1939Tp_Internal_SendRts(ChannelInfoPtr, TxInfoPtr, MaxNumPackets);
if (status != E_OK) {
J1939Tp_Internal_Reset_Channel(ChannelInfoPtr);
PduR_J1939TpTxConfirmation(TxState->CurrentPgPtr->NSdu, NTFRSLT_E_NOT_OK);
}
break;
default:
status = E_NOT_OK; /* no such protocol */
break;
}
}
else {
/* Transmission channel is not idle */
/* @req SWS_J1939Tp_00101 */
status = E_NOT_OK;
}
SchM_Exit_J1939Tp_EA_0(); /* restore interrupts mask */
}
}
return status;
}
/*------------------[Direct transmission]---------------------------------------------------------*/
/**
* @brief Perform direct transmission of SDU.
*
* Direct transmission (without segmentation) is performed with PGs having less
* equal 8 bytes data.
*
* @param TxInfoPtr SDU to be transmitted. The pointed structure contains the size of the
* transmitted data. The actual data content is requested from PduR.
* @param PgInfo PG information about the SDU to be transmitted.
*
* @retval E_OK
* @retval E_NOT_OK
*/
static inline Std_ReturnType J1939Tp_Internal_DirectTransmit
(
const PduInfoType* TxInfoPtr,
J1939Tp_Internal_PgInfoType* PgInfo
)
{
Std_ReturnType status = E_NOT_OK;
const J1939Tp_PgType* Pg = PgInfo->PgConfPtr;
PduIdType CanIfPdu = Pg->DirectNPdu;
PduIdType NSdu = Pg->NSdu;
PduLengthType remainingBytes = 0;
/* check if transmission state is idle (not already sending)
* for direct frames the transmission state is stored directy in the PgInfo
* structure, not in the channel */
SchM_Enter_J1939Tp_EA_0();
if (PgInfo->TxState == J1939TP_PG_TX_IDLE)
{
/* transmit state is idle, so we can transmit */
status = E_OK;
}
SchM_Exit_J1939Tp_EA_0();
/** @req SWS_J1939Tp_00068 */
/* Data buffer used to copy the transmitted data from PduR */
uint8 dataPtr[DIRECT_TRANSMIT_SIZE + METADATALENGTH_MAX] =
{ J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED,
J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED
};
/* Pdu information we provide to CanIf for transmission.
* CanIf should use the PduId to recognize if this Pdu has metadata and
* subtract the metadatalength from the total length we provide.
* The metadata bytes themselves are provided by PduR itself when we call
* PduR_J1939TpCopyTxData below. */
PduInfoType directPduInfo =
{
.SduDataPtr = dataPtr,
.SduLength = TxInfoPtr->SduLength
};
if (status == E_OK) {
status = E_NOT_OK;
/* Get the data from PduR. This may include metadata bytes */
if (BUFREQ_OK == PduR_J1939TpCopyTxData(NSdu, &directPduInfo, NULL_PTR, &remainingBytes)) {
SchM_Enter_J1939Tp_EA_0();
/* Change transmission state to waiting for CanIf to confirm
* transmission */
PgInfo->TxState = J1939TP_PG_TX_WAIT_DIRECT_SEND_CANIF_CONFIRM;
SchM_Exit_J1939Tp_EA_0();
/* metadatalength is always 0 for J1939TP_DIRECT,
* Force Can_If to transmit DIRECT_TRANSMIT_SIZE bytes
*/
directPduInfo.SduLength = DIRECT_TRANSMIT_SIZE;
/* Timeout if CanIf takes to long */
J1939Tp_Internal_StartTimer(&(PgInfo->TimerInfo), J1939TP_TX_CONF_TIMEOUT);
/* Transmit! */
status = CanIf_Transmit(CanIfPdu, &directPduInfo);
}
}
if (status != E_OK) {
/* Transmit failed */
SchM_Enter_J1939Tp_EA_0();
/* Reset state to idle */
PgInfo->TxState = J1939TP_PG_TX_IDLE;
SchM_Exit_J1939Tp_EA_0();
/** @req SWS_J1939Tp_00032 */
/** @req SWS_J1939Tp_00048 */
/* Tell PduR that transmission went wrong.
* The value NTFRSLT_E_NOT_OK is defined in ComStack_Types.h
* and means message not successfully sent out */
PduR_J1939TpTxConfirmation(NSdu, NTFRSLT_E_NOT_OK);
}
return status;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Send BAM message]------------------------------------------------------------*/
/**
* @brief Transmit the broadcast announce message (BAM) on the specified
* channel and using the specified message size and PGN.
*
* @param ChannelInfoPtr channel used to transmit the BAM message.
* The channel structure is used to access the PGN of
* the transmitted PG and the SDU ID.
* @param TxInfoPtr Pointer to Pdu-structure.
* This is used to extract the message size.
*
* @retval E_OK message has been successfully transmitted
* @retval E_NOT_OK message could not be transmitted
*/
static inline Std_ReturnType J1939Tp_Internal_SendBam
(
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr,
const PduInfoType* TxInfoPtr
)
{
/* Data of the BAM frame. This is what we send.
* Its size is the standard size of the BAM message (8 bytes) plus
* the maximal size of the metadata which we append to the BAM message
* and which we get from the data buffer of the TxInfoPtr. */
uint8 cmBamData[BAM_SIZE + METADATALENGTH_MAX] = { 0 };
/* Mark this data as being a BAM message */
cmBamData[BAM_BYTE_CONTROL] = BAM_CONTROL_VALUE;
/* Get the data length of the SDU to send.
* We don't touch the actual SDU data, we just get its size and put it into
* the BAM message. */
PduLengthType SduLength = TxInfoPtr->SduLength;
/* Mask the second byte of the Sdu data length */
PduLengthType SduLength_2nd_byte = (SduLength & 0xFF00);
/* Extract the first byte of the SDU length */
uint8 SduLength_byte1 = (uint8) (SduLength & 0x00FF);
/* Extract the second byte of the SDU length */
uint8 SduLength_byte2 = (uint8) (SduLength_2nd_byte >> 8);
/* How many packets we need to send the whole data.
* This is how many TP.DT frames we send. */
uint8 num_DT_packets = J1939TP_Internal_GetNumDtPacketsToSend(SduLength);
/* Fill in message length in little endian byte order */
cmBamData[BAM_BYTE_LENGTH_1] = SduLength_byte1;
cmBamData[BAM_BYTE_LENGTH_2] = SduLength_byte2;
/* Fill in how many packets we are going to send */
cmBamData[BAM_BYTE_NUM_PACKETS] = num_DT_packets;
/* This byte is reserved */
cmBamData[BAM_BYTE_SAE_ASSIGN] = J1939TP_RESERVED;
/* Get the PGN we announce. */
J1939Tp_PgnType pgn = ChannelInfoPtr->TxState->CurrentPgPtr->Pgn;
/* Pointer to where the PGN is stored in the data segment */
uint8* pgn_bytes = &(cmBamData[BAM_BYTE_PGN_1]);
/* Fill in the PGN */
J1939Tp_Internal_SetPgn(pgn_bytes, pgn);
/* PduId of the Connection Management frame used to send the BAM message */
PduIdType CmNPdu = ChannelInfoPtr->ChannelConfPtr->CmNPdu;
/* MetaDataLength parameter associated with the Connection Management PDU
* of the channel */
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(ChannelInfoPtr->ChannelConfPtr, J1939TP_CM);
if (TxInfoPtr->SduDataPtr == NULL_PTR)
{
/* cannot copy medata because provided data pointer is null */
metadatalength = 0;
}
/* Copy the channel metadata into the data buffer.
* We take the metadata from the internal channel structure and not from
* the provided TxInfoPtr->SduDataPtr. */
J1939Tp_Internal_Copy_Channel_Metadata(ChannelInfoPtr, &(cmBamData[BAM_SIZE]), metadatalength);
/* This PDU Info is what CanIf, the underlying layer, should transmit.
* Note that we don't pass to CanIf the PDU Info we get as argument because
* we don't send the PDU data yet, but only announce it. */
PduInfoType cmBamPdu;
/* We pass to CanIf the entire data buffer with eventually metadata
* information. */
cmBamPdu.SduLength = BAM_SIZE + metadatalength;
cmBamPdu.SduDataPtr = cmBamData;
/* Transmit! */
Std_ReturnType r = CanIf_Transmit(CmNPdu, &cmBamPdu);
return r;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Extract message size from RTS and BAM message]-------------------------------*/
/**
* @brief Extract the message size out of a RTS or BAM message.
*
* The RTS and BAM messages - both 8 bytes long - contain at indexes 1 and 2
* the size of the PG to be transmitted. This size is stored in little endian
* byte order.
* This function extracts the numerical value of this size.
*
* @param pduInfo Pointer to PDU Info structure holding a pointer to the
* message's data buffer where to extract to size from.
* @return Message size in bytes.
*/
static inline uint16 J1939Tp_Internal_GetRtsMessageSize(PduInfoType* pduInfo)
{
/* Get the two bytes from the message buffer */
uint16 byte1 = (uint16) ( pduInfo->SduDataPtr[RTS_BYTE_LENGTH_1] );
uint16 byte2 = (uint16) ( pduInfo->SduDataPtr[RTS_BYTE_LENGTH_2] );
/* Shift first byte according to little endian order */
byte2 = byte2 << 8;
/* Reverse bytes */
return (byte2 | byte1);
}
/*------------------------------------------------------------------------------------------------*/
static inline boolean J1939Tp_Internal_WaitForCts(J1939Tp_Internal_TxChannelInfoType* TxChannelState) {
return TxChannelState->SentDtCount == TxChannelState->DtToSendBeforeCtsCount;
}
/*------------------[Compute number of packets]---------------------------------------------------*/
/**
* @brief Compute the number of data packets to be send based on the total message size.
*
* @param messageSize The total message size in bytes.
* This number must be in range 0 to 1785, which is the largest amount
* of data that can be transferred with J1939. If this parameter has
* a value larger than 1785, it will be corrected down to 1785.
*
* @return Number of packets to send.
*/
static inline
uint8 J1939TP_Internal_GetNumDtPacketsToSend(PduLengthType messageSize)
{
/* Correct message size */
if (messageSize > J1939TP_MAX_DATA_LENGTH)
{
messageSize = J1939TP_MAX_DATA_LENGTH;
}
uint8 packetsToSend = messageSize/DT_DATA_SIZE;
if (messageSize % DT_DATA_SIZE != 0) {
packetsToSend = packetsToSend + 1;
}
return packetsToSend;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Has the last DT been sent?]--------------------------------------------------*/
/**
* @brief Returns true is the specified transmission channel state indicates no more packets
* to be send.
*
* @param TxChannelState Transmission state, holds the number of already sent packets
* and the total message size.
*
* @retval true The last DT packet has been sent.
* @retval false There are more packets to be send.
*/
static inline boolean J1939Tp_Internal_LastDtSent(J1939Tp_Internal_TxChannelInfoType* TxChannelState)
{
/* Total message size in bytes */
J1939Tp_Internal_DtPayloadSizeType totalMessageSize = 0;
/* How many packets are needed to send the entire message */
uint8 packetsToSend = 0;
/* How many packets were sent already */
uint8 SentDtCount = 0;
totalMessageSize = TxChannelState->TotalMessageSize;
packetsToSend = J1939TP_Internal_GetNumDtPacketsToSend(totalMessageSize);
SentDtCount = TxChannelState->SentDtCount;
/* We may have erroneously incremented too much the counter SentDtCount,
* which stores how many packets were confirmed to have been sent,
* so we check if the sent data counter is greater or equal, not just equal,
* than the total number of packets to send. */
return (SentDtCount >= packetsToSend);
}
/*------------------------------------------------------------------------------------------------*/
static inline J1939Tp_Internal_TimerStatusType J1939Tp_Internal_IncAndCheckTimer
(J1939Tp_Internal_TimerType* TimerInfo)
{
J1939Tp_Internal_TimerStatusType status;
status = J1939TP_NOT_EXPIRED;
if (TimerInfo->Timer == 0 && TimerInfo->TimerExpire == 0)
{
status = J1939TP_NOT_EXPIRED;
} else {
TimerInfo->Timer += J1939TP_MAIN_FUNCTION_PERIOD;
if (TimerInfo->Timer >= TimerInfo->TimerExpire)
{
status = J1939TP_EXPIRED;
}
}
return status;
}
/* Returns the Parameter Format of a Parameter Group Number */
static inline uint8 J1939Tp_Internal_GetPf(J1939Tp_PgnType pgn)
{
return (uint8)(pgn >> 8);
}
/*------------------[Send Data Packet (DT)]-------------------------------------------------------*/
/**
* @brief Send data packet.
*
* @param ChannelInfoPtr Channel information used to send the packet.
* This contains information about message size, amount of sent packets
* and SDU IDs.
*
* @retval E_OK Data Packet has been sent.
* @retval E_NOT_OK Transmission failed.
* Mainly because PduR failed to access the associated data.
*/
static inline Std_ReturnType J1939Tp_Internal_SendDt
(
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr
)
{
/* Return value from this function */
Std_ReturnType status = E_NOT_OK;
/* How many SDU data bytes we request from PduR so send with this packet.
* Maximum is 7 bytes. */
uint8 requestLength = DT_DATA_SIZE;
/* Total message size in bytes */
J1939Tp_Internal_DtPayloadSizeType TotalMessageSize = ChannelInfoPtr->TxState->TotalMessageSize;
/* How many packets did we send up to this point */
uint8 SentDtCount = ChannelInfoPtr->TxState->SentDtCount;
/* How many bytes did we send up to this point */
J1939Tp_Internal_DtPayloadSizeType sentBytes = SentDtCount * DT_DATA_SIZE;
/* How many byte we still need to send */
J1939Tp_Internal_DtPayloadSizeType bytesLeftToSend = TotalMessageSize - sentBytes;
/* If the remaining bytes are less then the maximum number of bytes,
* do not request the maximum number.
* This happens when we send the last packet. */
if (bytesLeftToSend < DT_DATA_SIZE){
requestLength = bytesLeftToSend;
}
/** @req SWS_J1939Tp_00200 */
/* Prepare TP.DT message.
* The data message must be always 8 bytes large according to
* SWS_J1939Tp_00200. Additionally we setup eventuall metadata. */
/** @req SWS_J1939Tp_00068 */
uint8 dtBuffer[DT_SIZE + METADATALENGTH_MAX] = {
J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED,
J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED, J1939TP_RESERVED
};
/* This struct is what we pass CanIf to transmit.
* First we adjust the structure for the PduR call:
* - we set the data pointer one byte after the actual data begin because the first byte
* is used for the sequence number and only after that beginns the actual SDU data
* (next 7 bytes) which we get from PduR
* - set the SDU length to the number of bytes we transmit with this packet.
* we reset this to 8 later
*/
PduInfoType DtPdu = {
.SduDataPtr = &(dtBuffer[DT_BYTE_DATA_1]),
.SduLength = requestLength
};
/* SDU ID where to get the data from.
* This ID tells PduR where to get the date from. */
PduIdType NSdu = ChannelInfoPtr->TxState->CurrentPgPtr->NSdu;
/* Here stores PduR the remaining number of bytes being available */
PduLengthType availableData = 0;
/* Tell PduR to copy the SDU data into the data buffer. */
/** @req SWS_J1939Tp_00046 */
BufReq_ReturnType allocateBufferRes = PduR_J1939TpCopyTxData(NSdu, &DtPdu, NULL_PTR, &availableData);
if (allocateBufferRes == BUFREQ_OK)
{// successfully got data from upper layers
/* After PduR copied the data bytes we should send (the next packet)
* we copy the eventual metadata into the buffer of the Data PDU */
uint8* metadata = &(dtBuffer[DT_SIZE]);
PduIdType DtNPdu = ChannelInfoPtr->ChannelConfPtr->DtNPdu;
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(ChannelInfoPtr->ChannelConfPtr, J1939TP_DT);
J1939Tp_Internal_Copy_Channel_Metadata(ChannelInfoPtr, metadata, metadatalength);
/* Correct PDU information after PduR has copied the SDU data there:
* - PDU length is now 8 bytes + metadata, including the sequence
* number in the first byte
* - PDU data includes the first byte */
DtPdu.SduLength = DT_SIZE + metadatalength;
DtPdu.SduDataPtr = dtBuffer;
/* Note about the SduLength:
* SWS_CANIF_00844 specifies: "The SDU length is set to the sum of
the payload length and MetaDataLength".
CanIf should therefore use the global MetaDataLength in order to
compute the actual data length code by subtracting MetaDatLength
from the SduLength. */
/* Fill in the sequence number */
DtPdu.SduDataPtr[DT_BYTE_SEQ_NUM] = ChannelInfoPtr->TxState->SentDtCount+1;
status = CanIf_Transmit(DtNPdu, &DtPdu);
}
else
{/* PduR failed to provide the data we should transmit */
status = E_NOT_OK; // we failed
}
return status;
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Send the RTS message]--------------------------------------------------------*/
/**
* @brief Send the initial RTS message.
*
* The Request To Send message initiates a CMDT connection on the sender side.
* The receiver is expected to send a Clear To Send or Connection Abort message
* (or time out). After having received the CTS message the data transmission
* can begin.
*
* @param ChannelInfoPtr Channel used to transmit the RTS message. The channel
* is used to read the PduId of the connection management
* frame used to transmit the Sdu and the PGN of this Sdu.
* We assume that the channel was setup before calling
* this function.
* @param TxInfoPtr Pdu information containing the total data size of the
* Sdu to transmit and the MetaData at the end of the data
* pointer if the Sdu Id of the Sdu was setup with
* MetaData.
* @param MaxNumPackets Maximum number of packets J1939Tp can send in response
* to the CTS message. This number is part of the RTS
* message.
*
* @returns Whatever CanIf_Transmit returns.
*/
static inline Std_ReturnType J1939Tp_Internal_SendRts
(
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr,
const PduInfoType* TxInfoPtr,
uint8 MaxNumPackets
)
{
/* This array stores the RTS message we transmit */
uint8 cmRtsData[RTS_SIZE + METADATALENGTH_MAX] = { 0 };
cmRtsData[RTS_BYTE_CONTROL] = RTS_CONTROL_VALUE;
cmRtsData[RTS_BYTE_LENGTH_1] = (uint8)(TxInfoPtr->SduLength);
cmRtsData[RTS_BYTE_LENGTH_2] = (uint8)(TxInfoPtr->SduLength >> 8);
cmRtsData[RTS_BYTE_NUM_PACKETS] =
J1939TP_Internal_GetNumDtPacketsToSend(TxInfoPtr->SduLength);
cmRtsData[RTS_BYTE_MAX_NUM_PACKETS] = MaxNumPackets;
J1939Tp_PgnType pgn = ChannelInfoPtr->TxState->CurrentPgPtr->Pgn;
J1939Tp_Internal_SetPgn(&(cmRtsData[RTS_BYTE_PGN_1]), pgn);
/* Connection Management Pdu Id used on this channel */
PduIdType CmNPdu = ChannelInfoPtr->ChannelConfPtr->CmNPdu;
/* MetaDataLength parameter associated with the connection management Pdu
* used for RTS transmission */
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(ChannelInfoPtr->ChannelConfPtr, J1939TP_CM);
J1939Tp_Internal_Copy_Channel_Metadata(ChannelInfoPtr, &(cmRtsData[RTS_SIZE]), metadatalength);
PduInfoType cmRtsPdu = {
.SduLength = RTS_SIZE + metadatalength,
.SduDataPtr = cmRtsData
};
Std_ReturnType r = CanIf_Transmit(CmNPdu, &cmRtsPdu);
return r;
}
/*------------------[Send End of Message Aknowledge]----------------------------------------------*/
/**
* @brief Send the End Of Message Aknowledge Message.
*
* This message is being sent by the receiving node to the transmitting node to
* aknowledge the reception of the last data paket when using Connection Mode
* Data Transfer (CMDT).
*
* @param ChannelInfoPtr channel used to send the message.
* This channel is used to read the total size of the
* aknowledged message, the number of the received packets
* and the PGN of the aknowledged PG.
*/
static inline void J1939Tp_Internal_SendEndOfMsgAck
(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr)
{
/* Get the total message size from the description of the receiving state
* of the channel. */
J1939Tp_Internal_DtPayloadSizeType message_size =
ChannelInfoPtr->RxState->TotalMessageSize;
/* Extract the two bytes of the total message size.
* We put these byte into the transmitted message. */
uint8 message_size_byte1 = (uint8) (message_size >> 0);
uint8 message_size_byte2 = (uint8) (message_size >> 8);
/* PDU data buffer to send.
* This will become the 8 byte data segment of a CAN frame and is the actual
* message after CanIf has handled the eventual metadata at the end. */
uint8 endofmsgData[ENDOFMSGACK_SIZE + METADATALENGTH_MAX] = { 0 };
/* Mark this data buffer as End of Message Aknowledgement */
endofmsgData[ENDOFMSGACK_BYTE_CONTROL] = ENDOFMSGACK_CONTROL_VALUE;
/* Fill in the aknowledged message size in little endian byte order */
endofmsgData[ENDOFMSGACK_BYTE_TOTAL_MSG_SIZE_1] = message_size_byte1;
endofmsgData[ENDOFMSGACK_BYTE_TOTAL_MSG_SIZE_2] = message_size_byte2;
/* Fill in the number of packets we received */
endofmsgData[ENDOFMSGACK_BYTE_NUM_PACKETS] = ChannelInfoPtr->RxState->ReceivedDtCount;
/* The 5th byte of the message is reserved */
endofmsgData[ENDOFMSGACK_BYTE_SAE_ASSIGN] = J1939TP_RESERVED;
/* Get the PGN of the PG to aknowledge */
J1939Tp_Internal_PgnType PGN = ChannelInfoPtr->RxState->CurrentPgPtr->Pgn;
/* Fill in the PGN of the aknolwdged PG */
J1939Tp_Internal_SetPgn(&(endofmsgData[ENDOFMSGACK_BYTE_PGN_1]), PGN);
/* Get the PDU ID of the PDU used for Flow Control for this PG. */
PduIdType FcNPdu = ChannelInfoPtr->ChannelConfPtr->FcNPdu;
/* Extract the MetaDataLength for the Flow Control Pdu */
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(ChannelInfoPtr->ChannelConfPtr, J1939TP_REVERSE_CM);
/* Append the channel's addressing information to the data buffer */
J1939Tp_Internal_Copy_Channel_Metadata(ChannelInfoPtr, &(endofmsgData[ENDOFMSGACK_SIZE]), metadatalength);
/* The PDU which CanIf should send */
PduInfoType endofmsgInfo = {
.SduLength = ENDOFMSGACK_SIZE + metadatalength,
.SduDataPtr = endofmsgData
};
/* Transmit! */
/*lint -save -e534 */
CanIf_Transmit(FcNPdu, &endofmsgInfo);
/*lint -restore */
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Send the CTS message]--------------------------------------------------------*/
/**
* @brief Send the CTS message.
*
* This function transmits the Clear To Send (CTS) flow control message in
* response to an incoming Request To Send (RTS) message.
* The CTS message is being sent using a reception channel.
*
* @param ChannelInfoPtr Reception channel used to transmit the message.
* The channel is used to access the PDU ID of the
* flow control PDU.
* @param Pgn Parameter Group Number of the Parameter Group to
* send.
* @param NextPacketSeqNum Next packet number to request.
* @param NumPackets How many packets to request. This number is also
* called the block size.
*/
static inline void J1939Tp_Internal_SendCts
(
J1939Tp_Internal_ChannelInfoType *ChannelInfoPtr,
J1939Tp_PgnType Pgn,
uint8 NextPacketSeqNum,
uint8 NumPackets
)
{
/* Data buffer used to store the CTS message and the eventual metadata. */
uint8 ctsData[CTS_SIZE + METADATALENGTH_MAX] = { 0 };
/* Fill in the data of the CTS message */
/* Mark the data buffer as a CTS message */
ctsData[CTS_BYTE_CONTROL] = CTS_CONTROL_VALUE;
ctsData[CTS_BYTE_NUM_PACKETS] = NumPackets;
ctsData[CTS_BYTE_NEXT_PACKET] = NextPacketSeqNum;
ctsData[CTS_BYTE_SAE_ASSIGN_1] = J1939TP_RESERVED;
ctsData[CTS_BYTE_SAE_ASSIGN_2] = J1939TP_RESERVED;
/* Fill in the PGN */
J1939Tp_Internal_SetPgn(&(ctsData[CTS_BYTE_PGN_1]), Pgn);
/* ID of the flow control PDU used to transmit the CTS message */
const PduIdType FcNPdu = ChannelInfoPtr->ChannelConfPtr->FcNPdu;
/* Extract the MetaDataLength for the Control Flow Pdu */
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(ChannelInfoPtr->ChannelConfPtr, J1939TP_REVERSE_CM);
/* Append the channels addressing information to the metadata buffer */
J1939Tp_Internal_Copy_Channel_Metadata(ChannelInfoPtr, &(ctsData[CTS_SIZE]), metadatalength);
/* PDU passed to CanIf. The field SduLength contains the MetaDataLength and
* CanIf must correct this length in order to get the actual payload size.*/
PduInfoType ctsInfo =
{
.SduLength = CTS_SIZE + metadatalength,
.SduDataPtr = ctsData
};
/* Transmit! */
/*lint -save -e534 */
CanIf_Transmit(FcNPdu, &ctsInfo);
/*lint -restore */
}
/*------------------------------------------------------------------------------------------------*/
/*------------------[Send Connection Abort Message]-----------------------------------------------*/
/**
* @brief Send a connection abort message.
*
* @param ChannelInfoPtr
* Channel using the CmNPdu Pdu Id. The channel is used to
* extract the addressing information into the metadata buffer.
* @param PacketType
* Type of packet being sent. This argument is used to extract
* the right PduId used to call CanIf. It is necessary because
* the Send Abort message is used either as a connection
* management message, or as a control flow message. For these
* kinds of messages different PduIds are being used: for the
* Connection Management message (J1939TP_CM) the CmNPdu is used,
* for Flow Control messages (J1939TP_REVERSE_CM), the FcNPdu is
* used. This argument is also used to extract the associated
* MetaDataLength configuration parameter of the PduId.
* @param Pgn Parameter Group Number of the PG whose transmission is being
* aborted. This number is used in the connection abort message.
* @param Reason Connection Abort reason. Part of the connection abort message.
*
* @note The abort reasons are defined in J1939Tp_Internal_Packets.h
*
* @returns nothing
*/
static inline void J1939Tp_Internal_SendConnectionAbort
(
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr,
J1939Tp_RxPduType PacketType,
J1939Tp_PgnType Pgn,
uint8 Reason
)
{
/* Data buffer used as message.
* Make room for the message itself and for eventual metadata bytes. */
uint8 connAbortData[CONNABORT_SIZE + METADATALENGTH_MAX] = { 0 };
/* Mark this message as being a connection abort message.
* This byte is what differentiates the different CMDT messages. */
connAbortData[CONNABORT_BYTE_CONTROL] = CONNABORT_CONTROL_VALUE;
/* Fill in the abort reason. */
connAbortData[CONNABORT_BYTE_REASON] = Reason;
/* Next three bytes are reserved. */
connAbortData[CONNABORT_BYTE_SAE_ASSIGN_2] = J1939TP_RESERVED;
connAbortData[CONNABORT_BYTE_SAE_ASSIGN_3] = J1939TP_RESERVED;
connAbortData[CONNABORT_BYTE_SAE_ASSIGN_4] = J1939TP_RESERVED;
/* Fill in the PGN of the aborted PG. */
J1939Tp_Internal_SetPgn(&(connAbortData[CONNABORT_BYTE_PGN_1]), Pgn);
/* Extract the configuration parameter MetaDataLength of the
* Connection Management PDU */
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(ChannelInfoPtr->ChannelConfPtr, PacketType);
/* Copy the addressing information into the metadata buffer */
J1939Tp_Internal_Copy_Channel_Metadata(ChannelInfoPtr, &(connAbortData[CONNABORT_SIZE]), metadatalength);
/* Holds pointer to the data buffer to transmit and the buffer length.
* The buffer length equals the size of the message (payload) plus
* the metadatalength associated with the Pdu Id we pass to CanIf.
* This is what we pass to CanIf, which should correct the actual payload
* size by subtracting the MetaDataLength from the SduLength.*/
PduInfoType connAbortInfo = {
.SduLength = CONNABORT_SIZE + metadatalength,
.SduDataPtr = connAbortData
};
/* Transmit */
PduIdType PduId = J1939Tp_Internal_Get_Pdu(ChannelInfoPtr->ChannelConfPtr, PacketType);
/*lint -save -e534 */
CanIf_Transmit(PduId, &connAbortInfo);
/*lint -restore */
}
/*------------------------------------------------------------------------------------------------*/
static inline
void J1939Tp_Internal_StartTimer
(
J1939Tp_Internal_TimerType* TimerInfo,
uint16 TimerExpire
)
{
TimerInfo->Timer = 0;
TimerInfo->TimerExpire = TimerExpire;
}
static inline
void J1939Tp_Internal_StopTimer(J1939Tp_Internal_TimerType* TimerInfo)
{
TimerInfo->Timer = 0;
TimerInfo->TimerExpire = 0;
}
/*------------------[Extract and set the PGN into byte buffer]------------------------------------*/
/**
* @brief Write PGN into byte buffer.
*
* The parameter group number (PGN) is a 18 bits identification number of a
* J1939 parameter group (PG). This function extracts the 18 bits from the
* specified PGN and sets the bytes in the buffer PgnBytes accordingly.
* The byte order is little endian, as specified by the J1939 standard.
* The 18 bits are internally extended to 24 bits (3 bytes) with the most
* significant 6 bits set to zero.
*
* Example:
* For the PGN 0x02FBFD, the content of the array PgnBytes will be set
* to [0xFD, 0xFB, 0x02]. If PGN is for some reason 0xFFFFFFFF, then the array
* PgnBytes will be set to [0xFF, 0xFF, 0x03], that is the most significant 6
* bits of the extended 24 bit PGN set to zero.
*
* @param PgnBytes Array of at least three bytes of type uint8.
* @param pgn Parameter Group Number (PGN)
*/
static inline void J1939Tp_Internal_SetPgn(uint8* PgnBytes, J1939Tp_PgnType pgn)
{
/* Get the content of the least significant 3 bytes of the PGN.
* From the third byte from right we extract only 2 bits,
* because a PGN has only 18 bits. */
J1939Tp_PgnType pgn_byte1 = pgn & 0x000000FFu; /* first byte */
J1939Tp_PgnType pgn_byte2 = pgn & 0x0000FF00u; /* second byte */
J1939Tp_PgnType pgn_byte3 = pgn & 0x00030000u; /* 2 LSB of 3rd byte */
/* Revert the byte order as J1939 specifies little endian byte order */
PgnBytes[0] = (uint8) (pgn_byte1 >> 0);
PgnBytes[1] = (uint8) (pgn_byte2 >> 8);
PgnBytes[2] = (uint8) (pgn_byte3 >> 16);
}
/*----------------------------------------------------------------------------*/
/*------------------[Extract PGN from byte array]-----------------------------*/
/**
* @brief Extract the 18 bit PGN value from the three bytes array PgnBytes.
*
*
* @param PgnBytes Array of 3 bytes storing the PGN in little endian order.
* Because the PGN is a 18 bit value, the 6 most significant
* bits of the last (third) byte are discarded.
* @return The parameter group number stored in PgnBytes
*
* @see J1939Tp_Internal_SetPgn
*/
static inline J1939Tp_PgnType J1939Tp_Internal_GetPgn(uint8 PgnBytes[3])
{
/* Extract the bytes from the byte array */
J1939Tp_PgnType byte1 = (J1939Tp_PgnType) PgnBytes[0];
J1939Tp_PgnType byte2 = (J1939Tp_PgnType) PgnBytes[1];
J1939Tp_PgnType byte3 = (J1939Tp_PgnType) PgnBytes[2];
/* Extract only the last 2 bits from the last byte.
* This byte becomes the first one of the 18 bit PGN */
byte3 = ( byte3 & 0x03 );
/* Shift bytes to the right positions */
byte3 = ( byte3 << 16 );
byte2 = ( byte2 << 8 );
/* Invert bytes */
J1939Tp_PgnType pgn = byte3 | byte2 | byte1;
return pgn;
}
/*----------------------------------------------------------------------------*/
static inline J1939Tp_Internal_PgInfoType* J1939Tp_GetPgInfo(const J1939Tp_PgType* Pg) {
J1939Tp_Internal_PgInfoType* pgInfoPtr = NULL_PTR;
if (Pg != NULL_PTR)
{
pgInfoPtr = &(pgInfos[Pg - J1939Tp_ConfigPtr->Pgs]);
}
return pgInfoPtr;
}
/*------------------[Reset channel AI]----------------------------------------*/
/**
* @brief Reset the channels metadata (addressing information AI).
*
* The metadata contains parts of the CanId or the entire CanId used to transfer
* an SDU or PDU. The metadata is provided at runtime as 0 to 4 bytes appended
* to the actual data and contains the source address, destination address and
* priority.
*
* This function sets the protocol and addressing information of a channel to
* their default values. It does not change internal timers.
*/
static inline
void J1939Tp_Internal_Reset_Channel_Metadata
(
J1939Tp_Internal_ChannelInfoType* channelInfo
)
{
if (channelInfo != NULL_PTR)
{
/* Reset the setup protocol */
if (channelInfo->ChannelConfPtr != NULL_PTR)
{
channelInfo->Protocol = channelInfo->ChannelConfPtr->Protocol;
}
channelInfo->SourceAddress = J1939TP_RESERVED;
channelInfo->DestinationAddress = J1939TP_RESERVED;
channelInfo->Priority = J1939TP_DEFAULT_PRIORITY;
}
}
/*------------------[Set channel MetaData]------------------------------------*/
/**
* @brief Set the addressing information (MetaData) of channel according to the
* provided metadata (addressing information and priority).
*
* This functions first resets all channel metadata.
* It does not modify the channel state (timer etc).
*
* @param[out] channelInfo Channel information at runtime.
* @param[in] metadata Buffer storing the metadata.
* @param[in] metadatalength Size of buffer metadata.
*/
static
void J1939Tp_Internal_Set_Channel_Metadata
(
J1939Tp_Internal_ChannelInfoType* channelInfo,
uint8 metadata[],
uint8 metadatalength
)
{
uint8 destination_address = 0;
/* First reset the channel metadata so we have a clean channel */
J1939Tp_Internal_Reset_Channel_Metadata(channelInfo);
if (channelInfo != NULL_PTR && metadata != NULL_PTR && metadatalength > 0)
{
/* Set the source address */
if (metadatalength > METADATA_SA)
{
channelInfo->SourceAddress = metadata[METADATA_SA];
}
/* Set the destination address */
if (metadatalength > METADATA_DA)
{
destination_address = metadata[METADATA_DA];
channelInfo->DestinationAddress = destination_address;
/** @req SWS_J1939Tp_00039 */
/* Set dynamic protocol according to the destination address */
if (destination_address == BAM_DESTINATION_ADDRESS)
{
channelInfo->Protocol = J1939TP_PROTOCOL_BAM;
}
else
{
channelInfo->Protocol = J1939TP_PROTOCOL_CMDT;
}
}
else
{
/* No protocol specified, use the setup one */
channelInfo->Protocol = channelInfo->ChannelConfPtr->Protocol;
}
/* Set the priority */
if (metadatalength > METADATA_PRIORITY)
{
channelInfo->Priority = metadata[METADATA_PRIORITY];
}
}
}
/*------------------[Copy MetaData into buffer]-------------------------------*/
/**
* @brief Copy the channel's addressing information into the specified metadata
* buffer.
*
* Depending on the parameter metadatalength, which specifies the size of the
* metadata buffer, different parts of the addressing information are copied:
* - 1: source address
* - 2: source address, destination address
* - 3: source address, destination address, priority
*
* @param channelInfo Channel where to copy the addressing information from.
* @param metadata Buffer where to copy the addressing information.
* @param metadatalength Buffer length.
*
* @note The parameter metadatalength should be the configuration parameter
* MetaDataLength.
*/
static inline
void J1939Tp_Internal_Copy_Channel_Metadata
(
J1939Tp_Internal_ChannelInfoType* channelInfo,
uint8 metadata[],
uint8 metadatalength
)
{
if (channelInfo != NULL_PTR && metadata != NULL_PTR && metadatalength > 0)
{
if (metadatalength > METADATA_SA)
{
metadata[METADATA_SA] = channelInfo->SourceAddress;
}
if (metadatalength > METADATA_DA)
{
metadata[METADATA_DA] = channelInfo->DestinationAddress;
}
if (metadatalength > METADATA_PRIORITY)
{
metadata[METADATA_PRIORITY] = channelInfo->Priority;
}
}
}
/*------------------[Reset channel]-------------------------------------------*/
/**
* @brief Reset the state of a channel.
*
* This functions stops the channel timer, sets its state to idle and resets its
* metadata (addressing information).
*
* @param channel Channel to reset.
*/
static inline
void J1939Tp_Internal_Reset_Channel(J1939Tp_Internal_ChannelInfoType * channel)
{
if (channel != NULL_PTR)
{
if (channel->TxState != NULL_PTR)
{
channel->TxState->State = J1939TP_TX_IDLE;
J1939Tp_Internal_StopTimer(&(channel->TxState->TimerInfo));
}
if (channel->RxState != NULL_PTR)
{
channel->RxState->State = J1939TP_RX_IDLE;
J1939Tp_Internal_StopTimer(&(channel->RxState->TimerInfo));
}
J1939Tp_Internal_Reset_Channel_Metadata(channel);
}
}
/*------------------[Metadata matches channel AI]-----------------------------*/
/**
* @brief Returns true if the specified metadata content equals the addressing
* information of the specified channel.
*
* Depending on the parameter metadatalength, both source and destination
* addresses or only source address or no address are compared with the channels
* address fields. If metadatalength is zero, the functions returns true.
*
* If the specified packet type is flow control (reverse CM), then the source
* address in the metadata buffer is compared with the destination address of
* the channel and the destination address in the metadata buffer is compared
* with the source address of the channel. This is because the flow control
* messages are received on transmission channels and their addressing
* information is reversed.
*
* The layout of the addressing information in the buffer metadata is specified
* in item SWS_J1939Tp_00198 of the J1939Tp specification. See also figure in
* J1939Tp_Internal_Packets.h.
*
* @param metadata Buffer containing metadata (addressing information).
* @param metadatalength Size in bytes of the buffer metadata.
* @param packetType Packet type of the received PDU.
* @param channel Channel whose addressing information to compare.
*
* @retval true The channels addressing information (source and destination
* address) matches the one specified in buffer metadata. If the
* parameter metadatalength is zero, the the function also
* returns true.
* @retval false Source address or destination address does not match.
*/
static
boolean J1939Tp_Internal_Metadata_Matches_Channel
(
uint8 metadata[],
uint8 metadatalength,
J1939Tp_RxPduType packetType,
J1939Tp_Internal_ChannelInfoType* channel
)
{
boolean match = true;
uint8 source_address = 0;
uint8 destination_address = 0;
if (metadatalength > METADATA_SA)
{
source_address = metadata[METADATA_SA];
if (packetType == J1939TP_REVERSE_CM)
{
/* Control flow messages are received on transmission channels
* so we have to check if their source address matches the
* destination address of the channel. */
match = match &&
(source_address == channel->DestinationAddress);
}
else
{
match = match &&
(source_address == channel->SourceAddress);
}
}
if (metadatalength > METADATA_DA)
{
destination_address = metadata[METADATA_DA];
if (packetType == J1939TP_REVERSE_CM)
{
match = match &&
(destination_address == channel->SourceAddress);
}
else
{
match = match &&
(destination_address == channel->DestinationAddress);
}
}
return match;
}
/*------------------[Filter incoming packets]---------------------------------*/
/**
* @brief Indicate if a Pdu containing metadata should be further processed or
* if it should be ignored.
*
* This function analyses the metadata bytes appended to the actual data of the
* Pdu and checks if the pdu should be ignored or not.
* The metadata is supposed to begin with the 9th data byte and have the size
* <MetaDataLength> (setup at configuration time).
*
* For direct frames, pdus with no metadata setup and if the pdu length is
* less than 9 (8 bytes data + 1 byte metadata), this functions returns E_OK.
* If the pdu type is Connection Management (TP.CM) and the first data byte
* indicates a BAM or RTS message (which initiate a new reception session), the
* channels addressing information is setup and E_OK returned. Otherwise the
* appended metadata is checked against the channel's addressing information and
* if a missmatch is found, E_NOT_OK is returned.
*
* If the configuration parameter MetaDataLength is larger than the actual
* number of appended bytes, then the number of appended bytes is used as
* MetaDataLength. This allows dynamic metadatalength.
* Note: this behaviour is not specified but seems reasonable.
*
* @param RxPduId ID of the Pdu which has been received. This ID is used to
* extract the configuration parameter MetaDataLength.
* @param PduInfoPtr Pdu structure containing the Pdu length and a pointer to
* the received data. The data may contain metadata
* information. How large is the metadata is specified by the
* configuration parameter MetaDataLength of the Pdu.
* @param packetType Packet type of the received Pdu (CM, DT, direct or reverse
* CM).
* @param channel Channel where the Pdu was received. The channel is used to
* compare its addressing information with the one contained
* in PduInfoPtr->SduDataPtr.
*
* @retval E_OK The received Pdu should be further processed.
* @retval E_NOT_OK The received Pdu should be ignored because the previously
* specified metadata does not match the current addressing
* information of the channel or the extracted configuration
* parameter MetaDataLength is larger than the one indicated
* by the pdu length (PduInfoPtr->SduLength - 8). This
* indicated a missconfigured module.
*/
static Std_ReturnType J1939Tp_Internal_Filter_RxPdu_Metadata
(
PduIdType RxPduId,
PduInfoType* PduInfoPtr,
J1939Tp_RxPduType packetType,
J1939Tp_Internal_ChannelInfoType* channel
)
{
Std_ReturnType ret = E_NOT_OK;
uint8 appended_bytes = 0;
uint8* metadata = NULL_PTR;
boolean metadata_match = FALSE;
uint8 command = 0;
uint8 metadatalength = J1939Tp_Internal_Get_Pdu_MetaDataLength(channel->ChannelConfPtr, packetType);
if ((metadatalength == 0) || /* no metadata */
(packetType == J1939TP_DIRECT) || /* pdu setup as direct frame */
(PduInfoPtr->SduLength <= DIRECT_TRANSMIT_SIZE)
/* which also means no metadata */
)
{
/* It is ok to receive the pdu because there is no metadata to check or
* a direct frame has been received which is not segmented and not
* subject to any control. */
ret = E_OK;
}
else
{
/* how many bytes are actually appended to the data */
appended_bytes = PduInfoPtr->SduLength - DIRECT_TRANSMIT_SIZE;
/* if the pdu has less metadata bytes then configured, use this smaller
* value */
metadatalength = MIN(appended_bytes, metadatalength);
/* For TP frames, metadata is appended after the actual data */
metadata = &(PduInfoPtr->SduDataPtr[CM_SIZE]);
/* The command byte is used used to identify differet connection
* management messages */
command = PduInfoPtr->SduDataPtr[CM_BYTE_CONTROL];
/* Check if the metadata matches the channel addressing information */
metadata_match = J1939Tp_Internal_Metadata_Matches_Channel(metadata, metadatalength, packetType, channel);
switch (packetType)
{
/* Control Management frame */
case J1939TP_CM:
if ((command == BAM_CONTROL_VALUE) ||
(command == RTS_CONTROL_VALUE))
{
/* RTS and BAM initiate a new connection, so copy the
* addressing information from the metadata into the
* channel. Based on this information we will filter
* further messages. */
J1939Tp_Internal_Set_Channel_Metadata(channel, metadata, metadatalength);
ret = E_OK;
}
else
{
/* CM packets are Connection Abort messages from sender
* side if they are not BAM or RTS. Check their
* addressing information against the one previously saved.*/
if (metadata_match)
{
ret = E_OK;
}
}
break;
/* Data Packet and reverse CM*/
case J1939TP_DT:
case J1939TP_REVERSE_CM:
/* Data and reverse connection management frames (CTS,
* EndOfMsgAck, ConnAbort on receiver side) must match
* previously setup addressing information. */
if (metadata_match)
{
ret = E_OK;
}
break;
/* No such type */
default:
ret = E_NOT_OK;
break;
}
}
return ret;
}
/*------------------[Extract MetaDataLength of PduId from channel]------------*/
/**
* @brief Extract the configuration parameter MetaDataLength of a specific PDU
* based on the packet type transferred through the channel.
*
* Based on the PacketType argument, this functions reads from the channel
* configuration ChannelConfPtr the value of the MetaDataLength parameter of the
* Connection Management, Data transfer or Flow Control PDU of that channel.
* The dependency to the packet type is the following:
*
* J1939TP_CM - CmNPdu (Connection Management PDU)
* J1939TP_DT - DtNPdu (Data transfer PDU)
* J1939TP_REVERSE_CM - FcNPdu (Flow control PDU)
* default - 0 (no metadata)
*
* @param ChannelConfPtr Channel configuration.
* @param PacketType Packet type.
* @return MetaDataLength of the CmNPdu, DtNPdu, FcNPdu PDU of the channel or
* zero if the packet type is J1939TP_DIRECT.
*/
static inline
uint8 J1939Tp_Internal_Get_Pdu_MetaDataLength
(
const J1939Tp_ChannelType* ChannelConfPtr,
J1939Tp_RxPduType PacketType
)
{
uint8 metadatalength = 0;
switch (PacketType)
{
/* Connection Management frame */
case J1939TP_CM:
metadatalength = ChannelConfPtr->CmNPdu_MetaDataLength;
break;
/* Data transfer frame */
case J1939TP_DT:
metadatalength = ChannelConfPtr->DtNPdu_MetaDataLength;
break;
/* Flow control frame */
case J1939TP_REVERSE_CM:
metadatalength = ChannelConfPtr->FcNPdu_MetaDataLength;
break;
/* Default: no metadatalength */
default:
metadatalength = 0;
break;
}
metadatalength = MIN(metadatalength, METADATALENGTH_MAX);
return metadatalength;
}
/*------------------[Extract PduId from channel]------------------------------*/
/**
* @brief Extract the PduId used to transmit a packet based on the packet type.
*
* The different kinds of packets are being sent using different PduIds which
* are setup for the channel during configuration. Control Management packets
* are sent using the CmNPdu PduId, Control Flow messages are sent using the
* FcNPdu PduId and Data transfer messages are being sent using the DtNPdu
* PduId.
*
* This function inspects the packet type argument PacketType and returns the
* appropriate PduId stored in the channel configuration at the address
* ChannelConfPtr.
*
* @param ChannelConfPtr Channel configuration storing the setup PduIds.
* @param PacketType Packet type being used. The value J1939TP_DIRECT is
* ignored because the PduIds for direct frames are
* stored in the Parameter Group configuration structure
* and not in the channel.
*
* @return Appropriate PduId for the packet type.
*/
static inline
PduIdType J1939Tp_Internal_Get_Pdu
(
const J1939Tp_ChannelType* ChannelConfPtr,
J1939Tp_RxPduType PacketType
)
{
PduIdType pdu = 0;
switch (PacketType)
{
case J1939TP_CM:
pdu = ChannelConfPtr->CmNPdu;
break;
case J1939TP_DT:
pdu = ChannelConfPtr->DtNPdu;
break;
case J1939TP_REVERSE_CM:
pdu = ChannelConfPtr->FcNPdu;
break;
default:
break;
}
return pdu;
}
|
2301_81045437/classic-platform
|
communication/J1939Tp/src/J1939Tp.c
|
C
|
unknown
| 131,384
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.1.2 */
#ifndef J1939TP_INTERNAL_H_
#define J1939TP_INTERNAL_H_
#include "J1939Tp_Internal_Packets.h"
#include "J1939Tp_ConfigTypes.h"
#include "ComStack_Types.h"
#define PGN_BYTE_COUNT 3
/** Service Ids */
#define J1939TP_TRANSMIT_ID 0x05
#define J1939TP_INIT_ID 0x01
/** Error Codes */
/* !req SWS_J1939Tp_00115 */
#define J1939TP_E_PARAM_ID 0x01
#define J1939TP_E_UNINIT 0x20
#define J1939TP_E_REINIT 0x21
#define J1939TP_PACKET_SIZE 7
/** @req J1939TP0019 */
/** @req SWS_J1939Tp_00019 */
typedef enum {
J1939TP_ON,
J1939TP_OFF
} J1939Tp_Internal_GlobalStateType;
/** @brief State of a timer of type J1939Tp_Internal_TimerType:
* expired or not expired */
typedef enum {
J1939TP_EXPIRED,
J1939TP_NOT_EXPIRED
} J1939Tp_Internal_TimerStatusType;
/**
* @brief State description of a transmission channel.
*/
typedef struct {
/** @brief Channel state (idle, waiting etc).
* @note The type of this field is defined in J1939Tp_ConfigTypes.h. */
J1939Tp_Internal_TxChannelStateType State;
/** @brief Timer used to detect timeouts. */
J1939Tp_Internal_TimerType TimerInfo;
/** @brief How many data frames did we already sent?
* @details A message has been fully transmitted when
* SentDtCount * 'bytes per message' equals TotalMessageSize. */
uint8 SentDtCount;
/** @brief How many DT packets to send before waiting for another CTS
* message.
* @details A CTS message specifies how many packets (TP.DT frames) can the
* receiver node receive at a time. This is the number we store in
* this field. After sending that many packets, we wait for
* another CTS. */
uint8 DtToSendBeforeCtsCount;
/** @brief Total message size in bytes. */
J1939Tp_Internal_DtPayloadSizeType TotalMessageSize;
/** @brief ID of the SDU transmitted through the channel.
* @details This ID points to some PDU inside the PduR module. */
PduIdType PduRPdu;
/** @brief Parameter Group transmitted through this channel. */
const J1939Tp_PgType* CurrentPgPtr;
} J1939Tp_Internal_TxChannelInfoType;
/**
* @brief State description of a reception channel and related metadata
* like timer, number of received data frames and expected message size.
*/
typedef struct {
/** @brief State of the reception channel.
* @note The type of this field is defined in J1939Tp_ConfigTypes.h.
*/
J1939Tp_Internal_RxChannelStateType State;
/** @brief Timer used to detect timeouts. */
J1939Tp_Internal_TimerType TimerInfo;
/** @brief Number of received Data Transfer (DT) messages.
* @details A message is fully received when ReceivedDtCount equals
* DtToReceiveCount.
* @note The number of packets to receive is specified in the RTS message.
*/
uint8 ReceivedDtCount;
/** @brief Number of expected Data Transfer (DT) messages */
uint8 DtToReceiveCount;
/** @brief Total size of message to receive. */
J1939Tp_Internal_DtPayloadSizeType TotalMessageSize;
/** @brief Parameter Group received through the channel. */
const J1939Tp_PgType* CurrentPgPtr;
} J1939Tp_Internal_RxChannelInfoType;
/**
* @brief Runtime information about a communication channel.
*
* This structure stores the runtime information about a communication channel.
*
* This structure adds to a channel structure information about its transmission
* or reception state, like number of packets to send resp. receive, total
* message size and how many packets were received resp. transmitted.
* In order to be able to store generic state information about a channel, two
* state-structures were added: one for the transmission state and one for the
* reception state. If this is transmission channel, its state is stored ar the
* address pointed to by the field TxState, otherwise at the address pointed to
* by RxState.
*
* @note In order to know if this is a transmission or reception channel, you
* inquire the field Direction of the channel pointer. Example: to read
* the total message size transmitted through this channel no matter if
* this is a transmission or reception channel:
* @code
* J1939Tp_Internal_ChannelInfoType* channelInfo = ...;
* J1939Tp_Internal_DtPayloadSizeType messageSize = 0;
*
* if (channelInfo->Direction == J1939TP_RX) {
* // reception channel
* messageSize = channelInfo->RxState->TotalMessageSize;
* } else if (channelInfo->Direction == J1939TP_TX) {
* // trasmission channel
* messageSize = channelInfo->TxState->TotalMessageSize;
* }
* @endcode
*
*/
typedef struct {
/** @brief Setup channel information. */
const J1939Tp_ChannelType* ChannelConfPtr;
/** @brief Channel state if this is a transmission channel.
* @note setup in init */
J1939Tp_Internal_TxChannelInfoType* TxState;
/** @brief Channel state if this is a reception channel.
* @note setup in init */
J1939Tp_Internal_RxChannelInfoType* RxState;
/*--------[Metadata support]--------------------------*/
/* Each of the following fields store one entry in the metadata buffer.
* The metadata, which is appended to the data of a PDU or SDU contains
* parts of or the entire CAN Id used by the underlying CanIf.
* These fields are changed at runtime based on the provided metadata.
*/
/**
* @brief Dynamic protocol, setup at runtime.
* @details For Sdus with metadata, J1939Tp inspects at runtime the
* destination address stored in the metadata and, based on this
* address, chooses the appropriate protocol version (BAM for 0xFF,
* CMDT otherwise). This is the dynamic protocol stored in this
* field. The initial value of this field is the same as that of
* field ChannelConfPtr->Protocol.
*/
J1939Tp_ProtocolType Protocol;
/** @brief Source address provided in the metadata. */
uint8 SourceAddress;
/** @brief Destination address provided in the metadata. */
uint8 DestinationAddress;
/** @brief Priority provided in the metadata. */
uint8 Priority;
} J1939Tp_Internal_ChannelInfoType;
typedef enum {
J1939TP_PG_TX_IDLE,
J1939TP_PG_TX_WAIT_DIRECT_SEND_CANIF_CONFIRM,
} J1939Tp_Internal_PgDirectState;
/** @brief Metadata describing a transferred parameter group (PG).
*
* This structure adds more information to a J1939Tp_PgType structure
* (Parameter Group description): on which channel is the PG transmitted resp.
* received, transmission state and a timer used in case of direct transmission.
*/
typedef struct {
/** @brief Channel used to transmit the PG. */
J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr;
/** @brief Transferred parameter group. */
const J1939Tp_PgType* PgConfPtr;
/** @brief State when direct sending.
* @details For direct transmission of PGs with at most 8 bytes of data, the transmission
* state is stored directly in the PG info and not in the enclosing channel.
* @note Direct sending occurs when the PG data is less equal 8 bytes. */
J1939Tp_Internal_PgDirectState TxState;
/** @brief Timer structure used to monitor timeout of direct transmissions.
* @details When using direct transmission, we use this timer to monitor timeout.
* When using segmented transmission (BAM or CMDT) we use the timer in the
* transmission or reception state of the channel. */
J1939Tp_Internal_TimerType TimerInfo;
} J1939Tp_Internal_PgInfoType;
typedef struct {
J1939Tp_Internal_GlobalStateType State;
} J1939Tp_Internal_GlobalStateInfoType;
typedef uint8 J1939Tp_Internal_ControlByteType;
static inline uint8 J1939Tp_Internal_GetPf(J1939Tp_PgnType pgn);
static inline Std_ReturnType J1939Tp_Internal_ValidatePacketType(const J1939Tp_RxPduInfoType* RxPduInfo);
static inline J1939Tp_Internal_ChannelInfoType* J1939Tp_Internal_GetChannelState(const J1939Tp_RxPduInfoType* RxPduInfo);
static inline const J1939Tp_ChannelType* J1939Tp_Internal_GetChannel(const J1939Tp_RxPduInfoType* RxPduInfo);
static inline void J1939Tp_Internal_RxIndication_Dt(PduInfoType* PduInfoPtr, J1939Tp_Internal_ChannelInfoType* Channel);
static inline void J1939Tp_Internal_RxIndication_Cm(PduInfoType* PduInfoPtr, J1939Tp_Internal_ChannelInfoType* Channel);
static inline void J1939Tp_Internal_RxIndication_ReverseCm(PduInfoType* PduInfoPtr, J1939Tp_Internal_ChannelInfoType* Channel);
static inline void J1939Tp_Internal_RxIndication_Direct(PduInfoType* PduInfoPtr, const J1939Tp_RxPduInfoType* RxPduInfoPtr);
Std_ReturnType J1939Tp_ChangeParameterRequest(PduIdType SduId, TPParameterType Parameter, uint16 value);
static inline void J1939Tp_Internal_TxConfirmation_RxChannel(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr, const J1939Tp_RxPduInfoType* RxPduInfo);
static inline boolean J1939Tp_Internal_IsDtPacketAlreadySent(uint8 nextPacket, uint8 totalPacketsSent);
static inline Std_ReturnType J1939Tp_Internal_GetRxPduRelationsInfo(PduIdType RxPdu,const J1939Tp_RxPduInfoRelationsType** RxPduInfo);
static inline Std_ReturnType J1939Tp_Internal_GetPgFromPgn(const J1939Tp_ChannelType* channel, J1939Tp_Internal_PgnType Pgn, const J1939Tp_PgType** Pg);
static inline boolean J1939Tp_Internal_IsLastDt(J1939Tp_Internal_RxChannelInfoType* rxPgInfo);
static inline void J1939Tp_Internal_TxConfirmation_TxChannel(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr,const J1939Tp_RxPduInfoType* RxPduInfo);
static inline boolean J1939Tp_Internal_IsLastDtBeforeNextCts(J1939Tp_Internal_RxChannelInfoType* rxChannelInfo);
static inline uint16 J1939Tp_Internal_GetRtsMessageSize(PduInfoType* pduInfo);
static inline boolean J1939Tp_Internal_WaitForCts(J1939Tp_Internal_TxChannelInfoType* TxChannelState);
static inline boolean J1939Tp_Internal_LastDtSent(J1939Tp_Internal_TxChannelInfoType* TxPgState);
static inline J1939Tp_Internal_TimerStatusType J1939Tp_Internal_IncAndCheckTimer(J1939Tp_Internal_TimerType* TimerInfo);
static inline uint8 J1939Tp_Internal_GetDtDataSize(uint8 currentSeqNum, uint8 totalSize);
static inline Std_ReturnType J1939Tp_Internal_SendBam(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr,const PduInfoType* TxInfoPtr);
static inline Std_ReturnType J1939Tp_Internal_SendDt(J1939Tp_Internal_ChannelInfoType* Channel);
static inline Std_ReturnType J1939Tp_Internal_SendRts(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr, const PduInfoType* TxInfoPtr, uint8 MaxNumPackets);
static inline void J1939Tp_Internal_SendEndOfMsgAck(J1939Tp_Internal_ChannelInfoType* Channel);
static inline void J1939Tp_Internal_SendCts(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr, J1939Tp_PgnType Pgn, uint8 NextPacketSeqNum,uint8 NumPackets);
static inline void J1939Tp_Internal_SendConnectionAbort(J1939Tp_Internal_ChannelInfoType* ChannelInfoPtr, J1939Tp_RxPduType packetType, J1939Tp_PgnType Pgn, uint8 Reason);
static inline void J1939Tp_Internal_StartTimer(J1939Tp_Internal_TimerType* TimerInfo,uint16 TimerExpire);
static inline void J1939Tp_Internal_StopTimer(J1939Tp_Internal_TimerType* TimerInfo);
static inline void J1939Tp_Internal_SetPgn(uint8* PgnBytes,J1939Tp_PgnType pgn );
static inline J1939Tp_PgnType J1939Tp_Internal_GetPgn(uint8 PgnBytes[3]);
static inline Std_ReturnType J1939Tp_Internal_GetPg(PduIdType SduId, J1939Tp_Internal_PgInfoType** PgInfo);
static inline uint8 J1939TP_Internal_GetNumDtPacketsToSend(PduLengthType messageSize);
static inline Std_ReturnType J1939Tp_Internal_DirectTransmit(const PduInfoType* TxInfoPtr, J1939Tp_Internal_PgInfoType* PgInfo);
static inline J1939Tp_Internal_PgInfoType* J1939Tp_GetPgInfo(const J1939Tp_PgType* Pg);
static inline void J1939Tp_Internal_Reset_Channel(J1939Tp_Internal_ChannelInfoType * channel);
static inline PduIdType J1939Tp_Internal_Get_Pdu(const J1939Tp_ChannelType* ChannelConfPtr, J1939Tp_RxPduType PacketType);
/*------------[Functions related to metadata support]---------------------------------------------*/
static inline void J1939Tp_Internal_Reset_Channel_Metadata(J1939Tp_Internal_ChannelInfoType* channelInfo);
static void J1939Tp_Internal_Set_Channel_Metadata(J1939Tp_Internal_ChannelInfoType* channelInfo, uint8 metadata[], uint8 metadatalength);
static inline void J1939Tp_Internal_Copy_Channel_Metadata(J1939Tp_Internal_ChannelInfoType* channelInfo, uint8 metadata[METADATALENGTH_MAX], uint8 metadatalength);
static Std_ReturnType J1939Tp_Internal_Filter_RxPdu_Metadata
(PduIdType RxPduId, PduInfoType* PduInfoPtr, J1939Tp_RxPduType packetType, J1939Tp_Internal_ChannelInfoType* channel);
static inline uint8 J1939Tp_Internal_Get_Pdu_MetaDataLength(const J1939Tp_ChannelType* ChannelConfPtr, J1939Tp_RxPduType packetType);
static boolean J1939Tp_Internal_Metadata_Matches_Channel(uint8 metadata[], uint8 metadatalength, J1939Tp_RxPduType packetType, J1939Tp_Internal_ChannelInfoType* channel);
#endif
|
2301_81045437/classic-platform
|
communication/J1939Tp/src/J1939Tp_Internal.h
|
C
|
unknown
| 14,551
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/**
* @file J1939Tp_Internal_Packets.h
* @brief Structure of the J1939 messages used to manage the transmission of
* segmented data.
*
* The J1939 communication protocol transfers parameter groups with data
* (payload) larger than 8 bytes by segmenting the data into packets. The
* segmented data is sent by two means: either as broadcasted messages with
* no connection management (BAM transmission), or by means of peer-to-peer
* managed connections (CMDT transmission).
* Both trasmission methods use only two parameter groups (transport frames):
* - TP.CM (Transport Protocol - Connection Management) with PGN 0x00EC00,
* used to announce, initiate, manage and close connections
* - TP.DT (Transport Protocol - Data Transfer) with PGN 0x00EB00, used to
* transfer the actual data of the large parameter groups. The payload of
* this transport frame contains a sequence number in the first byte and
* the actual data in the remaining 7 bytes.
*
* The connection management is done by filling the 8 bytes data (payload) of
* the TP.CM parameter group with a special control code (command) in the first
* byte and the arguments to that command in the remaining 7 bytes. These codes
* correspond to different messages:
* - BAM: announce the transmission of a broadcasted message
* (after sending this message, data is sent in defined
* intervals of time without further announcement and without
* to wait for receive confirmations)
* - RTS: request to send
* (sender initiates the peer-to-peer connection)
* - CTS: clear to send
* (receiver is ready for reception)
* - EOMAck: Acknowledge the End of Message
* (receiver confirms the reception of the entire message)
* - Abort: Abort Connection.
*
*
* This file defines the following items:
* - Parameter Group Numbers (PGN) of the TP.CM and TP.DT parameter groups
* - Control codes identifying the management messages
* - Structure of the control messages. This structure is given by defining
* the indexes of the control byte and the indexes of the arguments to
* that command inside the 8 byte data of the J1939 TP.CM frame.
*
* Example of using the definitions of this file:
* @code
* uint8 connAbortData[CONNABORT_SIZE];
* connAbortData[CM_BYTE_CONTROL] = CONNABORT_CONTROL_VALUE;
* connAbortData[CONNABORT_BYTE_REASON] = CONNABBORT_REASON_NO_RESSOURCES;
* connAbortData[CONNABORT_BYTE_SAE_ASSIGN_2] = RESERVED;
* connAbortData[CONNABORT_BYTE_SAE_ASSIGN_3] = RESERVED;
* connAbortData[CONNABORT_BYTE_SAE_ASSIGN_4] = RESERVED;
* connAbortData[CM_PGN_BYTE_1] = 0xEE;
* connAbortData[CM_PGN_BYTE_2] = 0xFE
* connAbortData[CM_PGN_BYTE_3] = 0x00;
* @endcode
*/
#ifndef J1939TP_PACKETS_INTERNAL_H_
#define J1939TP_PACKETS_INTERNAL_H_
/** @brief Data size of mesages transmitted directly. */
#define DIRECT_TRANSMIT_SIZE 8
/** @brief Maximum data size of a message in bytes.
* @details This number equals 7 * 255, where 255 is the maximal sequence
* number of a data frame and 7 the number of bytes in a single frame.
* @note Sequence numbers range from 1 to 255. */
#define J1939TP_MAX_DATA_LENGTH 1785u
/*==================[Connection Management Frame]=============================*/
/** The Parameter Group Number (PGN) of a Connection Management message.
* This number is 0x00EC00 and takes 18 bits inside the CAN ID. */
#define CM_PGN_VALUE_1 0x00
#define CM_PGN_VALUE_2 0xEC
#define CM_PGN_VALUE_3 0x00
/** Indexes inside the data of a Connection Management frame (TP.CM) where the
* Parameter Group Number (PGN) of the transferred message is stored.
* This number takes three bytes in little endian order. In order to get the
* numerical value of PGN, the byte values must be inverted.
*/
#define CM_PGN_BYTE_1 5 /* least significant byte */
#define CM_PGN_BYTE_2 6
#define CM_PGN_BYTE_3 7 /* most significant byte of the PGN*/
/**
* @brief Index of the control byte (command) inside the TP.CM frame's data.
* @details This control byte distinguishes between RTS, CTS, EndOfMsgAck, Abort
* and BAM messages.
*/
#define CM_BYTE_CONTROL 0
/**
* @brief Size of a connection management message.
*
* @details All connection management messages have the same size. They are
* identified by consulting the first byte.
*/
#define CM_SIZE 8
/*--------[Connection Management: Clear To Send (CTS) message]----------------*/
/* The Clear To Send command is sent by the receiver node as response to a RTS
* request when the receiver node is ready to accept incoming data. The content
* of the CTS message contains information about how many packets, the next
* packet number and the PGN of the transferred PG. */
/** @brief Data size in bytes of the CTS message. */
#define CTS_SIZE CM_SIZE
/** @brief Index of the CTS-command. */
#define CTS_BYTE_CONTROL CM_BYTE_CONTROL
/** @brief Total number of packets ready to receive (block size)
* before sending another CTS message.
* @note The value stored at this index should not be larger
* than the one stored at index 4 in RTS (max blocksize).
* @see SWS Item ECUC_J1939Tp_00061 */
#define CTS_BYTE_NUM_PACKETS 1
/** @brief Next expected packet number. */
#define CTS_BYTE_NEXT_PACKET 2
/** @brief Reserved byte index. Must be filled with 0xFF. */
#define CTS_BYTE_SAE_ASSIGN_1 3
/** @brief Reserved byte index. Must be filled with 0xFF. */
#define CTS_BYTE_SAE_ASSIGN_2 4
/** @brief Indexes of the Parameter Group Number of the transferred message.
* This number takes three bytes in little endian order. */
#define CTS_BYTE_PGN_1 CM_PGN_BYTE_1
#define CTS_BYTE_PGN_2 CM_PGN_BYTE_2
#define CTS_BYTE_PGN_3 CM_PGN_BYTE_3
/** @brief First expected packet number. */
#define CTS_START_SEQ_NUM 1
/** @brief Command code of the CTS message. */
#define CTS_CONTROL_VALUE 17
/*--------[Connection Management: Broadcast Announce Message (BAM)]-----------*/
/* Following definitions define the indexes used in a BAM announce message.
* The message is stored in the data segment of a TP.CM frame.
* BAM is used to announce the transmission of non-managed multicast PG.
*/
/** @brief Size in bytes of entire BAM message data. */
#define BAM_SIZE CM_SIZE
/** @brief Index of the control byte. */
#define BAM_BYTE_CONTROL CM_BYTE_CONTROL
/** @brief Total message size which will be trasmitted. */
#define BAM_BYTE_LENGTH_1 1
#define BAM_BYTE_LENGTH_2 2
/** @brief Number of packets the sender wants to transmit.
* This is the number of TP.DT frames needed to send the entire PG data.
*/
#define BAM_BYTE_NUM_PACKETS 3
/** @brief Reserved index. Should be filled with 0xFF. */
#define BAM_BYTE_SAE_ASSIGN 4
/** Indexes of the PGN */
#define BAM_BYTE_PGN_1 CM_PGN_BYTE_1
#define BAM_BYTE_PGN_2 CM_PGN_BYTE_2
#define BAM_BYTE_PGN_3 CM_PGN_BYTE_3
/** @brief Command code of the BAM mesage.
* @details This is the value to be set in the first data byte. */
#define BAM_CONTROL_VALUE 32
/** @brief Destination address used for the BAM protocol */
#define BAM_DESTINATION_ADDRESS 0xFFu
/*--------[Connection Management: Request To Send (RTS)]----------------------*/
/* Following definitions define the indexes used in a RTS message.
* The RTS message is stored in the data segment of a TP.CM frame.
* RTS is used to initiate (request) a peer-to-peer connection with a specific
* node.
*/
/** @brief Size in bytes of entire RTS message. */
#define RTS_SIZE CM_SIZE
/** @brief Index of the control byte. */
#define RTS_BYTE_CONTROL CM_BYTE_CONTROL
/** @brief Total message size. */
#define RTS_BYTE_LENGTH_1 1
#define RTS_BYTE_LENGTH_2 2
/** @brief Number of packets (data frames) the sender wants to transmit.*/
#define RTS_BYTE_NUM_PACKETS 3
/** @brief Maximum number of packets (DT frames) the transmitter node is ready
* to send before waiting for another CTS message (block size).
* @see CTS_BYTE_NUM_PACKETS
* @see SWS Item ECUC_J1939Tp_00122. */
#define RTS_BYTE_MAX_NUM_PACKETS 4
/** Indexes of the PGN */
#define RTS_BYTE_PGN_1 CM_PGN_BYTE_1
#define RTS_BYTE_PGN_2 CM_PGN_BYTE_2
#define RTS_BYTE_PGN_3 CM_PGN_BYTE_3
/** @brief Command code of the RTS mesage.
* This is the value to be set in the first data byte. */
#define RTS_CONTROL_VALUE 16
/** @brief This special value tells the receiver of the RTS message that the
* number of packets it should declare within a CTS message has no upper
* limit i.e. the transmitting node can send any number of packets
* specified in the CTS message.
* This values is stored at index RTS_BYTE_MAX_NUM_PACKETS in the RTS
* message. */
#define RTS_MAX_NUM_PACKETS_VALUE 0xFFu
/*--------[Connection Management: End of Message Acknowledgment]--------------*/
/* This message is send by the receiver of a CMDT message to acknowledge the
* reception of the last data paket. Sending this message closes the connection
* with the sending node after successfully receiving all data packets.
*/
/** @brief Size of the ACK message. */
#define ENDOFMSGACK_SIZE CM_SIZE
/** @brief Index of the ACK control byte inside the TP.CM data. */
#define ENDOFMSGACK_BYTE_CONTROL CM_BYTE_CONTROL
/* The size of the aknowledged message takes the next two bytes after the
* control byte. This size is stored in little endian byte order. */
/** @brief LSB of the size of the acknowledged message. */
#define ENDOFMSGACK_BYTE_TOTAL_MSG_SIZE_1 1
/** @brief MSB of the size of the aknowledged message. */
#define ENDOFMSGACK_BYTE_TOTAL_MSG_SIZE_2 2
/** @brief Number of acknowledged packets. */
#define ENDOFMSGACK_BYTE_NUM_PACKETS 3
/** @brief Reserved byte. Should be filled with 0xFF. */
#define ENDOFMSGACK_BYTE_SAE_ASSIGN 4
/* The PGN of the acknowledged PG takes the next three byte and is stored in
* little endian byte order. */
/** @brief LSB of the acknowledged PGN. */
#define ENDOFMSGACK_BYTE_PGN_1 CM_PGN_BYTE_1
/** @brief Second byte of the acknowledged PGN. */
#define ENDOFMSGACK_BYTE_PGN_2 CM_PGN_BYTE_2
/** @brief MSB of the acknowledged PGN. */
#define ENDOFMSGACK_BYTE_PGN_3 CM_PGN_BYTE_3
/** @brief Value of the control byte of the End of Message Acknowledge message.
*/
#define ENDOFMSGACK_CONTROL_VALUE 19
/*--------[Connection Management: Connection Abort]---------------------------*/
/* The Connection Abort message is send by the receiver node to close or refuse
* a connection. */
/** @brief Size of the Connection Abort message. */
#define CONNABORT_SIZE CM_SIZE
/** @brief Index of the control byte of the Conn Abort message. */
#define CONNABORT_BYTE_CONTROL 0
/** @brief Index of the abort reason. */
#define CONNABORT_BYTE_REASON 1
/** @brief Reserved index. */
#define CONNABORT_BYTE_SAE_ASSIGN_2 2
/** @brief Reserved index. */
#define CONNABORT_BYTE_SAE_ASSIGN_3 3
/** @brief Reserved index. */
#define CONNABORT_BYTE_SAE_ASSIGN_4 4
/* The PGN of the PG whose transfer is being aborted takes the last three bytes
* of the abort message. The PGN is stored in little endian order. */
/** @brief LSM or the aborted PGN. */
#define CONNABORT_BYTE_PGN_1 CM_PGN_BYTE_1
/** @brief Second byte of the aborted PGN. */
#define CONNABORT_BYTE_PGN_2 CM_PGN_BYTE_2
/** @brief MSM or the aborted PGN. */
#define CONNABORT_BYTE_PGN_3 CM_PGN_BYTE_3
/** @brief Value of the control byte in a Connection Abort message. */
#define CONNABORT_CONTROL_VALUE 255
/*--------[Abort reasons]-----------------------------------------------------*/
/* Connection abort reasons used in the connection abort message. These values
* are used in the Connection Abort message. */
/** @brief Already engaged in one or more CMDT sessions with the requesting node
* and cannot open another session. */
#define CONNABORT_REASON_BUSY 1u
/** @brief Lacking system resources*/
#define CONNABORT_REASON_NO_RESOURCES 2u
/** @brief Timeout occurred. */
#define CONNABORT_REASON_TIMEOUT 3u
/** @brief CTS message received when data transfer is in progress. */
#define CONNABORT_REASON_CTS 4u
/** @brief Maximum retransmit request limit reached.
* @see item SWS_J1939Tp_00194 of the Autosar J1939 specification v4.1 */
#define CONNABORT_REASON_MAX_RETRY_LIMIT 5u
/** @brief Sequence number error occured during reception and retry support is
* disabled.
*
* This error happens when the sequence number of a received data packet does
* not match the expected sequence number.
* @note The sequence number is the first byte of a TP.DT message. */
#define CONNABORT_REASON_SEQUENCE_ERR 0xFFu
/*--------[Timeouts for a connection]-----------------------------------------*/
/* Connections can be aborted not only when a node sends the Connection Abort
* message, but also when a timeout occurs, either on the sender side or on the
* receiver side. The J1939 standard defines a few timouts which should be used
* in certain situations.
* All values are given in milliseconds */
/** @brief Minimum packet frequency when sending data packets with BAM. */
#define J1939TP_DT_BROADCAST_MIN_INTERVAL 50
/** @brief Response time.
* @details Maximal time needed by a node to process some data or control flow
* message. This is not the time a node waits for its communication
* partner, but the internal time needed by a node to process a
* request or indication.
* @see Figure 7-3 in Specification of a Transport Layer for SAE J1939,
* V1.3.0, R4.1 Rev 1.
*/
#define J1939TP_TR_TIMEOUT_MS 200
/** @brief Holding time.
* @details When the receiving node delays reception by sending an empty CTS
* message (wait frame, with number of packages set to 0) it must
* resend a new CTS message withing 500 ms in order to keep the
* connection alive. Relevant only for CMDT transmission.
*/
#define J1939TP_TH_TIMEOUT_MS 500
/** @brief Maximal elapsed time between reception of two data frames. */
#define J1939TP_T1_TIMEOUT_MS 750
/** @brief Maximal elapsed time after having sent the CTS message without
* receiving data.
*/
#define J1939TP_T2_TIMEOUT_MS 1250
/** @brief Maximal elapsed time after having sent the last data packet without
* receiving a new CTS or EndOfMessageACK message.
*/
#define J1939TP_T3_TIMEOUT_MS 1250
/** @brief Elapsed time after receiving a delaying CTS message (number of
* packets set to zero) without receiving a new CTS message.
* @note The receiver node can delay transmission of new data by sending a
* CTS message with the number of packets set to zero.
*/
#define J1939TP_T4_TIMEOUT_MS 1050
/*==================[Data Transfer Frame]=====================================*/
/* The Data Transfer Parameter Group with PGN 0x00EB00 is used to transfer the
* actual segmented data. The 8 byte data content of this PG contains the
* sequence number of the current data in the first byte and the data in the
* remaining 7 bytes. */
/* Parameter Group Number (PGN) of the Data Transfer PG. */
#define DT_PGN_VALUE_1 0x00
#define DT_PGN_VALUE_2 0xEB
#define DT_PGN_VALUE_3 0x00
/** @brief Data size of the TP.DT PG. */
#define DT_SIZE CM_SIZE
/** @brief Actual data in the TP.DT.
* First byte out of 8 is used for the sequence number. */
#define DT_DATA_SIZE 7
/** @brief Index of the sequence number in TP.DT data. */
#define DT_BYTE_SEQ_NUM 0
/* Symbolic values for the indexes of the 7 bytes of data in a TP.DT. */
#define DT_BYTE_DATA_1 1
#define DT_BYTE_DATA_2 2
#define DT_BYTE_DATA_3 3
#define DT_BYTE_DATA_4 4
#define DT_BYTE_DATA_5 5
#define DT_BYTE_DATA_6 6
#define DT_BYTE_DATA_7 7
/*==================[Metadata]================================================*/
/* Indexes of different components of a CAN Id inside the metadata buffer.
* The medatadata, which is appended to the regular Sdu data, contains 0 to 4
* bytes of the 29 bit CAN Id in little endian order, that is the last byte of
* the CAN Id is stored at index 0 inside the metadata buffer. How many bytes
* are stored is specified by the configuration parameter MetaDataLength.
* Here is the layout of a CAN Id for reference:
+---------------------------------------------------------------------------+
| 3 bit | 1 bit | 1 bit | 8 bit | 8 bit | 8 bit |
+---------------------------------------------------------------------------+
| priority | reserved | data page | PDU format | destination | source |
| | | | | address | address |
+---------------------------------------------------------------------------+
| metadata[3] | metadata[2] | metadata[1] | metadata[0] |
+---------------------------------------------------------------------------+
| CAN Id |
+---------------------------------------------------------------------------+
* See also SWS_J1939Tp_00198, Specification of a Transport Layer for SAE J1939,
* part of Autosar R4.1 and "A Comprehensible Guide to J1939" by Wilfried Voss.
*/
/** @brief Index of Source Address inside the metadata buffer. */
#define METADATA_SA 0
/** @brief Index of Destination Address inside the metadata buffer. */
#define METADATA_DA 1
/**
* @brief Index of priority inside the metadata buffer.
* @note The priority is stored in the 4th byte of the metadata (little endian
* order) and is left shifted by two bits. So when reading the priority
* one has to right shift the value 2 bits.
* See figure above.
*/
#define METADATA_PRIORITY 3
/** @brief Maximum value of the MetaDataLength configuration parameter of a Pdu.
* This is also the maximal size of the MetaData array which contains part of
* or Can Id or the whole Can Id. */
#define METADATALENGTH_MAX 4
/**
* @brief Default priority to use for metadata.
*
* The priority is an element of the Can Id stored in the metadata.
* According to the J1939 specification, the default priority of TP.CM and
* TP.DT parameter groups is 7. This number must be shifted 2 bits to left in
* order to match the CAN Id layout. See figure above. */
#define J1939TP_DEFAULT_PRIORITY (7 << 2)
/*==================[Other symbolic values]===================================*/
/** @brief Value of a reserved byte. */
#define J1939TP_RESERVED 0xFFu
#endif
|
2301_81045437/classic-platform
|
communication/J1939Tp/src/J1939Tp_Internal_Packets.h
|
C
|
unknown
| 21,391
|
#LdCom
obj-$(USE_LDCOM) += LdCom.o
obj-$(USE_LDCOM) += LdCom_Lcfg.o
obj-$(USE_LDCOM) += LdCom_PBcfg.o
vpath-$(USE_LDCOM) += $(ROOTDIR)/communication/LdCom/src
inc-$(USE_LDCOM) += $(ROOTDIR)/communication/LdCom/inc
|
2301_81045437/classic-platform
|
communication/LdCom/LdCom.mod.mk
|
Makefile
|
unknown
| 222
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LDCOM_H_
#define LDCOM_H_
/* @req 4.2.2/SWS_LDCOM_00002*/
#include "ComStack_Types.h"
#include "LdCom_Types.h"
#include "LdCom_Cbk.h"
/* General requirements */
#define LDCOM_VENDOR_ID 60u
#define LDCOM_MODULE_ID 49u
/* @req SWS_EthIf_00006 */
#define LDCOM_AR_RELEASE_MAJOR_VERSION 4u
#define LDCOM_AR_RELEASE_MINOR_VERSION 2u
#define LDCOM_AR_RELEASE_REVISION_VERSION 2u
#define LDCOM_AR_MAJOR_VERSION LDCOM_AR_RELEASE_MAJOR_VERSION
#define LDCOM_AR_MINOR_VERSION LDCOM_AR_RELEASE_MINOR_VERSION
#define LDCOM_AR_PATCH_VERSION LDCOM_AR_RELEASE_REVISION_VERSION
#define LDCOM_SW_MAJOR_VERSION 1u
#define LDCOM_SW_MINOR_VERSION 0u
#define LDCOM_SW_PATCH_VERSION 0u
#include "LdCom_Cfg.h"
// This is needed since the RTE is using signal names (needs attention when it comes to post build)
#include "LdCom_PBCfg.h"
/* @req 4.2.2/SWS_LDCOM_00018*/
#define LDCOM_E_PARAM 0x01u
#define LDCOM_E_UNINIT 0x02u
#define LDCOM_E_PARAM_POINTER 0x03u
#define LDCOM_E_INVALID_PDU_SDU_ID 0x04u
#define LDCOM_E_INVALID_SIGNAL_ID 0x05u
/** Service IDs */
#define LDCOM_SERVICE_ID_INIT 0x01u
#define LDCOM_SERVICE_ID_DE_INIT 0x02u
#define LDCOM_SERVICE_ID_GET_VERSION_INFO 0x03u
#define LDCOM_SERVICE_ID_TRANSMIT 0x05u
/* Callback notifications function service Ids */
#define LDCOM_SERVICE_ID_COPY_TX_DATA 0x43u
#define LDCOM_SERVICE_ID_TP_TX_CONFIRMATION 0x48u
#define LDCOM_SERVICE_ID_START_OF_RECEPTION 0x46u
#define LDCOM_SERVICE_ID_COPY_RX_DATA 0x44u
#define LDCOM_SERVICE_ID_TP_RX_INDICATION 0x45u
#define LDCOM_SERVICE_ID_RX_INDICATION 0x42u
#define LDCOM_SERVICE_ID_TX_CONFIRMATION 0x40u
#define LDCOM_SERVICE_ID_TRIGGER_TRANSMIT 0x41u
/* @req 4.2.2/SWS_LDCOM_00022*/
void LdCom_Init( const LdCom_ConfigType* config );
/* @req 4.2.2/SWS_LDCOM_00023*/
void LdCom_DeInit( void );
/* @req 4.2.2/SWS_LDCOM_00024*/
#if (LDCOM_VERSION_INFO_API == STD_ON)
void LdCom_GetVersionInfo( Std_VersionInfoType* versioninfo );
#endif
/* @req 4.2.2/SWS_LDCOM_00026*/
Std_ReturnType LdCom_Transmit( PduIdType Id, const PduInfoType* PduInfoPtr );
#endif /* LDCOM_H_ */
|
2301_81045437/classic-platform
|
communication/LdCom/inc/LdCom.h
|
C
|
unknown
| 3,210
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LDCOM_CBK_H_
#define LDCOM_CBK_H_
#include "ComStack_Types.h"
#include "LdCom_Types.h"
/* @req 4.2.2/SWS_LDCOM_00027*/
BufReq_ReturnType LdCom_CopyTxData( PduIdType id, const PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
/* @req 4.2.2/SWS_LDCOM_00028*/
void LdCom_TpTxConfirmation( PduIdType id, Std_ReturnType result );
/* @req 4.2.2/SWS_LDCOM_00029*/
BufReq_ReturnType LdCom_StartOfReception( PduIdType id, const PduInfoType* info, PduLengthType TpSduLength, PduLengthType* bufferSizePtr );
/* @req 4.2.2/SWS_LDCOM_00030*/
BufReq_ReturnType LdCom_CopyRxData( PduIdType id, const PduInfoType* info, PduLengthType* bufferSizePtr );
/* @req 4.2.2/SWS_LDCOM_00031*/
void LdCom_TpRxIndication( PduIdType id, Std_ReturnType result );
/* @req 4.2.2/SWS_LDCOM_00032*/
void LdCom_RxIndication( PduIdType RxPduId, const PduInfoType* PduInfoPtr );
/* @req 4.2.2/SWS_LDCOM_00056*/
void LdCom_TxConfirmation( PduIdType TxPduId );
/* @req 4.2.2/SWS_LDCOM_00033*/
Std_ReturnType LdCom_TriggerTransmit( PduIdType TxPduId, PduInfoType* PduInfoPtr );
#endif /* LDCOM_CBK_H_ */
|
2301_81045437/classic-platform
|
communication/LdCom/inc/LdCom_Cbk.h
|
C
|
unknown
| 1,884
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LDCOM_TYPES_H_
#define LDCOM_TYPES_H_
/* @req SWS_LDCOM_00020 */
#include "Std_Types.h"
#include "ComStack_Types.h"
/* Type of Lower layer for a given IPdu */
typedef enum {
LDCOM_IF,
LDCOM_TP
}LdComLowerApiType;
/* IPdu direction */
typedef enum {
LDCOM_RECEIVE,
LDCOM_SEND
}LdComIPduDirectionType;
typedef BufReq_ReturnType (*LdComCopyTxData)(const PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
typedef void (*LdComTpTxConfirmation)( Std_ReturnType result );
typedef BufReq_ReturnType (*LdComStartOfReception)( const PduInfoType* info, PduLengthType TpSduLength, PduLengthType* bufferSizePtr );
typedef BufReq_ReturnType (*LdComCopyRxData)( const PduInfoType* info, PduLengthType* bufferSizePtr );
typedef void (*LdComTpRxIndication)( Std_ReturnType result );
typedef void (*LdComRxIndication)( const PduInfoType* PduInfoPtr );
typedef void (*LdComTxConfirmation)(void);
typedef Std_ReturnType (*LdComTriggerTransmit)( PduInfoType* PduInfoPtr );
/* LdComIPdu config structure type */
typedef struct {
LdComStartOfReception LdComRxStartOfReceptionCbk; /* Callback for LdCom_StartOfReception */
LdComCopyRxData LdComCopyRxDataCbk; /* Callback for LdCom_CopyRxData */
LdComTpRxIndication LdComTpRxIndicationCbk; /* Callback for LdCom_TpRxIndication */
LdComCopyTxData LdComCopyTxDataCbk; /* Callback for LdCom_CopyTxData */
LdComTpTxConfirmation LdComTpTxConfirmationCbk; /* Callback for LdCom_TpTxConfirmation */
LdComRxIndication LdComRxIndicationCbk; /* Callback for LdCom_RxIndication */
LdComTriggerTransmit LdComTxTriggerTransmitCbk; /* Callback for LdCom_TriggerTransmit */
LdComTxConfirmation LdComTxConfirmationCbk; /* Callback for LdCom_TxConfirmation */
PduIdType LdComHandleId; /* Handle Id */
PduIdType LdComPdurPduId ; /* PduR Pdu Id for transmit */
LdComLowerApiType LdComLowerApi; /* Type of lower api */
LdComIPduDirectionType LdComIPduDir; /* Direction of IPdu */
}LdCom_IPduType;
typedef struct {
const LdCom_IPduType *LdComIPduCfg;
uint8 LdComIPduCnt;
}LdCom_ConfigType;
#endif /*LDCOM_TYPES_H_*/
|
2301_81045437/classic-platform
|
communication/LdCom/inc/LdCom_Types.h
|
C
|
unknown
| 3,011
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/*=================================[inclusions]======================================*/
/* General requirements */
/* @req 4.2.2/SWS_LDCOM_00051 */ /* LdCom_Lcfg.c and LdComPBcfg.c files are generated */
/* @req 4.2.2/SWS_LDCOM_00018 */ /* Development Error Types */
/* @req 4.2.2/SWS_LDCOM_00035 */ /* defines external interfaces, required to fulfill an optional functionality of the module */
/* @req 4.2.2/SWS_LDCOM_00020 */ /* ComStack_Types and Std_Types are included*/
/* @req 4.2.2/SWS_LDCOM_00052 */ /* LdCom_ConfigType implementation specific structure*/
/* @req 4.2.2/SWS_LDCOM_00036 */ /* Rte_LdComCbkCopyTxData, Large Data COM shall support Transport Protocol-like communication */
/* @req 4.2.2/SWS_LDCOM_00037 */ /* Rte_LdComCbkTpTxConfirmation, Large Data COM shall support Transport Protocol-like communication */
/* @req 4.2.2/SWS_LDCOM_00038 */ /* Rte_LdComCbkStartOfReception, Large Data COM shall support Transport Protocol-like communication */
/* @req 4.2.2/SWS_LDCOM_00039 */ /* Rte_LdComCbkCopyRxData, Large Data COM shall support Transport Protocol-like communication */
/* @req 4.2.2/SWS_LDCOM_00040 */ /* Rte_LdComCbkTpRxIndication, Large Data COM shall support Transport Protocol-like communication */
/* @req 4.2.2/SWS_LDCOM_00041 */ /* Rte_LdComCbkRxIndication, Large Data COM shall support Interface-like communication */
/* @req 4.2.2/SWS_LDCOM_00042 */ /* Rte_LdComCbkTriggerTransmit, Large Data COM shall support Transmission Triggered by lower layer */
/* @req 4.2.2/SWS_LDCOM_00053 */ /* Rte_LdComCbkTxConfirmation, AUTOSAR COM and LargeDataCOM shall provide a transmit confirmation function */
/*lint -save -e9046 */
#include "LdCom.h"
#include "LdCom_internal.h"
#include "PduR_LdCom.h" /* @req 4.2.2/SWS_LDCOM_00001*/
#include "Rte_Cbk.h" /* @req 4.2.2/SWS_LDCOM_00001*/
#if(LDCOM_DEV_ERROR_DETECT == STD_ON)
#include "Det.h" /* @req 4.2.2/SWS_LDCOM_00050*/
#endif
const LdCom_ConfigType* LdComCfgPtr;
#define INVALID_LENGTH 0x00u;
/** Static declarations */
LdCom_InternalType LdCom_Internal = {
.initStatus = LDCOM_STATE_UNINIT,
};
/*lint -emacro(904,LDCOM_DET_REPORTERROR)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
/* @req 4.2.2/SWS_LDCOM_00050*/
#if (LDCOM_DEV_ERROR_DETECT == STD_ON)
#define LDCOM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
(void)Det_ReportError(LDCOM_MODULE_ID, 0, _api, _error); \
return __VA_ARGS__; \
}
#else
#define LDCOM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
return __VA_ARGS__; \
}
#endif
/** AUTOSAR APIs */
/* @req 4.2.2/SWS_LDCOM_00022*/
void LdCom_Init( const LdCom_ConfigType* config ){
LDCOM_DET_REPORTERROR((NULL != config),LDCOM_SERVICE_ID_INIT, LDCOM_E_UNINIT);
/* @req 4.2.2/SWS_LDCOM_00007*/
LdComCfgPtr = config;
LdCom_Internal.initStatus = LDCOM_STATE_INIT;
}
/* @req 4.2.2/SWS_LDCOM_00023*/
void LdCom_DeInit( void ){
LdCom_Internal.initStatus = LDCOM_STATE_UNINIT;
/* @req 4.2.2/SWS_LDCOM_00008*/
LdComCfgPtr = NULL;
}
/* @req 4.2.2/SWS_LDCOM_00045*/
#if (LDCOM_VERSION_INFO_API == STD_ON)
/* @req 4.2.2/SWS_LDCOM_00024*/
void LdCom_GetVersionInfo( Std_VersionInfoType* versioninfo ){
LDCOM_DET_REPORTERROR((NULL != versioninfo),LDCOM_SERVICE_ID_GET_VERSION_INFO,LDCOM_E_PARAM_POINTER);
versioninfo->moduleID = LDCOM_MODULE_ID; /* Module ID of LDCOM */
versioninfo->vendorID = LDCOM_VENDOR_ID; /* Vendor Id (ARCCORE) */
/* return the Software Version numbers*/
versioninfo->sw_major_version = LDCOM_SW_MAJOR_VERSION;
versioninfo->sw_minor_version = LDCOM_SW_MINOR_VERSION;
versioninfo->sw_patch_version = LDCOM_SW_PATCH_VERSION;
}
#endif
/* @req 4.2.2/SWS_LDCOM_00026*/
Std_ReturnType LdCom_Transmit( PduIdType Id, const PduInfoType* PduInfoPtr ){
Std_ReturnType ret;
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_TRANSMIT, LDCOM_E_UNINIT, E_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != PduInfoPtr),LDCOM_SERVICE_ID_TRANSMIT,LDCOM_E_PARAM_POINTER, E_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != PduInfoPtr->SduDataPtr),LDCOM_SERVICE_ID_TRANSMIT,LDCOM_E_PARAM_POINTER, E_NOT_OK);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (Id == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_TRANSMIT,LDCOM_E_PARAM, E_NOT_OK);
/* @req 4.2.2/SWS_LDCOM_00010*/
/* @req 4.2.2/SWS_LDCOM_00012*/
/* @req 4.2.2/SWS_LDCOM_00009*/
if (LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_SEND) {
ret = PduR_LdComTransmit(LdComCfgPtr->LdComIPduCfg[i].LdComPdurPduId, PduInfoPtr);
} else {
ret = E_NOT_OK;
}
return ret;
}
/* @req 4.2.2/SWS_LDCOM_00027*/
BufReq_ReturnType LdCom_CopyTxData( PduIdType id, const PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr ){
BufReq_ReturnType ret = BUFREQ_NOT_OK;
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_COPY_TX_DATA, LDCOM_E_UNINIT, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != info),LDCOM_SERVICE_ID_COPY_TX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != info->SduDataPtr),LDCOM_SERVICE_ID_COPY_TX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != retry),LDCOM_SERVICE_ID_COPY_TX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != availableDataPtr),LDCOM_SERVICE_ID_COPY_TX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (id == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_COPY_TX_DATA,LDCOM_E_PARAM, BUFREQ_NOT_OK);
/* @req 4.2.2/SWS_LDCOM_00048*/
/* @req 4.2.2/SWS_LDCOM_00005*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_SEND) &&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_TP)){
if (LdComCfgPtr->LdComIPduCfg[i].LdComCopyTxDataCbk != NULL) {
/* @req 4.2.2/SWS_LDCOM_00013*/
ret = LdComCfgPtr->LdComIPduCfg[i].LdComCopyTxDataCbk(info, retry, availableDataPtr );
} else {
ret = BUFREQ_NOT_OK;
}
} else {
ret = BUFREQ_NOT_OK;
}
return ret;
}
/* @req 4.2.2/SWS_LDCOM_00028*/
void LdCom_TpTxConfirmation( PduIdType id, Std_ReturnType result ){
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_TP_TX_CONFIRMATION, LDCOM_E_UNINIT);
LDCOM_DET_REPORTERROR((E_OK == result),LDCOM_SERVICE_ID_TP_TX_CONFIRMATION,LDCOM_E_PARAM);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++)
{
if (id == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_TP_TX_CONFIRMATION,LDCOM_E_PARAM);
/* @req 4.2.2/SWS_LDCOM_00048*/
/* @req 4.2.2/SWS_LDCOM_00005*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_SEND) &&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_TP)){
if (LdComCfgPtr->LdComIPduCfg[i].LdComTpTxConfirmationCbk != NULL) {
/* @req 4.2.2/SWS_LDCOM_00013*/
LdComCfgPtr->LdComIPduCfg[i].LdComTpTxConfirmationCbk(result );
}
}
}
/* @req 4.2.2/SWS_LDCOM_00029*/
BufReq_ReturnType LdCom_StartOfReception( PduIdType id, const PduInfoType* info, PduLengthType TpSduLength, PduLengthType* bufferSizePtr ){
BufReq_ReturnType ret = BUFREQ_NOT_OK;
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_START_OF_RECEPTION, LDCOM_E_UNINIT, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL != info),LDCOM_SERVICE_ID_START_OF_RECEPTION,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL != info->SduDataPtr),LDCOM_SERVICE_ID_START_OF_RECEPTION,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR(((PduLengthType)0 != TpSduLength ), LDCOM_SERVICE_ID_START_OF_RECEPTION,LDCOM_E_PARAM, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL != bufferSizePtr),LDCOM_SERVICE_ID_START_OF_RECEPTION,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (id == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_START_OF_RECEPTION,LDCOM_E_PARAM, BUFREQ_NOT_OK);
/* @req 4.2.2/SWS_LDCOM_00049*/
/* @req 4.2.2/SWS_LDCOM_00005*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_RECEIVE )&&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_TP)){
if (LdComCfgPtr->LdComIPduCfg[i].LdComRxStartOfReceptionCbk != NULL) {
/* @req 4.2.2/SWS_LDCOM_00015*/
ret = LdComCfgPtr->LdComIPduCfg[i].LdComRxStartOfReceptionCbk(info, TpSduLength, bufferSizePtr );
} else {
ret = BUFREQ_NOT_OK;
}
} else {
ret = BUFREQ_NOT_OK;
}
return ret;
}
/* @req 4.2.2/SWS_LDCOM_00030*/
BufReq_ReturnType LdCom_CopyRxData( PduIdType id, const PduInfoType* info, PduLengthType* bufferSizePtr ){
BufReq_ReturnType ret = BUFREQ_NOT_OK;
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_COPY_RX_DATA, LDCOM_E_UNINIT, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL != info),LDCOM_SERVICE_ID_COPY_RX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL != info->SduDataPtr),LDCOM_SERVICE_ID_COPY_RX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
LDCOM_DET_REPORTERROR((NULL != bufferSizePtr),LDCOM_SERVICE_ID_COPY_RX_DATA,LDCOM_E_PARAM_POINTER, BUFREQ_NOT_OK);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (id == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_COPY_RX_DATA,LDCOM_E_PARAM, BUFREQ_NOT_OK);
/* @req 4.2.2/SWS_LDCOM_00049*/
/* @req 4.2.2/SWS_LDCOM_00005*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_RECEIVE )&&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_TP)){
if (LdComCfgPtr->LdComIPduCfg[i].LdComCopyRxDataCbk != NULL) {
/* @req 4.2.2/SWS_LDCOM_00016*/
ret = LdComCfgPtr->LdComIPduCfg[i].LdComCopyRxDataCbk( info, bufferSizePtr );
} else {
ret = BUFREQ_NOT_OK;
}
} else {
ret = BUFREQ_NOT_OK;
}
return ret;
}
/* @req 4.2.2/SWS_LDCOM_00031*/
void LdCom_TpRxIndication( PduIdType id, Std_ReturnType result ){
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_TP_RX_INDICATION, LDCOM_E_UNINIT);
LDCOM_DET_REPORTERROR((E_OK == result),LDCOM_SERVICE_ID_TP_RX_INDICATION,LDCOM_E_PARAM);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (id == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_TP_RX_INDICATION,LDCOM_E_PARAM);
/* @req 4.2.2/SWS_LDCOM_00005*/
/* @req 4.2.2/SWS_LDCOM_00049*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_RECEIVE )&&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_TP)){
if(LdComCfgPtr->LdComIPduCfg[i].LdComTpRxIndicationCbk != NULL){
/* @req 4.2.2/SWS_LDCOM_00017*/
LdComCfgPtr->LdComIPduCfg[i].LdComTpRxIndicationCbk( result );//Rte_LdComCbkTpRxIndication_<sn>
}
}
}
/* @req 4.2.2/SWS_LDCOM_00032*/
void LdCom_RxIndication( PduIdType RxPduId, const PduInfoType* PduInfoPtr ){
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_RX_INDICATION, LDCOM_E_UNINIT);
LDCOM_DET_REPORTERROR((NULL != PduInfoPtr),LDCOM_SERVICE_ID_RX_INDICATION,LDCOM_E_PARAM_POINTER);
LDCOM_DET_REPORTERROR((NULL != PduInfoPtr->SduDataPtr),LDCOM_SERVICE_ID_RX_INDICATION,LDCOM_E_PARAM_POINTER);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (RxPduId == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_RX_INDICATION,LDCOM_E_PARAM);
/* @req 4.2.2/SWS_LDCOM_00005*/
/* @req 4.2.2/SWS_LDCOM_00055*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_RECEIVE )&&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_IF)){
if(LdComCfgPtr->LdComIPduCfg[i].LdComRxIndicationCbk != NULL){
/* @req 4.2.2/SWS_LDCOM_00014*/
LdComCfgPtr->LdComIPduCfg[i].LdComRxIndicationCbk( PduInfoPtr);
}
}
}
/* @req 4.2.2/SWS_LDCOM_00056*/
void LdCom_TxConfirmation( PduIdType TxPduId ){
uint8 i;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_TX_CONFIRMATION, LDCOM_E_UNINIT);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (TxPduId == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_TX_CONFIRMATION,LDCOM_E_PARAM);
/* @req 4.2.2/SWS_LDCOM_00054*/
/* @req 4.2.2/SWS_LDCOM_00005*/
if((LdComCfgPtr->LdComIPduCfg[i].LdComIPduDir == LDCOM_SEND) &&(LdComCfgPtr->LdComIPduCfg[i].LdComLowerApi ==LDCOM_IF)){
if(LdComCfgPtr->LdComIPduCfg[i].LdComTxConfirmationCbk != NULL){
/* @req 4.2.2/SWS_LDCOM_00046*/
LdComCfgPtr->LdComIPduCfg[i].LdComTxConfirmationCbk();
}
}
}
/* @req 4.2.2/SWS_LDCOM_00033*/
Std_ReturnType LdCom_TriggerTransmit( PduIdType TxPduId, PduInfoType* PduInfoPtr ){
uint8 i;
Std_ReturnType ret = E_NOT_OK;
LDCOM_DET_REPORTERROR((LDCOM_STATE_INIT == LdCom_Internal.initStatus),LDCOM_SERVICE_ID_TRIGGER_TRANSMIT, LDCOM_E_UNINIT, E_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != PduInfoPtr),LDCOM_SERVICE_ID_TRIGGER_TRANSMIT,LDCOM_E_PARAM_POINTER, E_NOT_OK);
LDCOM_DET_REPORTERROR((NULL_PTR != PduInfoPtr->SduDataPtr),LDCOM_SERVICE_ID_TRIGGER_TRANSMIT,LDCOM_E_PARAM_POINTER, E_NOT_OK);
for(i=0; i < LdComCfgPtr->LdComIPduCnt; i++){
if (TxPduId == LdComCfgPtr->LdComIPduCfg[i].LdComHandleId ) {
break;
}
}
LDCOM_DET_REPORTERROR((i < LdComCfgPtr->LdComIPduCnt ),LDCOM_SERVICE_ID_TRIGGER_TRANSMIT,LDCOM_E_PARAM, E_NOT_OK);
/* @req 4.2.2/SWS_LDCOM_00005*/
/* @req 4.2.2/SWS_LDCOM_00047*/
/* @req 4.2.2/SWS_LDCOM_00005*/
if(LdComCfgPtr->LdComIPduCfg[i].LdComTxTriggerTransmitCbk != NULL){
/* @req 4.2.2/SWS_LDCOM_00011*/
ret = LdComCfgPtr->LdComIPduCfg[i].LdComTxTriggerTransmitCbk(PduInfoPtr );
}else{
ret = E_NOT_OK;
}
return ret;
}
#ifdef HOST_TEST
LdCom_InternalType* readinternal_status(void );
LdCom_InternalType* readinternal_status(void)
{
return &LdCom_Internal;
}
#endif
/*lint -restore */
/*END*/
|
2301_81045437/classic-platform
|
communication/LdCom/src/LdCom.c
|
C
|
unknown
| 16,143
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LDCOM_INTERNAL_H_
#define LDCOM_INTERNAL_H_
typedef enum {
LDCOM_STATE_UNINIT, /* Status of LdCom module before LdCom_Init function*/
LDCOM_STATE_INIT, /* Status of LdCom module after LdCom_Init function called*/
}LdCom_StateType;
typedef struct {
LdCom_StateType initStatus; /* var to hold LdCom module status */
}LdCom_InternalType;
#endif /*LDCOM_INTERNAL_H*/
|
2301_81045437/classic-platform
|
communication/LdCom/src/LdCom_internal.h
|
C
|
unknown
| 1,158
|
# LinIf
obj-$(USE_LINIF) += LinIf_Lcfg.o
obj-$(USE_LINIF) += LinIf_PBcfg.o
obj-$(USE_LINIF) += LinIf.o
inc-$(USE_LINIF) += $(ROOTDIR)/communication/LinIf/inc
vpath-$(USE_LINIF) += $(ROOTDIR)/communication/LinIf/src
|
2301_81045437/classic-platform
|
communication/LinIf/LinIf.mod.mk
|
Makefile
|
unknown
| 221
|
# LinIf
obj-$(USE_LINTP) += LinTp_Lcfg.o
obj-$(USE_LINTP) += LinTp_PBcfg.o
obj-$(USE_LINTP) += LinTp.o
inc-$(USE_LINTP) += $(ROOTDIR)/communication/LinIf/inc
vpath-$(USE_LINTP) += $(ROOTDIR)/communication/LinIf/src
|
2301_81045437/classic-platform
|
communication/LinIf/LinTp.mod.mk
|
Makefile
|
unknown
| 221
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @addtogroup LinIf LIN Interface
* @{ */
/** @file LinIf.h
* API and type definitions for LIN Interface.
*/
/** @req LINIF691 */
#ifndef LINIF_H_
#define LINIF_H_
#define LINIF_MODULE_ID 62u
#define LINIF_VENDOR_ID 60u
#define LINIF_SW_MAJOR_VERSION 4u
#define LINIF_SW_MINOR_VERSION 0u
#define LINIF_SW_PATCH_VERSION 0u
#define LINIF_AR_RELEASE_MAJOR_VERSION 4u
#define LINIF_AR_RELEASE_MINOR_VERSION 0u
#define LINIF_AR_RELEASE_PATCH_VERSION 3u
/* @req LINIF499 */
#include "Std_Types.h"
/** @req LINIF638 */
#include "Lin_GeneralTypes.h"
#include "LinIf_Cfg.h"
#include "LinIf_Types.h"
#include "ComM_Types.h"
/** @name Service id's */
//@{
#define LINIF_INIT_SERVICE_ID 0x00u
#define LINIF_GETVERSIONINFO_SERVICE_ID 0x03u
#define LINIF_SCHEDULEREQUEST_SERVICE_ID 0x05u
#define LINIF_GOTOSLEEP_SERVICE_ID 0x06u
#define LINIF_WAKEUP_SERVICE_ID 0x07u
#define LINIF_MAINFUNCTION_SERVICE_ID 0x80u
//@}
/**@req LINIF267 */
/** @name Error Codes */
//@{
#define LINIF_E_UNINIT (uint8) 0x00u
#define LINIF_E_ALREADY_INITIALIZED (uint8) 0x10u
#define LINIF_E_NONEXISTENT_CHANNEL (uint8) 0x20u
#define LINIF_E_PARAMETER (uint8) 0x30u
#define LINIF_E_PARAMETER_POINTER (uint8) 0x40u
#define LINIF_E_SCHEDULE_OVERFLOW (uint8) 0x50u
#define LINIF_E_SCHEDULE_REQUEST_ERROR (uint8) 0x51u
#define LINIF_E_RESPONSE (uint8) 0x60u
#define LINIF_E_NC_NO_RESPONSE (uint8) 0x61u
// Following error codes are added by ArcCore
#define LINIF_E_UNEXPECTED_EXECUTION 0x70u
//@}
/**@req LINIF278 */ /**@req LINIF487 *//**@req LINIF340 */
#if (LINIF_VERSION_INFO_API == STD_ON)
void LinIf_GetVersionInfo( Std_VersionInfoType *versionInfo );
#define LinIf_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,LINIF)
#endif
void LinIf_Init( const LinIf_ConfigType* ConfigPtr );
void LinIf_DeInit(void);
Std_ReturnType LinIf_Transmit(PduIdType LinTxPduId,const PduInfoType* PduInfoPtr);
Std_ReturnType LinIf_ScheduleRequest(NetworkHandleType Channel,LinIf_SchHandleType Schedule);
Std_ReturnType LinIf_GotoSleep(NetworkHandleType Channel);
Std_ReturnType LinIf_WakeUp(NetworkHandleType Channel);
void LinIf_MainFunction(void);
#endif
/** @} */
|
2301_81045437/classic-platform
|
communication/LinIf/inc/LinIf.h
|
C
|
unknown
| 3,196
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LINIF_CBK_H_
#define LINIF_CBK_H_
#include "Std_Types.h"
void LinIf_Cbk_CheckWakeup(NetworkHandleType Channel);
#endif
|
2301_81045437/classic-platform
|
communication/LinIf/inc/LinIf_Cbk.h
|
C
|
unknown
| 909
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LINIF_TYPES_H_
#define LINIF_TYPES_H_
#include "Std_Types.h"
/** @req LINIF499 */
#include "ComStack_Types.h"
/*===========[Type definitions]===============================================*/
/* Checksum type */
typedef enum
{
CLASSIC,
ENHANCED
} LinIf_ChecksumType;
/* Type of a Lin frame */
typedef enum
{
ASSIGN,
ASSIGN_NAD,
CONDITIONAL,
EVENT_TRIGGERED,
FREE,
MRF,
SPORADIC,
SRF,
UNASSIGN,
UNCONDITIONAL
} LinIf_FrameTypeType;
/* Direction of a Lin PDU */
typedef enum
{
LinIfInternalPdu,
LinIfRxPdu,
LinIfSlaveToSlavePdu,
LinIfTxPdu
} LinIf_PduDirectionType;
/** @req LINIF441*/
typedef enum {
LINIF_UNINIT, /** @req LINIF438 */
LINIF_INIT, /** @req LINIF439 */
LINIF_CHANNEL_UNINIT,
LINIF_CHANNEL_OPERATIONAL, /** @req LINIF441*/
LINIF_CHANNEL_SLEEP_TRANS,
LINIF_CHANNEL_SLEEP, /** @req LINIF442*/
}LinIf_StatusType;
/* Resuming modes of schedule table after having been
* interrupted by another RUN_ONCE schedule table */
typedef enum
{
CONTINUE_AT_IT_POINT,
START_FROM_BEGINNING
} LinIf_ResumePositionType;
/* Run modes of a schedule table */
typedef enum
{
RUN_CONTINUOUS,
RUN_ONCE
} LinIfRunModeType;
/* Lin frame */
typedef struct
{
LinIf_ChecksumType LinIfChecksumType;
char* LinIfFrameName;
uint8 LinIfFramePriority;
LinIf_FrameTypeType LinIfFrameType;
PduLengthType LinIfLength;
uint8 LinIfPid;
PduIdType LinIfTxTargetPduId;
uint8 *LinIfFixedFrameSdu;
LinIf_PduDirectionType LinIfPduDirection;
} LinIf_FrameType;
/* Master node type */
typedef struct
{
uint32 LinIfJitter;
} LinIf_MasterType;
/* Slave node type */
typedef struct
{
uint32 LinIfConfiguredNad;
uint32 LinIfFunctionId;
char* LinIfProtocolVersion;
uint32 LinIfResponseErrorBitPos;
uint32 LinIfSupplierId;
uint32 LinIfVariant;
uint32 LinIfResponseErrorEventRef;
uint16 LinIfResponseErrorFrameRef;
} LinIf_SlaveType;
/* Entry type */
typedef struct
{
uint16 LinIfDelay;
uint16 LinIfEntryIndex;
uint16 LinIfCollisionResolvingRef;
uint16 LinIfFrameRef; /* Index in the LinIfFrameCfg array */
} LinIfEntryType;
/** @req LINIF197 */
typedef uint8 LinIf_SchHandleType;
/* Lin schedule table */
typedef struct
{
LinIf_ResumePositionType LinIfResumePosition;
LinIfRunModeType LinIfRunMode;
uint8 LinIfSchedulePriority;
LinIf_SchHandleType LinIfScheduleTableIndex;
const char* LinIfScheduleTableName;
const LinIfEntryType *LinIfEntry;
uint16 LinIfNofEntries;
} LinIf_ScheduleTableType;
typedef uint8 LinIf_WakeUpSourceType;
typedef char* LinIf_NodeComposition;
/* General settings as structure. */
typedef struct
{
/* Switches the Development Error Detection and Notification ON or OFF. */
boolean LinIfDevErrorDetect;
/* States if multiple drivers are included in the LIN Interface or not.
* The reason for this parameter is to reduce the size of LIN Interface if
* multiple drivers are not used. */
boolean LinIfMultipleDriversSupported;
/* States if the node configuration commands Assign NAD and Conditional
* Change NAD are supported. */
boolean LinIfNcOptionalRequestSupported;
/* States if the TP is included in the LIN Interface or not. The reason for
* this parameter is to reduce the size of LIN Interface if the TP is not
* used. */
boolean LinIfTpSupported;
/* Switches the LinIf_GetVersionInfo function ON or OFF. */
boolean LinIfVersionInfoApi;
} LinIf_GeneralType;
/* Lin channel */
typedef struct
{
/* Internal ID for the channel on LIN Interface level. This parameter shall
* map the NetworkHandleType to the physical LIN channel.
* Implementation Type: NetworkHandleType */
uint8 LinIfLinChannelId;
/* Number of schedule requests the schedule table manager can handle for
* this channel. */
uint8 LinIfScheduleRequestQueueLength;
/* Generic container for all types of LIN frames. */
const LinIf_FrameType *LinIfFrame;
/* Each Master can only be connected to one physical channel.
* This could be compared to the Node parameter in a LDF file. */
LinIf_MasterType LinIfMaster;
/* Describes a schedule table. Each LinIfChannel may have several schedule tables.
* Each schedule table can only be connected to one channel. */
const LinIf_ScheduleTableType *LinIfScheduleTable;
/* The Node attributes of the Slaves are provided with these parameter. */
const LinIf_SlaveType *LinIfSlave;
/* This container contains the configuration (parameters) needed
to configure a wakeup capable channel */
const LinIf_WakeUpSourceType *LinIfWakeUpSource;
/* Startup state */
LinIf_StatusType LinIfStartupState;
/* ComM network */
NetworkHandleType LinIfComMHandle;
/* LinIf Sleep transition cycle time*/
uint8 LinIfSleepTransitionCycle;
} LinIf_ChannelType;
/** @req LINIF668 */
/* Global configuration */
typedef struct
{
uint16 LinIfTimeBase;
const LinIf_ChannelType *LinIfChannel;
const LinIf_FrameType *LinIfFrameConfig;
const NetworkHandleType *LinIfChannelMap;
NetworkHandleType LinIfChannelMapSize;
} LinIf_ConfigType;
/* Lin configuration */
typedef struct
{
const LinIf_GeneralType *LinIfGeneral;
const LinIf_ConfigType *LinIfGlobalConfig;
} LinIf_Type;
#endif
|
2301_81045437/classic-platform
|
communication/LinIf/inc/LinIf_Types.h
|
C
|
unknown
| 6,416
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @addtogroup LinTP LIN Interface
* @{ */
/** @file LinTP.h
* API and type definitions for LIN Interface.
*/
#ifndef LINTP_H_
#define LINTP_H_
#define LINTP_MODULE_ID 62u
#define LINTP_VENDOR_ID 60u
#define LINTP_SW_MAJOR_VERSION 1u
#define LINTP_SW_MINOR_VERSION 0u
#define LINTP_SW_PATCH_VERSION 0u
#define LINTP_AR_RELEASE_MAJOR_VERSION 4u
#define LINTP_AR_RELEASE_MINOR_VERSION 3u
#define LINTP_AR_RELEASE_PATCH_VERSION 0u
#include "Std_Types.h"
#include "LinIf.h"
#include "LinTp_Cfg.h"
#include "LinTp_Types.h"
#include "ComM_Types.h"
/** @name Service id's */
//@{
/* @req SWS_LinIf_00352 */
#define LINTP_GETVERSIONINFO_SERVICE_ID 0x42u
/* @req SWS_LinIf_00355 */
#define LINTP_SHUTDOWN_SERVICE_ID 0x43u
/* @req SWS_LinIf_00500 */
#define LINTP_CANCELTRANSMIT_SERVICE_ID 0x4au
/* @req SWS_LinIf_00501 */
#define LINTP_CHANGEPARAMETER_SERVICE_ID 0x4bu
/* @req SWS_LinIf_00378 */
#define LINIF_CHECKWAKEUP_SERVICE_ID 0x60u
/* @req SWS_LinIf_00625 */
#define LINTP_CANCELRECEIVE_SERVICE_ID 0x4cu
/* @req SWS_LinIf_00715 */
#define LINIF_WAKEUPCONFIRMATION_SERVICE_ID 0x61u
//@}
/* @req SWS_LinIf_00376 */
/** @name Error Codes */
//@{
#define LINIF_E_UNINIT (uint8) 0x00u
#define LINIF_E_NONEXISTENT_CHANNEL (uint8) 0x20u
#define LINIF_E_PARAMETER (uint8) 0x30u
#define LINIF_E_PARAM_POINTER (uint8) 0x40u
#define LINIF_E_SCHEDULE_OVERFLOW (uint8) 0x50u
#define LINIF_E_SCHEDULE_REQUEST_ERROR (uint8) 0x51u
#define LINIF_E_TRCV_INV_MODE (uint8) 0x53u
#define LINIF_E_TRCV_NOT_NORMAL (uint8) 0x54u
#define LINIF_E_PARAM_WAKEUPSOURCE (uint8) 0x55u
#define LINIF_E_RESPONSE (uint8) 0x60u
#define LINIF_E_NC_NO_RESPONSE (uint8) 0x61u
// Following error codes are added by ArcCore
#define LINIF_E_UNEXPECTED_EXECUTION 0x70u
//@}
/* @req SWS_LinIf_00639 */
/* @req SWS_LinIf_00352 */
/** @brief Return the version information of LinTp module.
*
* The function LinTp_GetVersionInfo shall return the version
* information of the LinTp module.
* The version information includes:
* - Module Id
* - Vendor Id
* - sw_major_version
* - sw_minor_version
* - sw_patch_version
*
* The function LinTp_GetVersionInfo raises a development error "LINIF_E_PARAM_POINTER."
* if versioninfo has an invalid value
*
* @param Std_VersionInfoType The type including Module and Vendor ID for the LinTP Module.
* @return void.
*/
#if (LINTP_VERSION_INFO_API == STD_ON)
void LinTp_GetVersionInfo( Std_VersionInfoType *versionInfo );
#endif
/** @} */
/* @req SWS_LinIf_00350 */
void LinTp_Init( const LinTp_ConfigType* ConfigPtr );
/* @req SWS_LinIf_00351 */
Std_ReturnType LinTp_Transmit(PduIdType LinTxPduId,const PduInfoType* PduInfoPtr);
/* @req SWS_LinIf_00355 */
void LinTp_Shutdown(void);
/* @req SWS_LinIf_00501 */
Std_ReturnType LinTp_ChangeParameter(PduIdType id,TPParameterType parameter,uint16 value);
/* @req SWS_LinIf_00625 */
Std_ReturnType LinTp_CancelReceive(PduIdType RxPduId);
/* @req SWS_LinIf_00500 */
Std_ReturnType LinTp_CancelTransmit(PduIdType TxPduId);
#endif
|
2301_81045437/classic-platform
|
communication/LinIf/inc/LinTp.h
|
C
|
unknown
| 4,122
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef LINTP_TYPES_H_
#define LINTP_TYPES_H_
#include "Std_Types.h"
typedef enum {
LINTP_UNINIT, /** @req SWS_LinIf_00316 */
LINTP_INIT, /** @req SWS_LinIf_00483 */
}LinTp_StatusType;
/* @req SWS_LinIf_00426 */
/* Global configuration */
typedef struct
{
/* @req ECUC_LinTp_00624 */
/* Configures the maximum number of allowed response pending frames. */
uint16 LinTpMaxNumberOfRespPendingFrames;
/* @req ECUC_LinTp_00635 */
/* Maximum number of NSdus. This parameter is needed only in case
* of post-build loadable implementation using static memory allocation. */
uint16 LinTpMaxRxNSduCnt;
/* @req ECUC_LinTp_00636 */
/*Maximum number of NSdus. This parameter is needed only in case
* of post-build loadable implementation using static memory allocation. */
uint16 LinTpMaxTxNSduCnt;
/* @req ECUC_LinTp_00622 */
/* P2*max timeout when a response pending frame is expected in seconds.
Note that the minimum value of LinTpP2Max shall be more than or equal
to the value of LinTpP2Timing. */
uint16 LinTpP2Max;
/* @req ECUC_LinTp_00625 */
/* Definition of the P2max timeout observation parameter in seconds. */
uint16 LinTpP2Timing;
}LinTp_ConfigType;
/* @req SWS_LinIf_00629 */
typedef enum {
LINTP_APPLICATIVE_SCHEDULE = 0,
LINTP_DIAG_REQUEST,
LINTP_DIAG_RESPONSE
}LinTp_Mode;
/* LinTP configuration */
typedef struct
{
const LinTp_ConfigType *LinTprGlobalConfig;
} LinTp_Type;
#endif
|
2301_81045437/classic-platform
|
communication/LinIf/inc/LinTp_Types.h
|
C
|
unknown
| 2,290
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @req LINIF376 */ /* Error codes detected by LINIF */
/** @req LINIF270 */ /* The detection of production code errors can not be switched off.*/
/** @req LINIF308 *//* The LIN Interface shall not use a Node Model */
/** @req LINIF359.partially *//* Among Mandatory interface LINTP interface not supported */
/** !req LINIF360 */ /* None of the optional interface mentioned in autosar are supported */
/** !req LINIF374 */ /* Post builf not supported */
/** @req LINIF376 *//** @reqLINIF579 */ /* DET error codes */
/** @req LINIF458 */ /* The LIN Interface shall not report a header error to the upper layers when the return code of the LIN Drivermodule’s function Lin_GetStatus is LIN_TX_HEADER_ERROR*/
/** @req LINIF469 */ /* Types Included from different modules */
/** @req LINIF129 */ /* Accessing Functions provided by LIN Driver */
/** @req LINIF237 */ /* The power management of the LIN 2.1 specification shall not be applicable to the LIN Interface */
/** @req LINIF241 */ /* Code structure files.*/
/** @req LINIF248 */ /* The LIN Interface shall support the behavior of the master in the LIN 2.1 specification.*/
/** @req LINIF249 */ /* The LIN Interface shall realize the master behavior so that existing slaves can be reused.*/
/** @req LINIF375 */ /* The LIN Interface shall not make any consistency check of the configuration in run-time in production software. It may be done if the development error detection is enabled. */
/** @req LINIF472 */ /*The LIN Interface shall not use reserved frames.*/
/** @req LINIF579 *//* Additional errors that are detected because of specific implementation */
/** @req LINIF261 *//* The delay between processing two frames shall be a multiple of the LIN Interface time-base, This is checked in LinIf.chk */
#include "LinIf.h" /** @req LINIF242 */
#include "LinIf_Types.h"
#include "LinIf_Cbk.h"
#include "Lin.h" /** @req LINIF434 */
#include "LinSM_Cbk.h" /** @req LINIF556 */
#include "PduR_LinIf.h" /** @req LINIF497 */
#include "SchM_LinIf.h"
/** @req LINIF498 */
#if (LINIF_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
/*lint -emacro(904,VALIDATE,VALIDATE_W_RV)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
/** @req LINIF269*/ /** @req LINIF271*/
/* Development error macros. */
#if ( LINIF_DEV_ERROR_DETECT == STD_ON )
#define VALIDATE(_exp,_api,_err ) \
if( !(_exp) ) { \
(void)Det_ReportError(LINIF_MODULE_ID,0,_api,_err); \
return; \
}
#define VALIDATE_W_RV(_exp,_api,_err,_rv ) \
if( !(_exp) ) { \
(void)Det_ReportError(LINIF_MODULE_ID,0,_api,_err); \
return (_rv); \
}
#define DET_REPORT_ERROR(_api,_err) (void)Det_ReportError(LINIF_MODULE_ID, 0, _api, _err);
#else
#define VALIDATE(_exp,_api,_err )
#define VALIDATE_W_RV(_exp,_api,_err,_rv )
#define DET_REPORT_ERROR(_api,_err)
#endif
static const LinIf_ConfigType *LinIf_ConfigPtr;
static LinIf_StatusType LinIfStatus = LINIF_UNINIT;
static LinIf_StatusType LinIfChannelStatus[LINIF_CONTROLLER_CNT];
static const LinIf_ScheduleTableType *currentSchedule[LINIF_CONTROLLER_CNT];
static const LinIf_ScheduleTableType *previousSchedule[LINIF_CONTROLLER_CNT];
static uint16 currentIndex[LINIF_CONTROLLER_CNT];
static uint16 previousIndex[LINIF_CONTROLLER_CNT];
static uint16 currentDelayInTicks[LINIF_CONTROLLER_CNT];
static boolean newScheduleRequest[LINIF_CONTROLLER_CNT];
static uint8 chSleepCmdAttmpt[LINIF_CONTROLLER_CNT]; /* This is required for tx a sleep frame */
static LinIf_SchHandleType newSchedule[LINIF_CONTROLLER_CNT];
/* Internal function declarations */
static inline void handelSchedTransmission(uint8 chIndex);
/** @req LINIF198 */
void LinIf_Init( const LinIf_ConfigType* ConfigPtr )
{/*lint !e9046 LinIf_Init and LINIF_INIT are in the AutoSAR specification. */
/** @req LINIF373 */
LinIf_ConfigPtr = ConfigPtr;
/** @req LINIF486 */
VALIDATE( (LinIf_ConfigPtr!=NULL), LINIF_INIT_SERVICE_ID, LINIF_E_PARAMETER_POINTER );
/** @req LINIF562 */
VALIDATE((LinIfStatus != LINIF_INIT), LINIF_INIT_SERVICE_ID, LINIF_E_ALREADY_INITIALIZED);
uint8 i;
for (i=0;i<LINIF_CONTROLLER_CNT;i++)
{
/** @req LINIF507 */
LinIfChannelStatus[i] = LinIf_ConfigPtr->LinIfChannel[i].LinIfStartupState;
if (LINIF_CHANNEL_SLEEP == LinIfChannelStatus[i]) {
(void)Lin_GoToSleepInternal(LinIf_ConfigPtr->LinIfChannel[i].LinIfLinChannelId);//It is expected that Lin Driver goes to sleep
}
/** @req LINIF233 */
currentSchedule[i] = LinIf_ConfigPtr->LinIfChannel[i].LinIfScheduleTable;
previousSchedule[i]= LinIf_ConfigPtr->LinIfChannel[i].LinIfScheduleTable;
currentIndex[i] = 0;
previousIndex[i] = 0;
currentDelayInTicks[i] = 0;
newScheduleRequest[i] = FALSE;
chSleepCmdAttmpt[i] = 0;
}
/** @req LINIF381 */
LinIfStatus = LINIF_INIT;
}
void LinIf_DeInit()
{
LinIfStatus = LINIF_UNINIT;
}
/** @req LINIF201 */
Std_ReturnType LinIf_Transmit(PduIdType LinTxPduId,const PduInfoType* PduInfoPtr)
{
(void)LinTxPduId;
//lint -estring(920,pointer) /* cast to void */
(void)PduInfoPtr;
//lint +estring(920,pointer) /* cast to void */
/* Sporadic frames not supported in this release */
/*printf("LinIf_Transmit received request. Id: %d, Data: %d\n", LinTxPduId, *(PduInfoPtr->SduDataPtr));*/
return E_OK;
}
/** @req LINIF202 */
/*lint -e{578} FALSE POSITIVE Declaration of Schedule should hide Schedule(void)*/
Std_ReturnType LinIf_ScheduleRequest(NetworkHandleType Channel,LinIf_SchHandleType Schedule)
{
/** @req LINIF535 */
VALIDATE_W_RV( (LinIfStatus != LINIF_UNINIT), LINIF_SCHEDULEREQUEST_SERVICE_ID, LINIF_E_UNINIT, E_NOT_OK);
/** @req LINIF563 */
VALIDATE_W_RV( ((Channel < LinIf_ConfigPtr->LinIfChannelMapSize) && (LinIf_ConfigPtr->LinIfChannelMap[Channel] < LINIF_CONTROLLER_CNT)), LINIF_SCHEDULEREQUEST_SERVICE_ID, LINIF_E_NONEXISTENT_CHANNEL, E_NOT_OK);
/** @req LINIF567 */
VALIDATE_W_RV( (Schedule < LINIF_SCH_CNT), LINIF_SCHEDULEREQUEST_SERVICE_ID, LINIF_E_SCHEDULE_REQUEST_ERROR, E_NOT_OK);
/* Get the corresponding LinIf index */
NetworkHandleType LinIfIndex = LinIf_ConfigPtr->LinIfChannelMap[Channel];
/** @req LINIF467 */
VALIDATE_W_RV( ( (LinIfChannelStatus[LinIfIndex] != LINIF_CHANNEL_SLEEP) && (LinIfChannelStatus[LinIfIndex] != LINIF_CHANNEL_SLEEP_TRANS) ), LINIF_SCHEDULEREQUEST_SERVICE_ID, LINIF_E_SCHEDULE_REQUEST_ERROR, E_NOT_OK);
newScheduleRequest[LinIfIndex] = TRUE;
/** @req LINIF389 */
newSchedule[LinIfIndex] = Schedule;
return E_OK;
}
/** @req LINIF204 */
Std_ReturnType LinIf_GotoSleep(NetworkHandleType Channel)
{
/** @req LINIF535 */
VALIDATE_W_RV( (LinIfStatus != LINIF_UNINIT), LINIF_GOTOSLEEP_SERVICE_ID, LINIF_E_UNINIT, E_NOT_OK);
/** @req LINIF564 */
VALIDATE_W_RV( ((Channel < LinIf_ConfigPtr->LinIfChannelMapSize) && (LinIf_ConfigPtr->LinIfChannelMap[Channel] < LINIF_CONTROLLER_CNT)), LINIF_GOTOSLEEP_SERVICE_ID, LINIF_E_NONEXISTENT_CHANNEL, E_NOT_OK);
/* Get the corresponding LinIf index */
NetworkHandleType LinIfIndex = LinIf_ConfigPtr->LinIfChannelMap[Channel];
if (LinIfChannelStatus[LinIfIndex] == LINIF_CHANNEL_OPERATIONAL) {
/** @req LINIF488 */
LinIfChannelStatus[LinIfIndex] = LINIF_CHANNEL_SLEEP_TRANS;
chSleepCmdAttmpt[LinIfIndex] = 0;
}
/** !req LINIF597 */ /* is not implemented since channel is already in sleep and calling Lin_GoToSleepInternal doesn't make difference */
/** @req LINIF113 */
return E_OK;
}
/** @req LINIF205 */
Std_ReturnType LinIf_WakeUp(NetworkHandleType Channel)
{
uint8 *Lin_SduPtr;
/** @req LINIF535 */
VALIDATE_W_RV( (LinIfStatus != LINIF_UNINIT), LINIF_WAKEUP_SERVICE_ID, LINIF_E_UNINIT, E_NOT_OK);
/** @req LINIF565 */
VALIDATE_W_RV( ((Channel < LinIf_ConfigPtr->LinIfChannelMapSize) && (LinIf_ConfigPtr->LinIfChannelMap[Channel] < LINIF_CONTROLLER_CNT)), LINIF_WAKEUP_SERVICE_ID, LINIF_E_NONEXISTENT_CHANNEL, E_NOT_OK);
NetworkHandleType LinChannelIndex = LinIf_ConfigPtr->LinIfChannelMap[Channel];
switch(LinIfChannelStatus[LinChannelIndex]) {
case LINIF_CHANNEL_SLEEP:
/** @req LINIF296 */
(void)Lin_Wakeup(LinIf_ConfigPtr->LinIfChannel[LinChannelIndex].LinIfLinChannelId); //Driver always returns E_OK
currentIndex[LinChannelIndex] = 0;
currentDelayInTicks[LinChannelIndex] = 0;
break;
case LINIF_CHANNEL_OPERATIONAL:
/** @req LINIF670 */
LinSM_WakeUp_Confirmation(Channel, TRUE);
break;
case LINIF_CHANNEL_SLEEP_TRANS:
/** @req LINIF459 */
if(0 == chSleepCmdAttmpt[LinChannelIndex]){
LinIfChannelStatus[LinChannelIndex] = LINIF_CHANNEL_OPERATIONAL;
} else if (Lin_GetStatus(LinIf_ConfigPtr->LinIfChannel[LinChannelIndex].LinIfLinChannelId, &Lin_SduPtr) == LIN_CH_SLEEP) {
LinIfChannelStatus[LinChannelIndex] = LINIF_CHANNEL_SLEEP;
/** @req LINIF460 */
(void)Lin_Wakeup(LinIf_ConfigPtr->LinIfChannel[LinChannelIndex].LinIfLinChannelId); //Driver always returns E_OK
currentIndex[LinChannelIndex] = 0;
currentDelayInTicks[LinChannelIndex] = 0;
chSleepCmdAttmpt[LinChannelIndex] = 0;
} else {
LinIfChannelStatus[LinChannelIndex] = LINIF_CHANNEL_OPERATIONAL;
LinSM_WakeUp_Confirmation(LinIf_ConfigPtr->LinIfChannel[LinChannelIndex].LinIfComMHandle, TRUE);
chSleepCmdAttmpt[LinChannelIndex] = 0;
}
break;
default:
break;
}
/* LINIF432: The function LinIf_WakeUp shall do nothing and return E_OK when the */
/* referenced channel is not in the sleep state. */
/** @req LINIF432 */
return E_OK;
}
/** @req LINIF039*//** @req LINIF287*//** @req LINIF384*/
void LinIf_MainFunction(void)
{
SchM_Enter_LinIf_EA_0();
uint8 chIndex;
uint8 *Lin_SduPtr;
if (LinIfStatus == LINIF_UNINIT) {
SchM_Exit_LinIf_EA_0();
/*lint -e{904} Return statement is necessary to avoid multiple if loops and hence increase readability in case of argument check */
return;
}
/** @req LINIF473 */ /** @req LINIF290 *//** @req LINIF386 */
for(chIndex = 0; chIndex < LINIF_CONTROLLER_CNT; chIndex++) {
/* Normal scheduling */
if(currentDelayInTicks[chIndex] > 0){
/* Not time for sending yet */
currentDelayInTicks[chIndex]--;
continue;
}
/* Check if there are any pending sleep transitions */
if (LinIfChannelStatus[chIndex] == LINIF_CHANNEL_SLEEP_TRANS) {
if (Lin_GetStatus(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &Lin_SduPtr) != LIN_CH_SLEEP) {
if (0==chSleepCmdAttmpt[chIndex]) {
/** @req LINIF453 */
(void)Lin_GoToSleep(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId); /* Driver always returns E_OK */
chSleepCmdAttmpt[chIndex]++;
}
else if(chSleepCmdAttmpt[chIndex] <= LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfSleepTransitionCycle) {
chSleepCmdAttmpt[chIndex]++;
} else {
/** @req LINIF454 */
/* The delay of sleep mode frame is assumed to be time_base arbitarily since ASR is not specific */
LinIfChannelStatus[chIndex] = LINIF_CHANNEL_OPERATIONAL;
chSleepCmdAttmpt[chIndex] = 0;
/** @req LINIF558 *//** @req LINIF521 */
LinSM_GotoSleep_Confirmation(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfComMHandle, FALSE);
}
} else {
/** @req LINIF455 */
LinIfChannelStatus[chIndex] = LINIF_CHANNEL_SLEEP;
/** @req LINIF557 */
LinSM_GotoSleep_Confirmation(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfComMHandle, TRUE);
/* Set NULL schedule at sleep */
/** @req LINIF444 *//** @req LINIF293 *//** @req LINIF043*/
currentIndex[chIndex] = 0;
currentDelayInTicks[chIndex] = 0;
currentSchedule[chIndex] = LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfScheduleTable;
}
continue;
}
/* Check if there are any wakeup transitions */
if (LinIfChannelStatus[chIndex] == LINIF_CHANNEL_SLEEP){
if (Lin_GetStatus(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &Lin_SduPtr) != LIN_CH_SLEEP) {
/** @req LINIF478 */
LinIfChannelStatus[chIndex] = LINIF_CHANNEL_OPERATIONAL;
/** @req LINIF496 */ /** @req LINIF522 */
LinSM_WakeUp_Confirmation(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfComMHandle, TRUE);
}
}
/** @req LINIF053 *//** @req LINIF189 *//** @req LINIF030 *//* by virtue of continue statement in the for loop where currentDelayInTicks is decremented this req LINIF030 is taken care*/
if(LinIfChannelStatus[chIndex] == LINIF_CHANNEL_OPERATIONAL) {
/* Check if NULL schedule is present otherwise check status of last sent */
if( (currentSchedule[chIndex] != NULL) && (currentSchedule[chIndex]->LinIfEntry != NULL)){ /*lint !e9032 Comparison with NULL is ok */
const LinIfEntryType *ptrEntry = ¤tSchedule[chIndex]->LinIfEntry[currentIndex[chIndex]];
const LinIf_FrameType *ptrFrame = &LinIf_ConfigPtr->LinIfFrameConfig[ptrEntry->LinIfFrameRef];
/* Handle received and sent frames */
if(ptrFrame->LinIfPduDirection == LinIfRxPdu){
Lin_StatusType linSts = Lin_GetStatus(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &Lin_SduPtr);
if(linSts == LIN_RX_OK){
PduInfoType outgoingPdu;
outgoingPdu.SduDataPtr = Lin_SduPtr;
outgoingPdu.SduLength = ptrFrame->LinIfLength;
/** @req LINIF289 *//** @req LINIF033 */ /** @req LINIF530 */
PduR_LinIfRxIndication(ptrFrame->LinIfTxTargetPduId,&outgoingPdu);
}else {/* RX_ERROR or BUSY */
/** @req LINIF254 *//** @req LINIF466*/
DET_REPORT_ERROR(LINIF_MAINFUNCTION_SERVICE_ID,LINIF_E_RESPONSE);
}
} else if(ptrFrame->LinIfPduDirection == LinIfTxPdu){
Lin_StatusType status = Lin_GetStatus(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &Lin_SduPtr);
if(status == LIN_TX_OK){
/** @req LINIF289 *//** @req LINIF128 *//** @req LINIF529*/
PduR_LinIfTxConfirmation(ptrFrame->LinIfTxTargetPduId);
}else{/* TX_ERROR or BUSY */
/** @req LINIF036 */ /** @req LINIF465*//** @req LINIF466*/
DET_REPORT_ERROR(LINIF_MAINFUNCTION_SERVICE_ID,LINIF_E_RESPONSE);
}
}else{
DET_REPORT_ERROR(LINIF_MAINFUNCTION_SERVICE_ID,LINIF_E_UNEXPECTED_EXECUTION);
}
/* Update index after getting status of last frame */
currentIndex[chIndex] = (currentIndex[chIndex] + 1) % currentSchedule[chIndex]->LinIfNofEntries;
/** @req LINIF485 */ /** @req LINIF397 */
if((currentIndex[chIndex] == 0)&&(currentSchedule[chIndex]->LinIfRunMode == RUN_ONCE)&&(newScheduleRequest[chIndex] == FALSE)){
currentSchedule[chIndex] = previousSchedule[chIndex];
if(previousSchedule[chIndex]->LinIfResumePosition == CONTINUE_AT_IT_POINT){
currentIndex[chIndex] = previousIndex[chIndex];
}else{
currentIndex[chIndex] = 0;
}
LinSM_ScheduleRequest_Confirmation(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfComMHandle,currentSchedule[chIndex]->LinIfScheduleTableIndex); /** Informing SM about Schedule table switching*/
}
}
handelSchedTransmission(chIndex);
}
}
SchM_Exit_LinIf_EA_0();
}
static inline void handelSchedTransmission(uint8 chIndex)
{
uint8 buf[8];
/* Set new schedule if ordered */
if(newScheduleRequest[chIndex] == TRUE){
/** @req LINIF028 */
if(currentSchedule[chIndex]->LinIfRunMode == RUN_CONTINUOUS){
if(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfScheduleTable[newSchedule[chIndex]].LinIfRunMode == RUN_ONCE)
{
previousSchedule[chIndex] = currentSchedule[chIndex];
previousIndex[chIndex] = currentIndex[chIndex];
}
currentSchedule[chIndex] = &LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfScheduleTable[newSchedule[chIndex]];
currentIndex[chIndex] = 0;
newScheduleRequest[chIndex]=FALSE;
/** @req LINIF495 *//** @req LINIF520 */
LinSM_ScheduleRequest_Confirmation(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfComMHandle,currentSchedule[chIndex]->LinIfScheduleTableIndex);
}else{
/** @req LINIF393 */
if(currentIndex[chIndex] == 0){
currentSchedule[chIndex] = &LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfScheduleTable[newSchedule[chIndex]];
currentIndex[chIndex] = 0;
newScheduleRequest[chIndex]=FALSE;
/** @req LINIF495 *//** @req LINIF520 */
LinSM_ScheduleRequest_Confirmation(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfComMHandle,currentSchedule[chIndex]->LinIfScheduleTableIndex);
}
}
}
/* Handle new transmissions */
if( (currentSchedule[chIndex] != NULL) && (currentSchedule[chIndex]->LinIfEntry != NULL_PTR)){
Lin_PduType PduInfo;
const LinIfEntryType *ptrEntry = ¤tSchedule[chIndex]->LinIfEntry[currentIndex[chIndex]];
const LinIf_FrameType *ptrFrame = &LinIf_ConfigPtr->LinIfFrameConfig[ptrEntry->LinIfFrameRef];
/** @req LINIF286 LINIF287 */
/* Only UNCONDITIONAL frames is supported in first version */
if (ptrFrame->LinIfFrameType == UNCONDITIONAL){
/* SendHeader */
if(ptrFrame->LinIfChecksumType==ENHANCED){
PduInfo.Cs = LIN_ENHANCED_CS;
}else{
PduInfo.Cs = LIN_CLASSIC_CS;
}
PduInfo.Pid = ptrFrame->LinIfPid;
PduInfo.SduPtr = buf; /* Data will be added in PduR_LinIfTriggerTransmit */
PduInfo.Dl = (Lin_FrameDIType)ptrFrame->LinIfLength;
if(ptrFrame->LinIfPduDirection == LinIfTxPdu){
PduInfo.Drc = LIN_MASTER_RESPONSE;
}else{
PduInfo.Drc = LIN_SLAVE_RESPONSE;
}
/* Maybe send response also */
if(ptrFrame->LinIfPduDirection == LinIfTxPdu){
if(ptrFrame->LinIfFixedFrameSdu != NULL){
PduInfo.SduPtr = ptrFrame->LinIfFixedFrameSdu;
/** @req LINIF224*/
(void)Lin_SendFrame(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &PduInfo);//Driver always returns E_OK
}else{
PduInfoType outgoingPdu;
outgoingPdu.SduDataPtr = PduInfo.SduPtr;
outgoingPdu.SduLength = (PduLengthType)PduInfo.Dl;
/* TX */
/** @req LINIF289 */ /** @req LINIF528 *//** @req LINIF225 */
(void)PduR_LinIfTriggerTransmit(ptrFrame->LinIfTxTargetPduId, &outgoingPdu);
/** @req LINIF224*//** @req LINIF419*//** @req LINIF226 */
(void)Lin_SendFrame(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &PduInfo);//Driver always returns E_OK
}
}
else {
/* RX */
(void)Lin_SendFrame(LinIf_ConfigPtr->LinIfChannel[chIndex].LinIfLinChannelId, &PduInfo);//Driver always returns E_OK
}
}
/* Set new delay */
uint16 temp = ptrEntry->LinIfDelay / LinIf_ConfigPtr->LinIfTimeBase ;
currentDelayInTicks[chIndex] = (temp > 0)? (temp - 1): 0; //LinIfDelay can be zero for the first frame on the table
}
}
#ifdef HOST_TEST
LinIf_StatusType* readInternal_LinIfChnlStatus(void);
LinIf_StatusType* readInternal_LinIfChnlStatus(void){
return LinIfChannelStatus ;
}
#endif
|
2301_81045437/classic-platform
|
communication/LinIf/src/LinIf.c
|
C
|
unknown
| 22,085
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "LinTp.h"
/* @req SWS_LinIf_00498 */
#if (LINIF_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
/*lint -e{551} */ /* ( [Temporary] Remove this exception after LinTp_Init() is filled up */
static LinTp_StatusType LinTpStatus = LINTP_UNINIT;
/*lint -emacro(904,VALIDATE,VALIDATE_W_RV)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
/** @req LINIF269*/ /** @req LINIF271*/
/* Development error macros. */
/* Development error macros. */
#if ( LINIF_DEV_ERROR_DETECT == STD_ON )
#define VALIDATE(_exp,_api,_err ) \
if( !(_exp) ) { \
(void)Det_ReportError(LINIF_MODULE_ID,0,_api,_err); \
return; \
}
#define VALIDATE_W_RV(_exp,_api,_err,_rv ) \
if( !(_exp) ) { \
(void)Det_ReportError(LINIF_MODULE_ID,0,_api,_err); \
return (_rv); \
}
#define DET_REPORT_ERROR(_api,_err) (void)Det_ReportError(LINIF_MODULE_ID, 0, _api, _err);
#else
#define VALIDATE(_exp,_api,_err )
#define VALIDATE_W_RV(_exp,_api,_err,_rv )
#define DET_REPORT_ERROR(_api,_err)
#endif
/** @req SWS_LinIf_00350 */
void LinTp_Init( const LinTp_ConfigType* ConfigPtr )
{
/*lint -e715 */ /* ( [Temporary] Remove this exception after LinTp_Init() is filled up */
/** @req SWS_LinIf_00483 */
LinTpStatus = LINTP_INIT;
}
/** @req SWS_LinIf_00351 */
Std_ReturnType LinTp_Transmit(PduIdType LinTxPduId,const PduInfoType* PduInfoPtr)
{
(void)LinTxPduId;
//lint -estring(920,pointer) /* cast to void */
(void)PduInfoPtr;
//lint +estring(920,pointer) /* cast to void */
/* Sporadic frames not supported in this release */
/*printf("LinIf_Transmit received request. Id: %d, Data: %d\n", LinTxPduId, *(PduInfoPtr->SduDataPtr));*/
return E_OK;
}
/* @req SWS_LinIf_00639 */
/* @req SWS_LinIf_00352 */
/** @brief Return the version information of LinTp module.
*
* The function LinTp_GetVersionInfo shall return the version
* information of the LinTp module.
* The version information includes:
* - Module Id
* - Vendor Id
* - sw_major_version
* - sw_minor_version
* - sw_patch_version
*
* The function LinTp_GetVersionInfo raises a development error "LINIF_E_PARAM_POINTER."
* if versioninfo has an invalid value
*
* @param Std_VersionInfoType The type including Module and Vendor ID for the LinTP Module.
* @return void.
*/
void LinTp_GetVersionInfo(Std_VersionInfoType* versioninfo) {
VALIDATE((versioninfo != NULL_PTR),LINTP_GETVERSIONINFO_SERVICE_ID,LINIF_E_PARAM_POINTER);
versioninfo->vendorID = LINTP_VENDOR_ID;
versioninfo->moduleID = LINTP_MODULE_ID;
versioninfo->sw_major_version = LINTP_SW_MAJOR_VERSION;
versioninfo->sw_minor_version = LINTP_SW_MINOR_VERSION;
versioninfo->sw_patch_version = LINTP_SW_PATCH_VERSION;
}
/** @req SWS_LinIf_00355 */
void LinTp_Shutdown(void)
{
/* @req SWS_LinIf_00484 */
LinTpStatus = LINTP_UNINIT;
}
/** @req SWS_LinIf_00501 */
Std_ReturnType LinTp_ChangeParameter(PduIdType id,TPParameterType parameter,uint16 value)
{
return E_OK;
}
/** @req SWS_LinIf_00625 */
Std_ReturnType LinTp_CancelReceive(PduIdType RxPduId)
{
return E_OK;
}
/** @req SWS_LinIf_00500 */
Std_ReturnType LinTp_CancelTransmit(PduIdType TxPduId)
{
return E_OK;
}
#ifdef HOST_TEST
LinTp_StatusType readInternal_LinTpStatus(void);
LinTp_StatusType readInternal_LinTpStatus(void){
return LinTpStatus;
}
#endif
|
2301_81045437/classic-platform
|
communication/LinIf/src/LinTp.c
|
C
|
unknown
| 4,258
|
#LinSM
obj-$(USE_LINSM) += LinSM_Lcfg.o
obj-$(USE_LINSM) += LinSM_Cfg.o
obj-$(USE_LINSM) += LinSM.o
inc-$(USE_LINSM) += $(ROOTDIR)/communication/LinSM/inc
vpath-$(USE_LINSM) += $(ROOTDIR)/communication/LinSM/src
|
2301_81045437/classic-platform
|
communication/LinSM/LinSM.mod.mk
|
Makefile
|
unknown
| 218
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @req LINSM005 */
#ifndef LINSM_H_
#define LINSM_H_
#define LINSM_MODULE_ID 141u
#define LINSM_VENDOR_ID 60u
#define LINSM_SW_MAJOR_VERSION 2u
#define LINSM_SW_MINOR_VERSION 4u
#define LINSM_SW_PATCH_VERSION 0u
#define LINSM_AR_RELEASE_MAJOR_VERSION 4u
#define LINSM_AR_RELEASE_MINOR_VERSION 0u
#define LINSM_AR_RELEASE_PATCH_VERSION 3u
#include "ComStack_Types.h"
#include "Std_Types.h"
#include "Lin_GeneralTypes.h"
#include "LinSM_Cfg.h"
#include "Com_Types.h"
#if defined(USE_COM)
#include "Com.h"
#endif
#include "ComM_Types.h"
#include "LinIf.h"
#define LINSM_INIT_SERVICE_ID 0x01u
#define LINSM_GET_CURRENT_COM_MODE_SERVICE_ID 0x11u
#define LINSM_REQUEST_COM_MODE_SERVICE_ID 0x12u
#define LINSM_SCHEDULE_REQUEST_SERVICE_ID 0x10u
#define LINSM_SCHEDULE_REQUEST_CONF_SERVICE_ID 0x20u
#define LINSM_WAKEUP_CONF_SERVICE_ID 0x21u
#define LINSM_GOTO_SLEEP_CONF_SERVICE_ID 0x22u
#define LINSM_MAIN_FUNCTION_SERVICE_ID 0x30u
/**@req LINSM052*//**@req LINSM053*/
/* --- Error codes --- */
#define LINSM_E_UNINIT (uint8) 0x00u
#define LINSM_E_ALREADY_INITIALIZED (uint8) 0x10u
#define LINSM_E_NONEXISTENT_NETWORK (uint8) 0x20u
#define LINSM_E_PARAMETER (uint8) 0x30u
#define LINSM_E_PARAMETER_POINTER (uint8) 0x40u
#define LINSM_E_CONFIRMATION_TIMEOUT (uint8) 0x50u /* Assigned by DEM */
typedef enum {
LINSM_UNINIT,
LINSM_INIT,
LINSM_NO_COMMUNICATION,
LINSM_FULL_COMMUNICATION
}LinSM_StatusType;
typedef enum {
/** @req LINSM0220 */
LINSM_NO_COM = 1, /* @req LINSM026 */
LINSM_FULL_COM =2 /* @req LINSM032 */
}LinSM_ModeType;
/**@req LINSM117 *//**@req LINSM118 *//**@req LINSM121 *//**@req LINSM165 */
#if (LINSM_VERSION_INFO_API == STD_ON)
void LinSM_GetVersionInfo( Std_VersionInfoType *versionInfo );
#define LinSM_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,LINSM)
#endif
void LinSM_Init(const LinSM_ConfigType* ConfigPtr);
void LinSM_DeInit(void);
Std_ReturnType LinSM_ScheduleRequest(NetworkHandleType channel,LinIf_SchHandleType schedule);
Std_ReturnType LinSM_GetCurrentComMode(NetworkHandleType network,ComM_ModeType* mode);
Std_ReturnType LinSM_RequestComMode(NetworkHandleType network,ComM_ModeType mode);
void LinSM_MainFunction(void);
#endif
|
2301_81045437/classic-platform
|
communication/LinSM/inc/LinSM.h
|
C
|
unknown
| 3,205
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @req LINSM006 */
#ifndef LINSM_CBK_H_
#define LINSM_CBK_H_
#include "ComStack_Types.h"
#include "LinIf_Types.h"
void LinSM_ScheduleRequest_Confirmation(NetworkHandleType channel,LinIf_SchHandleType schedule);
void LinSM_WakeUp_Confirmation(NetworkHandleType channel,boolean success);
void LinSM_GotoSleep_Confirmation(NetworkHandleType channel,boolean success);
#endif
|
2301_81045437/classic-platform
|
communication/LinSM/inc/LinSM_Cbk.h
|
C
|
unknown
| 1,161
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/**
* @file LinSM_ConfigTypes.h Configuration types for LinSM.
*
* This file defines the LinSm type LinSM_ConfigType and all other needed types.
* They reflect the structure of the configuration parameters described in the
* LinSM specification and their relations.
* These types are used in the generated configuration files for LinSM.
*/
#ifndef LINSM_CONFIGTYPES_H_
#define LINSM_CONFIGTYPES_H_
#include "Std_Types.h"
#include "LinIf_Types.h"
/*-----------[LinSMSchedule]--------------------------------------------------*/
/* Stores the configuration data of a LinSMSchedule object.
* See item LINSM146_Conf. */
typedef struct
{
/* LinIf schedule table identifier.
* The value of the LinSMScheduleIndex shall be the same
* as the value from the LinIf. */
const LinIf_SchHandleType LinSMScheduleIndex;
}
LinSM_ScheduleType;
/*-----------[LinSMChannel]---------------------------------------------------*/
/* Stores the configuration data of a LinSMChannel object.
* See item LINSM142_Conf. */
typedef struct
{
/* Timeout in milliseconds for the goto sleep and wakeup calls to LinIf. */
uint32 LinSMConfirmationTimeout;
boolean LinSMSleepSupport;
/* Selects STANDBY (true) or SLEEP (false) transceiver mode when
* entering LINSM_NO_COM. */
boolean LinSMTransceiverPassiveMode;
/* Unique handle to identify one certain LIN network. */
NetworkHandleType LinSMComMNetworkHandleRef;
/* List of LinSMSchedule objects assigned to this channel. */
const LinSM_ScheduleType *LinSMSchedules;
/* Number of LinSMSchedule (size of the array LinSMSchedule) */
const uint8 LinSMSchedule_Cnt;
}
LinSM_ChannelType;
/*-----------[LinSM_ConfigType]-----------------------------------------------*/
/**@req LINSM0221 */
/* Configuration of the LinSm module.
* See item LINSM0221 */
typedef struct
{
/* Array of setup LinSMChannel objects */
const LinSM_ChannelType *LinSMChannels;
/* Number of setup LinSMChannel objects (size of array LinSMChannels) */
const uint32 LinSMChannels_Size;
}
LinSM_ConfigType;
#endif // LINSM_CONFIGTYPES_H_
|
2301_81045437/classic-platform
|
communication/LinSM/inc/LinSM_ConfigTypes.h
|
C
|
unknown
| 2,978
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/**@req LINSM001 *//* LIN Interface – LinIf is interfaced with LINSM */
/**@req LINSM002 *//* The LinSM module shall not use or access the LIN driver or assume information about it any way other than what the LinIf module provides through the function calls to the LinIf module */
/**@req LINSM054 *//* The detection of development errors is configurable (ON/OFF) at precompile time */
/**@req LINSM073 *//* The LinSM module shall not make any consistency check of the configuration in run-time inproduction software */
/**@req LINSM105 *//* Communication Manager – ComM is interfaced */
/**@req LINSM138 *//* Optional Interfaced */
/**@req LINSM196 *//* BSW Mode Manager - BswM is interfaced */
/**@req LINSM200 *//* Additional errors that are detected because of specific implementation and/or specific hardware propertiesshall be added in the module’s implementation documentation */
/**@req LINSM219 *//* Types are used by the LinSM module */
#include "Std_Types.h"
#include "Lin.h"
#include "LinIf.h" /**@req LINSM012 */
#include "LinSM.h"
#include "LinSM_Cbk.h"
#include "LinIf_Types.h"
#if defined(USE_COM)
#include "Com.h"
#endif
#include "ComM_Types.h"
#include "ComStack_Types.h" /**@req LINSM016 */
#include "Com_Types.h"
#include "ComM_BusSM.h"
#if ( LINSM_DEV_ERROR_DETECT == STD_ON )
#include "Det.h" /**@req LINSM015 */
#endif
#include "SchM_LinSM.h"
#if defined(USE_BSWM)
/*@req LINSM201 Including BswM_LinSM.h and not BswM.h */
#include "BswM_LinSM.h"
#endif
#include "Mcu.h"
#include "LinSM_ConfigTypes.h"
/*==================[macros]==================================================*/
/*lint -emacro(904,VALIDATE,VALIDATE_W_RV)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
/**@req LINSM055 */ /**@req LINSM057 *//**@req LINSM086 */
/* Development error macros. */
#if ( LINSM_DEV_ERROR_DETECT == STD_ON )
#define LINSM_DET_REPORT_ERROR(_api, _err) (void)Det_ReportError(LINSM_MODULE_ID,0,_api,_err)
#define VALIDATE(_exp,_api,_err ) \
if( !(_exp) ) { \
(void)Det_ReportError(LINSM_MODULE_ID,0,_api,_err); \
return; \
}
#define VALIDATE_W_RV(_exp,_api,_err,_rv ) \
if( !(_exp) ) { \
(void)Det_ReportError(LINSM_MODULE_ID,0,_api,_err); \
return (_rv); \
}
#else
#define LINSM_DET_REPORT_ERROR(_api, _err)
#define VALIDATE(_exp,_api,_err )
#define VALIDATE_W_RV(_exp,_api,_err,_rv )
#endif
#if defined(USE_BSWM)
#define BSWM_LINSM_CURRENTSCHEDULE(_ch, _sch) \
BswM_LinSM_CurrentSchedule(_ch,_sch); \
#define BSWM_LINSM_CURRENTSTATE(_ch,_state) \
BswM_LinSM_CurrentState(_ch,_state); \
#else
#define BSWM_LINSM_CURRENTSCHEDULE(_ch, _sch)
#define BSWM_LINSM_CURRENTSTATE(_ch,_state)
#endif
/*==================[internal data]===========================================*/
/* Timer values for every LinIf channel. These timers are used to monitor the
* confirmation of a specific command after calling LinIf_GotoSleep,
* LinIf_Wakeup or LinIf_ScheduleRequest. The arrays are indexed by the LinSM
* channel index (NOT the LinIf channel id).
*
* See Specification of LIN State Manager, R4.0 Rev 3,
* 7.1.8 Timeout of requests. */
/** @req LINSM175 */
static uint32 ScheduleRequestTimer [LINSM_CHANNEL_CNT];
static uint32 GoToSleepTimer [LINSM_CHANNEL_CNT];
static uint32 WakeUpTimer [LINSM_CHANNEL_CNT];
static boolean ScheduleRequest_Ok [LINSM_CHANNEL_CNT];
static void DecrementTimer(uint32 *timer);
/* LinSM module state *//**@req LINSM161 */
static LinSM_StatusType LinSMStatus = LINSM_UNINIT;
/* Channel states. The arrays are indexed by the LinSM
* channel index. */
static LinSM_StatusType LinSMChannelStatus[LINSM_CHANNEL_CNT];
static LinIf_SchHandleType LinSMSchTablCurr[LINSM_CHANNEL_CNT];
static LinIf_SchHandleType LinSMSchTablNew[LINSM_CHANNEL_CNT];
static const LinSM_ConfigType *LinSMConfigPtr;
/*=========================[Local functions]===========================*/
/**
* Get the index (in LinSM configuration) for a Lin channel
* @param channel
* @param channelIndex
* @return TRUE: index found, FALSE: invalid Lin channel
*/
static Std_ReturnType GetChannelIndex(NetworkHandleType channel, uint32 *channelIndex)
{
Std_ReturnType ret = E_NOT_OK;
for (uint32 i = 0; (i < LinSMConfigPtr->LinSMChannels_Size) && (E_OK != ret); i++) {
if(channel == LinSMConfigPtr->LinSMChannels[i].LinSMComMNetworkHandleRef) {
*channelIndex = i;
ret = E_OK;
}
}
return ret;
}
#if ( LINSM_DEV_ERROR_DETECT == STD_ON )
/**
* Checks if a schedule is configured for a specific channel
* @param channelIndex
* @param schedule
* @return TRUE: valid schedule, FALSE: schedule not configured for this channel
*/
static boolean CheckScheduleValid(uint32 channelIndex, LinIf_SchHandleType schedule)
{
boolean isValid = FALSE;
const LinSM_ScheduleType *schedulePtr = LinSMConfigPtr->LinSMChannels[channelIndex].LinSMSchedules;
for(uint8 schIndex = 0; (schIndex < LinSMConfigPtr->LinSMChannels[channelIndex].LinSMSchedule_Cnt) && (FALSE == isValid); schIndex++) {
/* IMPROVEMNT: Is it ok to request the NULL schedule? */
if((schedule == schedulePtr->LinSMScheduleIndex) || (0 == schedule)) {
isValid = TRUE;
}
schedulePtr++;
}
return isValid;
}
#endif
/*==================[Implementation of LinSM interface]=======================*/
/*------------------[Initialization]------------------------------------------*/
/**@req LINSM155 *//**@req LINSM020 */
void LinSM_Init(const LinSM_ConfigType* ConfigPtr)
{
/**@req LINSM151 *//**@req LINSM166 *//**@req LINSM173 */
uint32 i;
VALIDATE( (ConfigPtr!=NULL), LINSM_INIT_SERVICE_ID, LINSM_E_PARAMETER_POINTER );
LinSMConfigPtr = ConfigPtr;
for (i = 0; i < LinSMConfigPtr->LinSMChannels_Size; i++)
{
/** @req LINSM160 *//**@req LINSM152 */
LinSMChannelStatus[i] = LINSM_NO_COMMUNICATION;
/** @req LINSM0216 */
LinSMSchTablCurr[i]= 0; //NULL Schedule
LinSMSchTablNew[i]=0;
ScheduleRequestTimer[i] = 0;
GoToSleepTimer[i] = 0;
WakeUpTimer[i] = 0;
ScheduleRequest_Ok[i] = TRUE;
}
LinSMStatus = LINSM_INIT; /** @req LINSM024 *//** @req LINSM025 *//** @req LINSM043 */
}
/*------------------[Deinitialization]----------------------------------------*/
void LinSM_DeInit()
{
LinSMStatus = LINSM_UNINIT; /** @req LINSM022 */
}
/*------------------[Schedule Request]----------------------------------------*/
/**@req LINSM113*/
Std_ReturnType LinSM_ScheduleRequest(NetworkHandleType channel,LinIf_SchHandleType schedule)
{
Std_ReturnType rv;
uint32 channelIndex = 0;
/** @req LINSM116 *//** @req LINSM032 */
VALIDATE_W_RV( (LinSMStatus != LINSM_UNINIT), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_UNINIT, E_NOT_OK);
/** @req LINSM114 */
rv = GetChannelIndex(channel, &channelIndex);
VALIDATE_W_RV( (E_OK == rv), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_NONEXISTENT_NETWORK, E_NOT_OK);
/** @req LINSM115 */
VALIDATE_W_RV( (TRUE == CheckScheduleValid(channelIndex, schedule)), LINSM_SCHEDULE_REQUEST_SERVICE_ID, LINSM_E_PARAMETER, E_NOT_OK);
/** @req LINSM163 *//** @req LINSM10211 */
if ((ScheduleRequestTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD) || (LINSM_FULL_COMMUNICATION != LinSMChannelStatus[channelIndex])) {
rv = E_NOT_OK;
}
else {
/* Set the Schedule Request confirmation timer for the specified channel. */
/** @req LINSM100 */
ScheduleRequestTimer[channelIndex] = LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout;
LinSMSchTablNew[channelIndex] = schedule;
/** @req LINSM164 *//**@req LINSM079*//**@req LINSM167*//**@req LINSM168*/
rv = LinIf_ScheduleRequest(channel, schedule);
if (rv != E_OK) {
ScheduleRequest_Ok[channelIndex] = FALSE;
ScheduleRequestTimer[channelIndex] = 0;
}
}
return rv;
}
/*------------------[Get current COM mode]------------------------------------*/
/** @req LINSM021 *//** @req LINSM122 */
Std_ReturnType LinSM_GetCurrentComMode(NetworkHandleType network,ComM_ModeType* mode)
{
Std_ReturnType ret;
uint32 channelIndex = 0;
/** @req LINSM182 */
/* If active state is LINSM_UNINIT the state
* COMM_NO_COMMUNICATION shall be returned. */
if ((LinSMStatus == LINSM_UNINIT) && (mode != NULL_PTR)) {
*mode= COMM_NO_COMMUNICATION;
}
/** @req LINSM125 */
VALIDATE_W_RV( (LinSMStatus != LINSM_UNINIT), LINSM_GET_CURRENT_COM_MODE_SERVICE_ID, LINSM_E_UNINIT, E_NOT_OK);
/** @req LINSM123 */
ret = GetChannelIndex(network, &channelIndex);
VALIDATE_W_RV( (E_OK == ret), LINSM_GET_CURRENT_COM_MODE_SERVICE_ID, LINSM_E_NONEXISTENT_NETWORK, E_NOT_OK);
/** @req LINSM124 */
VALIDATE_W_RV( (mode != NULL_PTR), LINSM_GET_CURRENT_COM_MODE_SERVICE_ID, LINSM_E_PARAMETER_POINTER, E_NOT_OK);
switch (LinSMChannelStatus[channelIndex]) {
case LINSM_FULL_COMMUNICATION:
/** @req LINSM181 */
*mode= COMM_FULL_COMMUNICATION;
break;
default:
/** @req LINSM180 */
*mode= COMM_NO_COMMUNICATION;
break;
}
return E_OK;
}
/*------------------[Request new COM mode]------------------------------------*/
/** @req LINSM126 */
Std_ReturnType LinSM_RequestComMode(NetworkHandleType network,ComM_ModeType mode)
{
Std_ReturnType res;
uint32 channelIndex = 0;
boolean tempflg;
boolean timeflg;
timeflg = FALSE;
/** @req LINSM128 */
VALIDATE_W_RV( (LinSMStatus != LINSM_UNINIT), LINSM_REQUEST_COM_MODE_SERVICE_ID, LINSM_E_UNINIT, E_NOT_OK);
/** @req LINSM127 */
res = GetChannelIndex(network, &channelIndex);
VALIDATE_W_RV( (E_OK == res), LINSM_REQUEST_COM_MODE_SERVICE_ID, LINSM_E_NONEXISTENT_NETWORK, E_NOT_OK);
/** @req LINSM191 */
VALIDATE_W_RV( ((mode == COMM_NO_COMMUNICATION) || (mode == COMM_SILENT_COMMUNICATION) || (mode == COMM_FULL_COMMUNICATION)), LINSM_REQUEST_COM_MODE_SERVICE_ID, LINSM_E_PARAMETER_POINTER, E_NOT_OK);
res = E_NOT_OK;
/** @req LINSM035 */
tempflg = (boolean)(((COMM_NO_COMMUNICATION == mode) && (LINSM_NO_COMMUNICATION == LinSMChannelStatus[channelIndex])) ||
((COMM_FULL_COMMUNICATION == mode) && (LINSM_FULL_COMMUNICATION == LinSMChannelStatus[channelIndex])));
if(0 != LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout){
timeflg = ((WakeUpTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD) || (GoToSleepTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD)) ? TRUE : FALSE;
}
/** @req LINSM0210 *//** @req LINSM174 *//** @req LINSM044 */
if ((TRUE == tempflg) || (TRUE == timeflg)) {
res = E_NOT_OK;
} else {
switch(mode)
{ /** @req LINSM178 */ /** @req LINSM10209*/
case COMM_NO_COMMUNICATION:
/* Set the GotoSleep confirmation timer for the specified channel. */
/** @req LINSM100 */
GoToSleepTimer[channelIndex] = LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout;
/** @req LINSM036 *//** @req LINSM10208 */
if (E_OK == LinIf_GotoSleep(network)){
res = E_OK;
}
else {
/** @req LINSM177 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, LINSM_FULL_COM);
ComM_ModeType ComMode;
ComMode = COMM_FULL_COMMUNICATION;
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
GoToSleepTimer[channelIndex] = 0;
}
break;
case COMM_SILENT_COMMUNICATION:
// Standard say nothing about this case.
/** @req LINSM183 */
break;
case COMM_FULL_COMMUNICATION:
/* Set the Wakeup confirmation timer for the specified channel. */
/** @req LINSM100 */
WakeUpTimer[channelIndex] = LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout;
/** @req LINSM047 *//** @req LINSM164 *//** @req LINSM176 */
if (E_OK == LinIf_WakeUp(network)){
res = E_OK;
}
else
{
/** @req LINSM0202 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef,LINSM_NO_COM);
ComM_ModeType ComMode;
ComMode = COMM_NO_COMMUNICATION;
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
WakeUpTimer[channelIndex] = 0;
}
break;
default:
break;
}
}
return res;
}
/*------------------[Schedule request confirmation]---------------------------*/
/** @req LINSM129 */
void LinSM_ScheduleRequest_Confirmation(NetworkHandleType channel,LinIf_SchHandleType schedule)
{
Std_ReturnType ret;
uint32 channelIndex = 0;
/** @req LINSM131 */
VALIDATE( (LinSMStatus != LINSM_UNINIT), LINSM_SCHEDULE_REQUEST_CONF_SERVICE_ID, LINSM_E_UNINIT);
/** @req LINSM130 */
ret = GetChannelIndex(channel, &channelIndex);
VALIDATE( (E_OK == ret), LINSM_SCHEDULE_REQUEST_CONF_SERVICE_ID, LINSM_E_NONEXISTENT_NETWORK);
if(LinSMSchTablNew[channelIndex] == schedule){
if ((ScheduleRequestTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD)||(0 == LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout)){
LinSMSchTablCurr[channelIndex] = LinSMSchTablNew[channelIndex];
/** @req LINSM206 */
BSWM_LINSM_CURRENTSCHEDULE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, LinSMSchTablCurr[channelIndex]);
}
}else{
/**@req LINSM207 */
BSWM_LINSM_CURRENTSCHEDULE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, schedule);
}
/** @req LINSM154 */
ScheduleRequestTimer[channelIndex] = 0;
}
/*------------------[Wakeup confirmation]-------------------------------------*/
/** @req LINSM132 */
void LinSM_WakeUp_Confirmation(NetworkHandleType channel,boolean success)
{
Std_ReturnType ret;
uint32 channelIndex = 0;
/** @req LINSM134 */
VALIDATE( (LinSMStatus != LINSM_UNINIT), LINSM_WAKEUP_CONF_SERVICE_ID, LINSM_E_UNINIT);
/** @req LINSM133 */
ret = GetChannelIndex(channel, &channelIndex);
VALIDATE( (E_OK == ret), LINSM_WAKEUP_CONF_SERVICE_ID, LINSM_E_NONEXISTENT_NETWORK);
/** @req LINSM172 */
if((WakeUpTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD)||(0 == LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout)){
if(TRUE == success)
{
ComM_ModeType ComMode = COMM_FULL_COMMUNICATION;
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
/**@req LINSM049 */
LinSMChannelStatus[channelIndex] = LINSM_FULL_COMMUNICATION;
/** @req LINSM192 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef,LINSM_FULL_COM);
}
else {
LinSMChannelStatus[channelIndex] = LINSM_NO_COMMUNICATION;
/** @req LINSM0202 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef,LINSM_NO_COM);
ComM_ModeType ComMode;
ComMode = COMM_NO_COMMUNICATION;
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
}
}
/** @req LINSM154 */
WakeUpTimer[channelIndex] = 0;
}
/*------------------[GotoSleep confirmation]----------------------------------*/
/** @req LINSM135 */
void LinSM_GotoSleep_Confirmation(NetworkHandleType channel,boolean success)
{
Std_ReturnType ret;
uint32 channelIndex = 0;
/** @req LINSM137 */
VALIDATE( (LinSMStatus != LINSM_UNINIT), LINSM_GOTO_SLEEP_CONF_SERVICE_ID, LINSM_E_UNINIT);
/** @req LINSM136 */
ret = GetChannelIndex(channel, &channelIndex);
VALIDATE( (E_OK == ret), LINSM_GOTO_SLEEP_CONF_SERVICE_ID, LINSM_E_NONEXISTENT_NETWORK);
/** @req LINSM172 */
if((GoToSleepTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD)||(0 == LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout)){
if(TRUE == success)
{ /** @req LINSM045 *//** @req LINSM028 */
LinSMChannelStatus[channelIndex] = LINSM_NO_COMMUNICATION;
ComM_ModeType ComMode = COMM_NO_COMMUNICATION;
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
/** @req LINSM193 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef,LINSM_NO_COM);
}
else {
LinSMChannelStatus[channelIndex] = LINSM_FULL_COMMUNICATION;
/** @req LINSM177 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef,LINSM_FULL_COM);
ComM_ModeType ComMode;
/** @req LINSM046 */
ComMode = COMM_FULL_COMMUNICATION;
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
}
}
/** @req LINSM154 */
GoToSleepTimer[channelIndex] = 0;
}
/*==================[Main function]==========================================*/
/**@req LINSM156 */
void LinSM_MainFunction(void)
{
uint32 channelIndex;
ComM_ModeType ComMode;
/** @req LINSM179 */
VALIDATE( (LinSMStatus != LINSM_UNINIT), LINSM_MAIN_FUNCTION_SERVICE_ID, LINSM_E_UNINIT);
SchM_Enter_LinSM_EA_0();
/** @req LINSM157 *//** @req LINSM019 */
for(channelIndex = 0; channelIndex < LinSMConfigPtr->LinSMChannels_Size; channelIndex++){
/**@req LINSM103 */
if(0 != LinSMConfigPtr->LinSMChannels[channelIndex].LinSMConfirmationTimeout)
{
if(FALSE == ScheduleRequest_Ok[channelIndex]){
/** @req LINSM0213 */
BSWM_LINSM_CURRENTSCHEDULE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, LinSMSchTablCurr[channelIndex]);
}
if(ScheduleRequestTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD){
DecrementTimer(&ScheduleRequestTimer[channelIndex]);
if (ScheduleRequestTimer[channelIndex] < LINSM_MAIN_PROCESSING_PERIOD) {
/** @req LINSM0214 */
BSWM_LINSM_CURRENTSCHEDULE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, LinSMSchTablCurr[channelIndex]);
/** @req LINSM102 */
LINSM_DET_REPORT_ERROR(LINSM_MAIN_FUNCTION_SERVICE_ID, LINSM_E_CONFIRMATION_TIMEOUT);
}
}
if(GoToSleepTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD){
DecrementTimer(&GoToSleepTimer[channelIndex]);
if (GoToSleepTimer[channelIndex] < LINSM_MAIN_PROCESSING_PERIOD) {
ComMode = COMM_FULL_COMMUNICATION;
/** @req LINSM170 *//** @req LINSM033 */
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
/** @req LINSM215 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, LINSM_FULL_COM);
/** @req LINSM102 */
LINSM_DET_REPORT_ERROR(LINSM_MAIN_FUNCTION_SERVICE_ID, LINSM_E_CONFIRMATION_TIMEOUT);
}
}
if(WakeUpTimer[channelIndex] >= LINSM_MAIN_PROCESSING_PERIOD){
DecrementTimer(&WakeUpTimer[channelIndex]);
if (WakeUpTimer[channelIndex] < LINSM_MAIN_PROCESSING_PERIOD) {
ComMode = COMM_NO_COMMUNICATION;
/** @req LINSM170 */ /** @req LINSM027 */
ComM_BusSM_ModeIndication(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef, &ComMode);
/** @req LINSM215 */
BSWM_LINSM_CURRENTSTATE(LinSMConfigPtr->LinSMChannels[channelIndex].LinSMComMNetworkHandleRef,LINSM_NO_COM);
/** @req LINSM102 */
LINSM_DET_REPORT_ERROR(LINSM_MAIN_FUNCTION_SERVICE_ID, LINSM_E_CONFIRMATION_TIMEOUT);
}
}
}
}
SchM_Exit_LinSM_EA_0();
}
/** @req LINSM162*/
static void DecrementTimer(uint32 *timer) {
/** @req LINSM159*/
*timer = *timer - LINSM_MAIN_PROCESSING_PERIOD;
/** @req LINSM101*/
if(*timer < LINSM_MAIN_PROCESSING_PERIOD){
/** @req LINSM102*/
(void)Det_ReportError(LINSM_MODULE_ID,0,LINSM_MAIN_FUNCTION_SERVICE_ID,LINSM_E_CONFIRMATION_TIMEOUT);
}
}
/*==================[end of file]=============================================*/
#ifdef HOST_TEST
LinSM_StatusType* readInternal_LinSmChnlStatus(void);
LinSM_StatusType* readInternal_LinSmChnlStatus(void){
return LinSMChannelStatus;
}
LinIf_SchHandleType* readInternal_LinSmSchedule(void);
LinIf_SchHandleType* readInternal_LinSmSchedule(void){
return LinSMSchTablCurr;
}
uint32* readInternal_ScheduleTimer(void);
uint32* readInternal_ScheduleTimer(void){
return ScheduleRequestTimer;
}
uint32* readInternal_GoToSleepTimer(void);
uint32* readInternal_GoToSleepTimer(void){
return GoToSleepTimer;
}
uint32* readInternal_WakeUpTimer(void);
uint32* readInternal_WakeUpTimer(void){
return WakeUpTimer;
}
#endif
|
2301_81045437/classic-platform
|
communication/LinSM/src/LinSM.c
|
C
|
unknown
| 23,422
|
# Nm
obj-$(USE_NM) += Nm.o
obj-$(USE_NM) += Nm_Cfg.o
ifeq ($(filter Nm_Extension.o,$(obj-y)),)
obj-$(USE_NM_EXTENSION) += Nm_Extension.o
endif
inc-$(USE_NM) += $(ROOTDIR)/communication/Nm/inc
vpath-$(USE_NM) += $(ROOTDIR)/communication/Nm/src
|
2301_81045437/classic-platform
|
communication/Nm/Nm.mod.mk
|
Makefile
|
unknown
| 251
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef NM_H_
#define NM_H_
#include "Std_Types.h" /** @req NM124 */
#include "ComStack_Types.h"
#include "NmStack_Types.h" /** @req NM123 */
#include "Nm_ConfigTypes.h"
#include "ComM_Nm.h" /** @req NM124 */
#define NM_VENDOR_ID 60u
#define NM_MODULE_ID 29u
#define NM_AR_RELEASE_MAJOR_VERSION 4u
#define NM_AR_RELEASE_MINOR_VERSION 0u
#define NM_AR_RELEASE_PATCH_VERSION 3u
#define NM_AR_MAJOR_VERSION NM_AR_RELEASE_MAJOR_VERSION
#define NM_AR_MINOR_VERSION NM_AR_RELEASE_MINOR_VERSION
#define NM_AR_PATCH_VERSION NM_AR_RELEASE_PATCH_VERSION
#define NM_SW_MAJOR_VERSION 3u
#define NM_SW_MINOR_VERSION 2u
#define NM_SW_PATCH_VERSION 1u
#include "Nm_Cfg.h" /** @req NM123 */
/** @req Nm232 */
/* Error codes*/
#define NM_E_UNINIT 0u
#define NM_E_HANDLE_UNDEF 1u
#define NM_E_PARAM_POINTER 2u
/* Api Service codes */
#define NM_SERVICEID_INIT 0x00u
#define NM_SERVICEID_PASSIVESTARTUP 0x01u
#define NM_SERVICEID_NETWORKREQUEST 0x02u
#define NM_SERVICEID_NETWORKRELEASE 0x03u
#define NM_SERVICEID_DISABLECOMMUNICATION 0x04u
#define NM_SERVICEID_ENABLECOMMUNICATION 0x05u
#define NM_SERVICEID_SETUSERDATA 0x06u
#define NM_SERVICEID_GETUSERDATA 0x07u
#define NM_SERVICEID_GETPDUDATA 0x08u
#define NM_SERVICEID_REPEATMESSAGEREQUEST 0x09u
#define NM_SERVICEID_GETNODEIDENTIFIER 0x0Au
#define NM_SERVICEID_GETLOCALNODEIDENTIFIER 0x0Bu
#define NM_SERVICEID_CHECKREMOTESLEEPINDICATION 0x0Du
#define NM_SERVICEID_GETSTATE 0x0Eu
#define NM_SERVICEID_GETVERSIONINFO 0x0Fu
#define NM_SERVICEID_NETWORKSTARTINDICATION 0x11u
#define NM_SERVICEID_NETWORKMODE 0x12u
#define NM_SERVICEID_BUSSLEEPMODE 0x14u
#define NM_SERVICEID_PREPAREBUSSLEEPMODE 0x13u
#define NM_SERVICEID_REMOTESLEEPINDICATION 0x17u
#define NM_SERVICEID_REMOTESLEEPCANCELLATION 0x18u
#define NM_SERVICEID_REMOTESYNCHRONISATIONPOINT 0x19u
#define NM_SERVICEID_PDURXINDICATION 0x15u
#define NM_SERVICEID_STATECHANGENOTIFICATION 0x16u
#define NM_SERVICEID_REPEATMESSAGEINDICATION 0x1Au
#define NM_SERVICEID_TXTIMEOUTEXCEPTION 0x1Bu
#define NM_SERVICEID_CARWAKEUPINDICATION 0x1Du
#define NM_SERVICEID_COORDREADYTOSLEEPINDICATION 0x1Eu
#define NM_SERVICEID_MAINFUNCTION 0x10u
extern const Nm_ConfigType Nm_Config ;
/** Initializes the NM Interface. */
/** @req NM030 */
void Nm_Init(void);
/** This service returns the version information of this module */
/** @req NM044 */
/* @req Nm152 */
#if ( NM_VERSION_INFO_ENABLED == STD_ON )
#define Nm_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,NM)
#endif
/** This function calls the <BusNm>_PassiveStartUp function
* (e.g. CanNm_PassiveStartUp function is called if channel is configured as CAN). */
/** @req NM031 */
Std_ReturnType Nm_PassiveStartUp( const NetworkHandleType NetworkHandle );
/** This function calls the <BusNm>_NetworkRequest
* (e.g. CanNm_NetworkRequest function is called if channel is configured as CAN). */
/** @req NM032 */
Std_ReturnType Nm_NetworkRequest( const NetworkHandleType NetworkHandle );
/** This function calls the <BusNm>_NetworkRelease bus specific function
* (e.g. CanNm_NetworkRelease function is called if channel is configured as CAN). */
/** @req NM046 */
Std_ReturnType Nm_NetworkRelease( const NetworkHandleType NetworkHandle );
#if (NM_COM_CONTROL_ENABLED == STD_ON) /* @req NM134 @req NM136 */
/** This function calls the CanNm_NetworkRelease bus specific function, to disable
* the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service */
/** @req NM033 */
Std_ReturnType Nm_DisableCommunication( const NetworkHandleType NetworkHandle );
/** This function calls the CanNm_NetworkRequest bus specific function, to enable
* the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service */
/** @req NM034 */
Std_ReturnType Nm_EnableCommunication( const NetworkHandleType NetworkHandle );
#endif
/** Set user data for NM messages transmitted next on the bus.
* For that purpose <BusNm>_SetUserData shall be called
* (e.g. CanNm_SetUserData function is called if channel is configured as CAN). */
/** @req NM035 */
Std_ReturnType Nm_SetUserData( const NetworkHandleType NetworkHandle, const uint8 * const nmUserDataPtr );
/** Get user data out of the last successfully received NM message.
* For that purpose <BusNm>_GetUserData shall be called
* (e.g. CanNm_GetUserData function is called if channel is configured as CAN). */
/** @req NM036 */
Std_ReturnType Nm_GetUserData( const NetworkHandleType NetworkHandle, uint8 * const nmUserDataPtr );
/** Get the whole PDU data out of the most recently received NM message.
* For that purpose CanNm_GetPduData shall be called. */
/** @req NM037 */
Std_ReturnType Nm_GetPduData( const NetworkHandleType NetworkHandle, uint8 * const nmPduData );
/** Set Repeat Message Request Bit for NM messages transmitted next on the bus.
* For that purpose <BusNm>_RepeatMessageRequest shall be called
* (e.g. CanNm_RepeatMessageRequest function is called if channel is configured as CAN) */
/** @req NM038 */
Std_ReturnType Nm_RepeatMessageRequest( const NetworkHandleType NetworkHandle );
/** Get node identifier out of the last successfully received NM-message.
* The function <BusNm>_GetNodeIdentifier shall be called. */
/** @req NM039 */
Std_ReturnType Nm_GetNodeIdentifier( const NetworkHandleType NetworkHandle, uint8 * const nmNodeIdPtr );
/** Get node identifier configured for the local node.
* For that purpose <BusNm>_GetLocalNodeIdentifier shall be called
* (e.g. CanNm_GetLocalNodeIdentifier function is called if channel is configured as CAN). */
/** @req NM040 */
Std_ReturnType Nm_GetLocalNodeIdentifier( const NetworkHandleType NetworkHandle, uint8 * const nmNodeIdPtr );
/** Check if remote sleep indication takes place or not. This in turn calls the
* <BusNm>_CheckRemoteSleepIndication for the bus specific NM layer
* (e.g. CanNm_CheckRemoteSleepIndication function is called if channel is configured as CAN). */
/** @req NM042 */
Std_ReturnType Nm_CheckRemoteSleepIndication( const NetworkHandleType nmNetworkHandle, boolean * const nmRemoteSleepIndPtr );
/** Returns the state of the network management. This function in turn calls the
* <BusNm>_GetState function (e.g. CanNm_GetState function is called if channel is configured as CAN). */
/** @req NM043 */
Std_ReturnType Nm_GetState( const NetworkHandleType nmNetworkHandle, Nm_StateType* const nmStatePtr, Nm_ModeType* const nmModePtr );
/** Notification that a NM-message has been received in the Bus-Sleep Mode, what
* indicates that some nodes in the network have already entered the Network Mode.
* The callback function shall start the network management state machine. */
/** @req NM154 */
void Nm_NetworkStartIndication( const NetworkHandleType nmNetworkHandle );
/** Notification that the network management has entered Network Mode. The
* callback function shall enable transmission of application messages. */
/** @req NM156 */
void Nm_NetworkMode( const NetworkHandleType nmNetworkHandle );
/** Notification that the network management has entered Prepare Bus-Sleep Mode.
* The callback function shall disable transmission of application messages. */
/** @req NM159 */
void Nm_PrepareBusSleepMode( const NetworkHandleType nmNetworkHandle );
/** Notification that the network management has entered Bus-Sleep Mode. */
/** @req NM162 */
void Nm_BusSleepMode( const NetworkHandleType nmNetworkHandle );
/** Notification that the network management has detected that all other nodes on the network are ready to enter Bus-Sleep Mode */
/** @req NM192 */
void Nm_RemoteSleepIndication( const NetworkHandleType nmNetworkHandle );
/**Notification that the network management has detected that not all other nodes on the network are longer ready to enter Bus-Sleep Mode */
/** @req NM193 */
void Nm_RemoteSleepCancellation( const NetworkHandleType nmNetworkHandle );
/** Notification to the NM Coordinator functionality that this is a suitable point in time to initiate the coordination algorithm on */
/** @req NM194 */
void Nm_SynchronizationPoint( const NetworkHandleType nmNetworkHandle );
/** Notification that a NM message has been received. */
/** @req NM112 */
void Nm_PduRxIndication( const NetworkHandleType nmNetworkHandle );
/** Notification that the CAN Generic NM state has changed. */
/** @req NM114 */
void Nm_StateChangeNotification(
const NetworkHandleType nmNetworkHandle,
const Nm_StateType nmPreviousState,
const Nm_StateType nmCurrentState );
/** Service to indicate that an NM message with set Repeat Message Request Bit has been received */
/** @req NM230 */
void Nm_RepeatMessageIndication( const NetworkHandleType nmNetworkHandle );
/** Service to indicate that an attempt to send an NM message failed */
/** @req NM234 */
void Nm_TxTimeoutException( const NetworkHandleType nmNetworkHandle );
/** This function is called by a <Bus>Nm to indicate reception of a CWU request */
/** @req NM250 */
void Nm_CarWakeUpIndication( const NetworkHandleType nmNetworkHandle );
/** Seta an indication, when the NM coordinator Sleep Ready bit in the Control Bit Vector is set */
/** @req NM254 */
void Nm_CoordReadyToSleepIndication( const NetworkHandleType nmNetworkHandle );
/** This function implements the processes of the NM Interface, which need a fix
* cyclic scheduling. This function is supplied for the NM coordinator functionality
* (Nm020). However, specific implementation may not need it (Nm093) */
/** @req NM118 */
void Nm_MainFunction(void);
#endif /* NM_H_ */
|
2301_81045437/classic-platform
|
communication/Nm/inc/Nm.h
|
C
|
unknown
| 10,826
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef NM_CBK_H_
#define NM_CBK_H_
#endif /* NM_CBK_H_ */
|
2301_81045437/classic-platform
|
communication/Nm/inc/Nm_Cbk.h
|
C
|
unknown
| 825
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef NM_CONFIGTYPES_H_
#define NM_CONFIGTYPES_H_
typedef struct {
const Nm_BusNmType BusType;
// const NetworkHandleType BusNmNetworkHandle;
// const NetworkHandleType ComMNetworkHandle;
} Nm_ChannelType;
typedef struct {
const Nm_ChannelType* Channels;
const NetworkHandleType* ChannelMap;
const NetworkHandleType ChannelMapSize;
} Nm_ConfigType;
#endif /* NM_CONFIGTYPES_H_ */
|
2301_81045437/classic-platform
|
communication/Nm/inc/Nm_ConfigTypes.h
|
C
|
unknown
| 1,189
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef NM_EXTENSTION_H_
#define NM_EXTENSTION_H_
#include "NmStack_Types.h"
#include "ComStack_Types.h"
/* Functions needed for every NM extension */
void Nm_Extension_Init(void);
void Nm_Extension_WriteState(const NetworkHandleType nmNetworkHandle,
const Nm_StateType nmCurrentState);
void Nm_Extension_NetworkStartIndication(const NetworkHandleType ComMNetworkHandle);
void Nm_Extension_NetworkMode(const NetworkHandleType ComMNetworkHandle);
void Nm_Extension_PrepareBusSleepMode(const NetworkHandleType ComMNetworkHandle);
void Nm_Extension_BusSleepMode(const NetworkHandleType ComMNetworkHandle);
#endif
|
2301_81045437/classic-platform
|
communication/Nm/inc/Nm_Extension.h
|
C
|
unknown
| 1,422
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#if defined(USE_CANNM)
#include "CanNm.h"
#endif
#if defined(USE_FRNM)
#include "FrNm.h"
#endif
#if defined(USE_LINNM)
#include "LinNm.h"
#endif
#if defined(USE_UDPNM)
#include "UdpNm.h"
#endif
#if defined(USE_OSEKNM)
#include "OsekNm.h"
#endif
#include "Nm.h" /** @req NM123 */
#if defined(USE_NM_EXTENSION)
#include "Nm_Extension.h"
#endif
#if ( NM_DEV_ERROR_DETECT == STD_ON )
#include "Det.h"
#endif
/* Globally fulfilled requirements */
/** @req NM126 */ /* Development errors are uint8 */
/** @req NM170 */ /* since mainfunctions does nothing this applies */
/** @req NM091 */ /* Some are implemented as functions and some as macros*/
/** @req NM095 */ /* do not provide more APIs than specified */
/** @req NM006 */ /* convert generic calls to bus specific function calls*/
/** @req NM243 */ /* det is included based on the generated macro */
/** @req Nm022 */ /* NM_DEV_ERROR_DETECT switch is generated in Nm_cfg.h */
/** @req Nm023 */ /* Det check is based on switch NM_DEV_ERROR_DETECT */
/** @req Nm025 */ /* Det service is use based on switch NM_DEV_ERROR_DETECT */
/** @req Nm028 */ /* Nm callbacks can run either in task or in interrupt context */
/*lint -emacro(904,VALIDATE,VALIDATE_NO_RV)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
#if ( NM_DEV_ERROR_DETECT == STD_ON )
#define VALIDATE(_exp,_api,_err,_ret ) \
if( !(_exp) ) { \
(void)Det_ReportError(NM_MODULE_ID, 0, _api, _err); \
return _ret; \
}
#define VALIDATE_NO_RV(_exp,_api,_err ) \
if( !(_exp) ) { \
(void)Det_ReportError(NM_MODULE_ID, 0, _api, _err); \
return; \
}
#else
#define VALIDATE(_exp,_api,_err,_ret )
#define VALIDATE_NO_RV(_exp,_api,_err )
#endif
boolean Nm_InitStatus = FALSE;
/** Initializes the NM Interface. */
void Nm_Init( void )
{
#if defined(USE_NM_EXTENSION)
Nm_Extension_Init();
#endif
Nm_InitStatus = TRUE;
}
/** This function calls the <BusNm>_PassiveStartUp function
* (e.g. CanNm_PassiveStartUp function is called if channel is configured as CAN). */
Std_ReturnType Nm_PassiveStartUp( const NetworkHandleType NetworkHandle ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm128 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_PASSIVESTARTUP, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_PASSIVESTARTUP, NM_E_HANDLE_UNDEF, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
status = CanNm_PassiveStartUp(NetworkHandle);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_PassiveStartUp(NetworkHandle);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_PassiveStartUp(NetworkHandle);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_PassiveStartUp(NetworkHandle);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
/** This function calls the <BusNm>_NetworkRequest
* (e.g. CanNm_NetworkRequest function is called if channel is configured as CAN). */
#if (NM_PASSIVE_MODE == STD_OFF)
Std_ReturnType Nm_NetworkRequest( const NetworkHandleType NetworkHandle ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm129 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_NETWORKREQUEST, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_NETWORKREQUEST, NM_E_HANDLE_UNDEF, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM) && defined(NM_BUSNM_CANNM_NOT_PASSIVE)
case NM_BUSNM_CANNM:
status = CanNm_NetworkRequest(NetworkHandle);
break;
#endif
#if defined(USE_FRNM) && defined(NM_BUSNM_FRNM_NOT_PASSIVE)
case NM_BUSNM_FRNM:
status = FrNm_NetworkRequest(NetworkHandle);
break;
#endif
#if defined(USE_LINNM) && defined(NM_BUSNM_LINNM_NOT_PASSIVE)
case NM_BUSNM_LINNM:
status = LinNm_NetworkRequest(NetworkHandle);
break;
#endif
#if defined(USE_UDPNM) && defined(NM_BUSNM_UDPNM_NOT_PASSIVE)
case NM_BUSNM_UDPNM:
status = UdpNm_NetworkRequest(NetworkHandle);
break;
#endif
#if defined(USE_OSEKNM) && defined(NM_BUSNM_OSEKNM_NOT_PASSIVE)
case NM_BUSNM_OSEKNM:
status = OsekNm_NetworkRequest(NetworkHandle);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
#if (NM_PASSIVE_MODE == STD_OFF)
/** This function calls the <BusNm>_NetworkRelease bus specific function
* (e.g. CanNm_NetworkRelease function is called if channel is configured as CAN). */
Std_ReturnType Nm_NetworkRelease( const NetworkHandleType NetworkHandle ){
Std_ReturnType status;
status = E_NOT_OK;
const Nm_ChannelType* ChannelConf;
/* @req Nm131 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_NETWORKRELEASE, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_NETWORKRELEASE, NM_E_HANDLE_UNDEF, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM) && defined(NM_BUSNM_CANNM_NOT_PASSIVE)
case NM_BUSNM_CANNM:
status = CanNm_NetworkRelease(NetworkHandle);
break;
#endif
#if defined(USE_FRNM) && defined(NM_BUSNM_FRNM_NOT_PASSIVE)
case NM_BUSNM_FRNM:
status = FrNm_NetworkRelease(NetworkHandle);
break;
#endif
#if defined(USE_LINNM) && defined(NM_BUSNM_LINNM_NOT_PASSIVE)
case NM_BUSNM_LINNM:
status = LinNm_NetworkRelease(NetworkHandle);
break;
#endif
#if defined(USE_UDPNM) && defined(NM_BUSNM_UDPNM_NOT_PASSIVE)
case NM_BUSNM_UDPNM:
status = UdpNm_NetworkRelease(NetworkHandle);
break;
#endif
#if defined(USE_OSEKNM) && defined(NM_BUSNM_OSEKNM_NOT_PASSIVE)
case NM_BUSNM_OSEKNM:
status = OsekNm_NetworkRelease(NetworkHandle);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
#if (NM_COM_CONTROL_ENABLED == STD_ON) /* @req NM134 */
/** This function calls the CanNm_NetworkRelease bus specific function, to disable
* the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service */
Std_ReturnType Nm_DisableCommunication( const NetworkHandleType NetworkHandle ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm133 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_DISABLECOMMUNICATION, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_DISABLECOMMUNICATION, NM_E_HANDLE_UNDEF, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
#if (CANNM_COM_CONTROL_ENABLED == STD_ON)
case NM_BUSNM_CANNM:
status = CanNm_DisableCommunication(NetworkHandle);
break;
#endif
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_DisableCommunication(NetworkHandle);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_DisableCommunication(NetworkHandle);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_DisableCommunication(NetworkHandle);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
#if (NM_COM_CONTROL_ENABLED == STD_ON) /* @req NM136 */
/** This function calls the CanNm_NetworkRequest bus specific function, to enable
* the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service */
Std_ReturnType Nm_EnableCommunication( const NetworkHandleType NetworkHandle ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm135 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_ENABLECOMMUNICATION, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_ENABLECOMMUNICATION, NM_E_HANDLE_UNDEF, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
#if (CANNM_COM_CONTROL_ENABLED == STD_ON)
case NM_BUSNM_CANNM:
status = CanNm_EnableCommunication(NetworkHandle);
break;
#endif
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_EnableCommunication(NetworkHandle);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_EnableCommunication(NetworkHandle);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_EnableCommunication(NetworkHandle);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
/** Set user data for NM messages transmitted next on the bus.
* For that purpose <BusNm>_SetUserData shall be called
* (e.g. CanNm_SetUserData function is called if channel is configured as CAN). */
/** @req NM241 */ /** @req NM138 */
#if (NM_COM_USER_DATA_ENABLED == STD_OFF) && (NM_USER_DATA_ENABLED == STD_ON) && (NM_PASSIVE_MODE == STD_OFF)
Std_ReturnType Nm_SetUserData( const NetworkHandleType NetworkHandle, const uint8 * const nmUserDataPtr ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm137 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_SETUSERDATA, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_SETUSERDATA, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmUserDataPtr != NULL), NM_SERVICEID_SETUSERDATA, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM) && defined(NM_BUSNM_CANNM_NOT_PASSIVE)
case NM_BUSNM_CANNM:
status = CanNm_SetUserData(NetworkHandle, nmUserDataPtr);
break;
#endif
#if defined(USE_FRNM) && defined(NM_BUSNM_FRNM_NOT_PASSIVE)
case NM_BUSNM_FRNM:
status = FrNm_SetUserData(NetworkHandle, nmUserDataPtr);
break;
#endif
#if defined(USE_LINNM) && defined(NM_BUSNM_LINNM_NOT_PASSIVE)
case NM_BUSNM_LINNM:
status = LinNm_SetUserData(NetworkHandle, nmUserDataPtr);
break;
#endif
#if defined(USE_UDPNM) && defined(NM_BUSNM_UDPNM_NOT_PASSIVE)
case NM_BUSNM_UDPNM:
status = UdpNm_SetUserData(NetworkHandle, nmUserDataPtr);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
/** Get user data out of the last successfully received NM message.
* For that purpose <BusNm>_GetUserData shall be called
* (e.g. CanNm_GetUserData function is called if channel is configured as CAN). */
#if (NM_USER_DATA_ENABLED == STD_ON)/** @req NM140 */
Std_ReturnType Nm_GetUserData( const NetworkHandleType NetworkHandle, uint8 * const nmUserDataPtr ){
Std_ReturnType status;
/* For some reason the signature of this service differs from its busNm equivalents... */
Std_ReturnType userDataRet = E_NOT_OK;
Std_ReturnType nodeIdRet = E_NOT_OK;
uint8 nmNodeIdPtr;
const Nm_ChannelType* ChannelConf;
/* @req Nm139 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_GETUSERDATA, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_GETUSERDATA, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmUserDataPtr != NULL), NM_SERVICEID_GETUSERDATA, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
userDataRet = CanNm_GetUserData(NetworkHandle, nmUserDataPtr);
nodeIdRet = CanNm_GetNodeIdentifier(NetworkHandle, &nmNodeIdPtr);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
userDataRet = FrNm_GetUserData(NetworkHandle, nmUserDataPtr);
nodeIdRet = FrNm_GetNodeIdentifier(NetworkHandle, &nmNodeIdPtr);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
userDataRet = LinNm_GetUserData(NetworkHandle, nmUserDataPtr);
nodeIdRet = LinNm_GetNodeIdentifier(NetworkHandle, &nmNodeIdPtr);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
userDataRet = UdpNm_GetUserData(NetworkHandle, nmUserDataPtr);
nodeIdRet = UdpNm_GetNodeIdentifier(NetworkHandle, &nmNodeIdPtr);
break;
#endif
default:
break;
}
if( (E_OK != userDataRet) || ( E_OK != nodeIdRet )) {
status = E_NOT_OK;
} else {
status = E_OK;
}
return status;
}
#endif
/** Get the whole PDU data out of the most recently received NM message.
* For that purpose CanNm_GetPduData shall be called. */
#if ((NM_NODE_ID_ENABLED == STD_ON) || (NM_NODE_DETECTION_ENABLED == STD_ON) || (NM_USER_DATA_ENABLED == STD_ON)) /** @req NM142 */
Std_ReturnType Nm_GetPduData( const NetworkHandleType NetworkHandle, uint8 * const nmPduData ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm141 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_GETPDUDATA, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_GETPDUDATA, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmPduData != NULL), NM_SERVICEID_GETPDUDATA, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
status = CanNm_GetPduData(NetworkHandle, nmPduData);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_GetPduData(NetworkHandle, nmPduData);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_GetPduData(NetworkHandle, nmPduData);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_GetPduData(NetworkHandle, nmPduData);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
/** Set Repeat Message Request Bit for NM messages transmitted next on the bus.
* For that purpose <BusNm>_RepeatMessageRequest shall be called
* (e.g. CanNm_RepeatMessageRequest function is called if channel is configured as CAN) */
#if (NM_NODE_DETECTION_ENABLED == STD_ON) /** @req NM144 */
Std_ReturnType Nm_RepeatMessageRequest( const NetworkHandleType NetworkHandle ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm143 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_REPEATMESSAGEREQUEST, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_REPEATMESSAGEREQUEST, NM_E_HANDLE_UNDEF, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
status = CanNm_RepeatMessageRequest(NetworkHandle);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_RepeatMessageRequest(NetworkHandle);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_RepeatMessageRequest(NetworkHandle);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_RepeatMessageRequest(NetworkHandle);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
/** Get node identifier out of the last successfully received NM-message.
* The function <BusNm>_GetNodeIdentifier shall be called. */
#if (NM_NODE_ID_ENABLED == STD_ON) /** @req NM146 */ /** @req NM148 */
Std_ReturnType Nm_GetNodeIdentifier( const NetworkHandleType NetworkHandle, uint8 * const nmNodeIdPtr ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm145 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_GETNODEIDENTIFIER, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_GETNODEIDENTIFIER, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmNodeIdPtr != NULL), NM_SERVICEID_GETNODEIDENTIFIER, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
status = CanNm_GetNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_GetNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_GetNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_GetNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
/** Get node identifier configured for the local node.
* For that purpose <BusNm>_GetLocalNodeIdentifier shall be called
* (e.g. CanNm_GetLocalNodeIdentifier function is called if channel is configured as CAN). */
Std_ReturnType Nm_GetLocalNodeIdentifier( const NetworkHandleType NetworkHandle, uint8 * const nmNodeIdPtr ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm147 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_GETLOCALNODEIDENTIFIER, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_GETLOCALNODEIDENTIFIER, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmNodeIdPtr != NULL), NM_SERVICEID_GETLOCALNODEIDENTIFIER, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
status = CanNm_GetLocalNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_GetLocalNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_GetLocalNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_GetLocalNodeIdentifier(NetworkHandle, nmNodeIdPtr);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
#endif
/** Check if remote sleep indication takes place or not. This in turn calls the
* <BusNm>_CheckRemoteSleepIndication for the bus specific NM layer
* (e.g. CanNm_CheckRemoteSleepIndication function is called if channel is configured as CAN). */
Std_ReturnType Nm_CheckRemoteSleepIndication( const NetworkHandleType NetworkHandle, boolean * const nmRemoteSleepIndPtr ){
const Nm_ChannelType* ChannelConf;
/* @req Nm149 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_CHECKREMOTESLEEPINDICATION, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_CHECKREMOTESLEEPINDICATION, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmRemoteSleepIndPtr != NULL), NM_SERVICEID_CHECKREMOTESLEEPINDICATION, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
(void)NetworkHandle;
(void)nmRemoteSleepIndPtr;/*lint !e920 */
(void)ChannelConf;/*lint !e920 */
return E_NOT_OK;
}
/** Returns the state of the network management. This function in turn calls the
* <BusNm>_GetState function (e.g. CanNm_GetState function is called if channel is configured as CAN). */
Std_ReturnType Nm_GetState( const NetworkHandleType NetworkHandle, Nm_StateType* const nmStatePtr, Nm_ModeType* const nmModePtr ){
Std_ReturnType status;
const Nm_ChannelType* ChannelConf;
/* @req Nm151 */
/* @req Nm232 */
VALIDATE((TRUE == Nm_InitStatus), NM_SERVICEID_GETSTATE, NM_E_UNINIT, E_NOT_OK);
/* @req Nm233 */
VALIDATE(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_GETSTATE, NM_E_HANDLE_UNDEF, E_NOT_OK);
/* @req Nm248 */
VALIDATE((nmStatePtr != NULL), NM_SERVICEID_GETSTATE, NM_E_PARAM_POINTER, E_NOT_OK);
VALIDATE((nmModePtr != NULL), NM_SERVICEID_GETSTATE, NM_E_PARAM_POINTER, E_NOT_OK);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[NetworkHandle]];
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
status = CanNm_GetState(NetworkHandle, nmStatePtr, nmModePtr);
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
status = FrNm_GetState(NetworkHandle, nmStatePtr, nmModePtr);
break;
#endif
#if defined(USE_LINNM)
case NM_BUSNM_LINNM:
status = LinNm_GetState(NetworkHandle, nmStatePtr, nmModePtr);
break;
#endif
#if defined(USE_UDPNM)
case NM_BUSNM_UDPNM:
status = UdpNm_GetState(NetworkHandle, nmStatePtr, nmModePtr);
break;
#endif
default: status = E_NOT_OK;
}
return status;
}
/** Notification that a NM-message has been received in the Bus-Sleep Mode, what
* indicates that some nodes in the network have already entered the Network Mode.
* The callback function shall start the network management state machine. */
/** @req NM012.partially.1 */
void Nm_NetworkStartIndication( const NetworkHandleType NetworkHandle ){
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_NETWORKSTARTINDICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_NETWORKSTARTINDICATION, NM_E_HANDLE_UNDEF);
#if defined(USE_NM_EXTENSION)
Nm_Extension_NetworkStartIndication(NetworkHandle);
#else
/** @req NM155 */
ComM_Nm_NetworkStartIndication(NetworkHandle);
#endif
}
/** Notification that the network management has entered Network Mode. The
* callback function shall enable transmission of application messages. */
/** @req NM012.partially.2 */
void Nm_NetworkMode( const NetworkHandleType NetworkHandle ){
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_NETWORKMODE, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_NETWORKMODE, NM_E_HANDLE_UNDEF);
#if defined(USE_NM_EXTENSION)
Nm_Extension_NetworkMode(NetworkHandle);
#else
/** @req NM158 */
ComM_Nm_NetworkMode(NetworkHandle);
#endif
}
/** Notification that the network management has entered Prepare Bus-Sleep Mode.
* The callback function shall disable transmission of application messages. */
/** @req NM012.partially.3 */
void Nm_PrepareBusSleepMode( const NetworkHandleType NetworkHandle ){
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_PREPAREBUSSLEEPMODE, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_PREPAREBUSSLEEPMODE, NM_E_HANDLE_UNDEF);
#if defined(USE_NM_EXTENSION)
Nm_Extension_PrepareBusSleepMode(NetworkHandle);
#else
/** @req NM161 */
ComM_Nm_PrepareBusSleepMode(NetworkHandle);
#endif
}
/** Notification that the network management has entered Bus-Sleep Mode. */
/** @req NM012.partially.4 */
void Nm_BusSleepMode( const NetworkHandleType NetworkHandle ){
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_BUSSLEEPMODE, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_BUSSLEEPMODE, NM_E_HANDLE_UNDEF);
#if defined(USE_NM_EXTENSION)
Nm_Extension_BusSleepMode(NetworkHandle);
#else
/** @req NM163 */
ComM_Nm_BusSleepMode(NetworkHandle);
#endif
}
/* NEW */
/** Notification that the network management has detected that all other nodes on the network are ready to enter Bus-Sleep Mode */
/** @req NM192 */
void Nm_RemoteSleepIndication( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_REMOTESLEEPINDICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_REMOTESLEEPINDICATION, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/* NEW */
/**Notification that the network management has detected that not all other nodes on the network are longer ready to enter Bus-Sleep Mode */
/** @req NM193 */
void Nm_RemoteSleepCancellation( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_REMOTESLEEPCANCELLATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_REMOTESLEEPCANCELLATION, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/* NEW */
/** Notification to the NM Coordinator functionality that this is a suitable point in time to initiate the coordination algorithm on */
/** @req NM194 */
void Nm_SynchronizationPoint( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_REMOTESYNCHRONISATIONPOINT, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_REMOTESYNCHRONISATIONPOINT, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/** Notification that a NM message has been received. */
void Nm_PduRxIndication( const NetworkHandleType NetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_PDURXINDICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (NetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[NetworkHandle]) ), NM_SERVICEID_PDURXINDICATION, NM_E_HANDLE_UNDEF);
(void)NetworkHandle;
}
#if (NM_STATE_CHANGE_IND_ENABLED == STD_ON)
/** Notification that the CAN or FR Generic NM state has changed. */
void Nm_StateChangeNotification(const NetworkHandleType nmNetworkHandle, const Nm_StateType nmPreviousState, const Nm_StateType nmCurrentState )
{
const Nm_ChannelType* ChannelConf;
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_STATECHANGENOTIFICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_STATECHANGENOTIFICATION, NM_E_HANDLE_UNDEF);
ChannelConf = &Nm_Config.Channels[Nm_Config.ChannelMap[nmNetworkHandle]];
(void)(nmPreviousState);
switch(ChannelConf->BusType) {
#if defined(USE_CANNM)
case NM_BUSNM_CANNM:
#if defined(USE_NM_EXTENSION)
Nm_Extension_WriteState(nmNetworkHandle, nmCurrentState);
#else
(void)nmCurrentState;
#endif
break;
#endif
#if defined(USE_FRNM)
case NM_BUSNM_FRNM:
#if defined(USE_NM_EXTENSION)
Nm_Extension_WriteState(nmNetworkHandle, nmCurrentState);
#else
(void)nmCurrentState;
#endif
break;
#endif
default:
break;
}
}
#endif
/* NEW */
/** Service to indicate that an NM message with set Repeat Message Request Bit has been received */
/** @req NM230 */
void Nm_RepeatMessageIndication( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_REPEATMESSAGEINDICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_REPEATMESSAGEINDICATION, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/* NEW */
/** Service to indicate that an attempt to send an NM message failed */
/** @req NM234 */
void Nm_TxTimeoutException( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_TXTIMEOUTEXCEPTION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_TXTIMEOUTEXCEPTION, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/* NEW */
/** This function is called by a <Bus>Nm to indicate reception of a CWU request */
/** @req NM250 */
void Nm_CarWakeUpIndication( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_CARWAKEUPINDICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_CARWAKEUPINDICATION, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/* NEW */
/** Seta an indication, when the NM coordinator Sleep Ready bit in the Control Bit Vector is set */
/** @req NM254 */
void Nm_CoordReadyToSleepIndication( const NetworkHandleType nmNetworkHandle )
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_COORDREADYTOSLEEPINDICATION, NM_E_UNINIT);
/* @req Nm233 */
VALIDATE_NO_RV(( (nmNetworkHandle < Nm_Config.ChannelMapSize) && (NM_CHANNEL_COUNT > Nm_Config.ChannelMap[nmNetworkHandle]) ), NM_SERVICEID_COORDREADYTOSLEEPINDICATION, NM_E_HANDLE_UNDEF);
(void)nmNetworkHandle;
}
/** This function implements the processes of the NM Interface, which need a fix
* cyclic scheduling. This function is supplied for the NM coordinator functionality
* (Nm020). However, specific implementation may not need it (Nm093) */
/** @req 121 */
void Nm_MainFunction()
{
/* @req Nm232 */
VALIDATE_NO_RV((TRUE == Nm_InitStatus), NM_SERVICEID_MAINFUNCTION, NM_E_UNINIT);
}
|
2301_81045437/classic-platform
|
communication/Nm/src/Nm.c
|
C
|
unknown
| 33,911
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "Nm_Extension.h"
void Nm_Extension_Init(void) {
}
void Nm_Extension_WriteState(const NetworkHandleType nmNetworkHandle,
const Nm_StateType nmCurrentState) {
}
void Nm_Extension_NetworkStartIndication(const NetworkHandleType ComMNetworkHandle) {
}
void Nm_Extension_NetworkMode(const NetworkHandleType ComMNetworkHandle) {
}
void Nm_Extension_PrepareBusSleepMode(const NetworkHandleType ComMNetworkHandle) {
}
void Nm_Extension_BusSleepMode(const NetworkHandleType ComMNetworkHandle) {
}
|
2301_81045437/classic-platform
|
communication/Nm/src/Nm_Extension.c
|
C
|
unknown
| 1,348
|
#OsekNm
obj-$(USE_OSEKNM) += OsekDirectNm.o
obj-$(USE_OSEKNM) += OsekIndirectNm.o
obj-$(USE_OSEKNM) += OsekNm.o
obj-$(USE_OSEKNM) += OsekNm_Cfg.o
obj-$(USE_OSEKNM) += OsekNmDllStubs.o
vpath-$(USE_OSEKNM) += $(ROOTDIR)/communication/OsekNm/src
inc-$(USE_OSEKNM) += $(ROOTDIR)/communication/OsekNm/inc
|
2301_81045437/classic-platform
|
communication/OsekNm/OsekNm.mod.mk
|
Makefile
|
unknown
| 310
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef OSEKNM_INTERNAL_H_
#define OSEKNM_INTERNAL_H_
#include "OsekNm_ConfigTypes.h"
#define OSEKNM_VENDOR_ID 60u
#define OSEKNM_MODULE_ID 30u
#define OSEKNM_AR_RELEASE_MAJOR_VERSION 4u
#define OSEKNM_AR_RELEASE_MINOR_VERSION 2u
#define OSEKNM_AR_RELEASE_REVISION_VERSION 2u
#define OSEKNM_AR_MAJOR_VERSION OSEKNM_AR_RELEASE_MAJOR_VERSION
#define OSEKNM_AR_MINOR_VERSION OSEKNM_AR_RELEASE_MINOR_VERSION
#define OSEKNM_AR_PATCH_VERSION OSEKNM_AR_RELEASE_REVISION_VERSION
#define OSEKNM_SW_MAJOR_VERSION 1u
#define OSEKNM_SW_MINOR_VERSION 0u
#define OSEKNM_SW_PATCH_VERSION 0u
#include <string.h>
#include "OsekNm_Cfg.h"
#if defined(USE_NM)
#include "Nm.h"
#endif
typedef enum {
OSEKNM_STATUS_UNINIT,
OSEKNM_STATUS_INIT
}OsekNm_Internal_InitStatusType;
/*
* Errors codes described for OSEKNM.
*****************************************************/
#define OSEKNM_E_NOT_INITIALIZED 0x00u
#define OSEKNM_E_INVALID_POINTER 0x01u
#define OSEKNM_E_INVALID_NETID 0x02u
#define OSEKNM_E_INVALID_NMCHANNEL 0x03u
#define OSEKNM_E_INVALID_CONFIGKIND 0x04u
/* Api Service codes */
#define OSEKNM_SERVICE_ID_INIT 0x00u
#define OSEKNM_SERVICE_ID_NETWORK_REQUEST 0x01u
#define OSEKNM_SERVICE_ID_NETWORK_RELEASE 0x02u
#define OSEKNM_SERVICE_ID_GET_VERSION_INFO 0x03u
#define OSEKNM_SERVICE_ID_DEINIT 0x04u
#define OSEKNM_SERVICE_ID_TX_CONFIRMATION 0x05u
#define OSEKNM_SERVICE_ID_RX_INDICATION 0x06u
#define OSEKNM_SERVICE_ID_CONTROLLER_BUSOFF 0x07u
#define OSEKNM_SERVICE_ID_TIMEOUT_NOTIFICATION 0x08u
#define OSEKNM_SERVICE_ID_INIT_CMASK_TABLE 0x09u
#define OSEKNM_SERVICE_ID_INIT_TARGETCONFIG_TABLE 0x0Au
#define OSEKNM_SERVICE_ID_CMP_CONFIG 0x0Bu
#define OSEKNM_SERVICE_ID_GET_CONFIG 0x0Cu
#define OSEKNM_SERVICE_ID_GET_STATUS 0x0Du
#define OSEKNM_SERVICE_ID_MAINFUNCTION 0x0Eu
void OsekNm_TxConfirmation(NetIdType NetId, NodeIdType NodeId);
void OsekNm_RxIndication(NetIdType NetId,NodeIdType NodeId, const OsekNm_PduType* NMPDU);
void OsekNm_MainFuntion(void);
#if ( OSEKNM_VERSION_INFO_API == STD_ON )
void OsekNm_GetVersionInfo(Std_VersionInfoType* versioninfo);
#endif /* OSEKNM_VERSION_INFO_API */
void OsekNm_ControllerBusOff(NetIdType NetId);
void OsekNm_Init( const OsekNm_ConfigType * const oseknmConfigPtr );
void OsekNm_DeInit(NetIdType netId);
void OsekNm_TimeoutNotification(NetIdType NetId,NodeIdType NodeId);
uint8 OsekNm_Internal_CheckNetId ( uint8 NetId);
uint8 OsekNm_Internal_GetNetId ( uint8 NethandleId);
uint8 OsekNm_Internal_nmHandleToNetHandle( const NetworkHandleType nmHandle);
Std_ReturnType OsekNm_NetworkRequest( const NetworkHandleType nmHandle );
Std_ReturnType OsekNm_NetworkRelease( const NetworkHandleType nmHandle );
void OsekNm_InitCMaskTable(NetIdType NetId,ConfigKindName ConfigKind, ConfigRefType CMask);
void OsekNm_InitTargetConfigTable(NetIdType NetId,ConfigKindName ConfigKind,ConfigRefType TargetConfig);
StatusType OsekNm_CmpConfig(NetIdType NetId,ConfigRefType TestConfig,ConfigRefType RefConfig,ConfigRefType CMask);
StatusType OsekNm_GetConfig(NetIdType NetId,ConfigRefType Config,ConfigKindName ConfigKind);
StatusType OsekNm_GetStatus(NetIdType netId, StatusRefType networkStatus); /*lint !e9018 'NetworkStatus' with union based type 'StatusRefType */
/*lint -e9003 */ /* could define variable 'OsekNmConfig' at block scope */
extern const OsekNm_ConfigType OsekNmConfig;
/* ********* Function required by DLL ************* */
void D_Init(NetIdType NetId,RoutineRefType InitRoutine);
void D_Offline(NetIdType NetId);
void D_Online(NetIdType NetId);
StatusType D_Window_Data_req(NetIdType netId, const OsekNm_PduType* nmPdu,uint8 dlc);
void BusInit(NetIdType NetId);
void BusSleep(NetIdType NetId);
void BusAwake(NetIdType NetId);
void BusRestart(NetIdType NetId);
void BusShutdown(NetIdType NetId);
#endif /*OSEKNM_INTERNAL_H_*/
|
2301_81045437/classic-platform
|
communication/OsekNm/inc/OsekNm.h
|
C
|
unknown
| 5,047
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef OSEKNM_CONFIGTYPES_H_
#define OSEKNM_CONFIGTYPES_H_
#include "Std_Types.h"
#if defined(USE_COM)
#include "Com_Types.h"
#else
#error "OsekNm: Module Com not used but is required"
#endif
#include "Os.h"
#define OSEKNM_NODE_MAX 32 /* 32 * 8 = 256 Nodes */
#define OSEKNM_INVALID_NETID 0xffu
#define OSEKNM_INVALID_NODEID 0xffu
typedef uint8 NodeIdType; /* references to several nodes */
typedef uint8 NetIdType; /* references to several communication networks */
typedef uint8 ScalingParamType;
typedef void (*RoutineRefType)(NetIdType NetId);
typedef enum {
OSEKNM_OFF = 0,
OSEKNM_INIT,
OSEKNM_INITRESET,
OSEKNM_NORMAL,
OSEKNM_NORMALPREPSLEEP,
OSEKNM_TwbsNORMAL,
OSEKNM_BUSSLEEP,
OSEKNM_LIMPHOME,
OSEKNM_LIMPHOMEPREPSLEEP,
OSEKNM_TwbsLIMPHOME,
OSEKNM_ON
}OsekNmDirectNmStateType;
/* @req OSEKNM066 */ /* @req OSEKNM064 */ /* @req OSEKNM065*/
/* @req OSEKNM067 */
/* Internal States of Indirect NM */
typedef enum
{
OSEKINDNM_OFF = 0,
OSEKINDNM_INIT,
OSEKINDNM_AWAKE,
OSEKINDNM_BUSSLEEP,
OSEKINDNM_NORMAL,
OSEKINDNM_WAITBUSSLEEP,
OSEKINDNM_LIMPHOME,
OSEKINDNM_ON
}OsekNmIndirectNmStateType;
/* Function pointer for User defined State change callback */
typedef void (*OsekNmDirectULStateChangeType)(NetIdType netId, OsekNmDirectNmStateType nodeStatus);
typedef void (*OsekNmIndirectULStateChangeType)(NetIdType netId, OsekNmIndirectNmStateType nodeStatus);
typedef enum{
NM_DIRECT = 0,
NM_INDIRECT
}NMType;
typedef enum{
SIGNAL_INVALID = 0,
SIGNAL_ACTIVATION,
SIGNAL_EVENT
}SignallingMode;
typedef enum {
MASTER=0,
SLAVE
}IndirectNodeType;
typedef enum {
GLOBAL_TIMEOUT =0,
TIMEOUT_PER_MESSAGE
}OsekNmIndirectTimeOutType;
typedef enum{
NM_BUSSLEEP = 1,
NM_AWAKE
}NMModeName;
typedef enum{
NM_CKNORMAL = 1, /* supported by direct and indirect NM */
NM_CKNORMALEXTENDED,/* only supported by indirect NM */
NM_CKLIMPHOME /* only supported by direct NM */
}ConfigKindName;
/*This data type represents the reference of a configuration*/
typedef uint8* ConfigRefType;
/*This data type represents a handle to reference values of the type ConfigRefType*/
typedef ConfigRefType ConfigHandleType;
/** @req OSEKNM003 */
/** @req OSEKNM054 */ /* network status is made common for both direct and indirect*/
typedef union{
uint32 status;
/*lint --e{46}*//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
struct{
uint8 configurationstable:1;
uint8 busoff:1;
uint8 active:1;
uint8 nmOff:1;
uint8 limpHome:1;
uint8 bussleep:1;
uint8 twbsNormalLimp:1;
uint8 ringdataNotallowed:1;
uint8 gotoModeSleep:1;
uint8 ExtendedNetworkstatus:2; /* @req OSEKNM052 */
}nodeStatus;
}NetworkStatusType;
typedef NetworkStatusType* StatusRefType;
typedef StatusRefType StatusHandleType;
typedef uint8 RingDataType[6];
typedef RingDataType* RingDataRefType;
/** @req OSEKNM001 */
#if (CPU_BYTE_ORDER == HIGH_BYTE_FIRST)
typedef struct{
uint8 source;
uint8 destination;
union{
uint8 b;
/*lint --e{46}*//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
struct {
uint8 reserved2 :2;
uint8 sleepAck :1;
uint8 sleepInd :1;
uint8 reserved1 :1;
uint8 limphome :1;
uint8 ring :1;
uint8 alive :1;
}B;
}OpCode;
RingDataType ringData ;
}OsekNm_PduType;
#else
typedef struct{
RingDataType ringData ;
union{
uint8 b;
/*lint --e{46}*//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
struct {
uint8 alive :1;
uint8 ring :1;
uint8 limphome :1;
uint8 reserved1 :1;
uint8 sleepInd :1;
uint8 sleepAck :1;
uint8 reserved2 :2;
}B;
}OpCode;
uint8 destination;
uint8 source;
}OsekNm_PduType;
#endif
typedef struct{
uint8 normal[OSEKNM_NODE_MAX];
uint8 normalExtended[OSEKNM_NODE_MAX];
uint8 limphome[OSEKNM_NODE_MAX];
}OsekNm_ConfigParamsType;
typedef struct{
uint8 normal[OSEKNM_NODE_MAX];
uint8 normalExtended[OSEKNM_NODE_MAX];
uint8 limphome[OSEKNM_NODE_MAX];
}OsekNm_CmaskParamsType;
/** @req OSEKNM002 */
typedef struct{
NodeIdType nodeId;
TickType osekdirectNmTTx;
TickType osekdirectNmTTyp;
TickType osekdirectNmTMax;
TickType osekdirectNmTError;
TickType osekdirectNmTWbs;
}Oseknm_DirectNMParamsType;
typedef struct{
Com_SignalIdType comSignalRef;
NodeIdType osekNmIndirectNodeId;
uint8 osekNmIndirectDeltaInc;
uint8 osekNmIndirectDeltaDec;
uint8 osekNmIndirectNodeHandle;
}OsekNmIndirectNodePrams;
typedef struct{
Com_SignalIdType comTxSignalRef;
const OsekNmIndirectNodePrams* osekNmIndirectNodevalues;
uint8 osekNmIndirectNodeCount;
IndirectNodeType osekNmIndirectNodeType;
TickType osekNmIndirectTOB;
TickType osekNmIndirectTError;
TickType osekNmIndirectTWBS;
uint8 osekNmIndirectDeltaInc;
uint8 osekNmIndirectDeltaDec;
uint8 osekNmIndirectThreshold;
NodeIdType osekNmIndirectSourceNodeId;
ConfigKindName configName;
OsekNmIndirectTimeOutType osekNmIndirectTimeoutConf;
}OsekIndNMNetPrams;
typedef struct {
const Oseknm_DirectNMParamsType* osekDirectNmNodeconfParams;
const OsekIndNMNetPrams* OsekNmIndirectNodeIdPrams;
NetIdType netId;
PduIdType canIfTxLPduRef;
uint8 networkHandle;
NMType osekNmType;
NetworkHandleType osekNmNetworkHandle;
}OsekNm_NetworkType;
typedef struct {
uint8 osekNmNetworkCount;
const OsekNm_NetworkType* osekNmNetwork;
const OsekNmDirectULStateChangeType osekNmDirectCallBack;
const OsekNmIndirectULStateChangeType osekNmIndirectCallBack;
} OsekNm_ConfigType;
#endif /* OSEKNM_CONFIGTYPES_H_ */
|
2301_81045437/classic-platform
|
communication/OsekNm/inc/OsekNm_ConfigTypes.h
|
C
|
unknown
| 7,241
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include"OsekNm.h"
#if (OSEKNM_DIRECT_NET_NUM > 0)
#include"OsekDirectNm.h"
#include "SchM_OsekNm.h"
#include <string.h>
/** @req OSEKNM037 */ /* NM message transmission shall be enabled */
/** @req OSEKNM038 */ /* NM message transmission shall be disabled */
#define NOT_SUPPORTED_YET 0
/* Macros for OpCode */
#define ALIVE_MASK 0x01
#define RING_MASK 0x02
#define LIMPHOME_MASK 0x04
#define SLEEPIND_MASK 0x10 /* sleep indication */
#define SLEEPACK_MASK 0x20 /* sleep acknowledgement */
#define SLEEP_ACK_SET 0x32 /* (RING_MASK|SLEEPIND_MASK|SLEEPACK_MASK)*/
#define TIMER_2 0x02 /* 2ticks extra added- 1 tick for setting and decrementing in same call and
one more tick because of checking time-out with 1 */
/** @req OSEKNM050 */
#define STATE_CHANGE_INDICATION(state) \
netId = OsekNm_Internal_GetNetId(netHandleId); \
OsekNm_ConfigPtr->osekNmDirectCallBack(netId, state ); \
extern const OsekNm_ConfigType* OsekNm_ConfigPtr;
static OsekDirect_InternalType OsekDirectNm_Networks[OSEKNM_DIRECT_NET_NUM];
/** Static function declarations */
static void initFromBusSleep(NetIdType netHandleId);
static void initFromNormal(NetIdType netHandleId);
static void initFromLimpHome(NetIdType netHandleId);
static void addToPresentConfig(NetIdType netHandleId,NodeIdType nodeId);
static void removeFromConfig(NetIdType netHandleId,ConfigKindName configKind,NodeIdType nodeId);
static void addToConfig(NetIdType netHandleId,ConfigKindName configKind,NodeIdType nodeId);
static void sendNmMessage(NetIdType netHandleId);
static void normalStandardNm(NetIdType netHandleId,uint8 rxBufIndex);
static void addToLimphomeConfig(NetIdType netHandleId,NodeIdType nodeId);
static NodeIdType determineLSnode(NodeIdType source,NodeIdType receiver,NodeIdType logsuccesor);
static boolean isNodeSkipped(NodeIdType source, NodeIdType receiver,NodeIdType destination);
static void normalMainFunc(NetIdType netHandleId);
static void normalPrepSleepMainFunc(NetIdType netHandleId);
static void normalTwbsMainFunc(NetIdType netHandleId);
static void twbsLimphomeMainFunc(NetIdType netHandleId);
static void limphomePrepSleepMainFunc(NetIdType netHandleId);
static void limphomeMainFunc(NetIdType netHandleId);
static void rxNmpduProcessFunc(NetIdType netHandleId, uint8 rxBufIndex);
static void rxNmpduLimpHomemsg(NetIdType netHandleId, uint8 rxBufIndex);
static void rxNmpduSleepAckProc(NetIdType netHandleId,uint8 rxBufIndex);
static void txNmpduProcessFunc(NetIdType netHandleId);
/**
* @brief Leave LimpHome
* @param netHandleId
*/
static void initFromLimpHome(NetIdType netHandleId){
NetIdType netId;
/* Cancel the timer TError and reset NMMerker.limphome */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = 0;
OsekDirectNm_Networks[netHandleId].nmMerker.B.limphome = 0;
/* Reset Tx and Rx Count */
OsekDirectNm_Networks[netHandleId].nmTxRetryCounter = 0;
OsekDirectNm_Networks[netHandleId].nmRxRetryCounter = 0;
/* Get Actual netId and enable the communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Online(netId);
initFromNormal(netHandleId);
}
/**
* @brief Function to send alive/ring message
* @param netHandleId
*/
static void sendNmMessage(NetIdType netHandleId) {
StatusType status;
NetIdType netId;
/* Get Actual netId and Start sending messages */
netId = OsekNm_Internal_GetNetId(netHandleId);
status = D_Window_Data_req(netId,&(OsekDirectNm_Networks[netHandleId].nmTransmitPdu),OSEKNM_DLL_FRAME_LENGTH);
/* DDL rejected the command to send actual NM Message(ring or alive) */
if(status != E_OK){
/* re-Transmit after TTx */ /* Figure 39 - DLL transmit Rejection */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTTx + 1);
}
}
/**
* @brief Function to add Node to present config
* @param netHandleId
* @param configKind
* @param nodeId
*/
static void addToConfig(NetIdType netHandleId,ConfigKindName configKind,NodeIdType nodeId){
ConfigRefType configNode = NULL;
uint8 byte;
uint8 bit;
switch(configKind){
case NM_CKNORMAL:
configNode = OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal;
break;
case NM_CKLIMPHOME:
configNode = OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome;
break;
default:
break;
}
if(NULL != configNode) {
/* Set the corresponding bit in array to represent nodeId */
byte = nodeId / 8;
bit = nodeId % 8;
configNode[byte] |= (uint8)(1u<<bit);
}
}
/**
* @brief Function to add Node to the LimpHome config
* @param netHandleId
* @param nodeId
*/
static void addToLimphomeConfig(NetIdType netHandleId, NodeIdType nodeId) {
uint8 refConfig[OSEKNM_NODE_MAX];
StatusType status;
/* Store old config for reference */
memcpy(refConfig, OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome, OSEKNM_NODE_MAX);
addToConfig(netHandleId, NM_CKLIMPHOME, nodeId);
/* Normal state of node is reset */
removeFromConfig(netHandleId, NM_CKNORMAL, nodeId);
/* check is there any change in config compared last logical ring */
status = OsekDirectNm_CmpConfig(netHandleId,OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome, refConfig, OsekDirectNm_Networks[netHandleId].nmDirectMask.limphome);
if(status != E_OK) {
/* Indicate Application about change in network config */
}
}
/**
* @brief Function call to remove node from configuration
* @param netHandleId
* @param configKind
* @param nodeId
*/
static void removeFromConfig(NetIdType netHandleId,ConfigKindName configKind,NodeIdType nodeId) {
ConfigRefType configNode = NULL;
uint8 byte;
uint8 bit;
switch(configKind){
case NM_CKNORMAL:
configNode = OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal;
break;
case NM_CKLIMPHOME:
configNode = OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome;
break;
default:
break;
}
if(NULL != configNode){
/* Set the corresponding bit in array to represent nodeId */
byte = nodeId / 8;
bit = nodeId % 8;
configNode[byte] &= (~(1u<<bit));
}
}
/**
* @brief Function to add the node into present configuration
* @param netHandleId
* @param nodeId
*/
static void addToPresentConfig(NetIdType netHandleId, NodeIdType nodeId) {
uint8 refConfig[OSEKNM_NODE_MAX];
StatusType status;
/* Store old configuration for reference */
memcpy(refConfig, OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal, OSEKNM_NODE_MAX);
/* Add node id to present configuration */
addToConfig(netHandleId, NM_CKNORMAL, nodeId);
/* limphome state of node is reset */
removeFromConfig(netHandleId, NM_CKLIMPHOME, nodeId);
/* check is there any change in configuration compared last logical ring */
status = OsekDirectNm_CmpConfig(netHandleId, OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal, refConfig, OsekDirectNm_Networks[netHandleId].nmDirectMask.normal);
if(status != E_OK) {
/* Indicate Application about change in network configuration */
}
}
/**
* @brief Leave the NmBusSleep and enter into StartNM sequence
* @param netHandleId
*/
static void initFromBusSleep(NetIdType netHandleId){
NetIdType netId;
/* config.limphome is set as Zero */
memset(OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome, 0x0, OSEKNM_NODE_MAX);
/* Reset the rx and tx counter */
/** @req OSEKNM007 */
OsekDirectNm_Networks[netHandleId].nmRxRetryCounter = 0x0;
OsekDirectNm_Networks[netHandleId].nmTxRetryCounter = 0x0;
/* Get actual netId and Enable application communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Online(netId);
OsekDirectNm_Networks[netHandleId].nmState= OSEKNM_INITRESET;
initFromNormal(netHandleId);
}
/**
* @brief Leave the NmNormal state and enter into StartNM sequence
* @param netHandleId
*/
/** @req OSEKNM006 */
static void initFromNormal(NetIdType netHandleId){
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
NetIdType netId;
#endif
/* config.present = own station */
memset(OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal,0,OSEKNM_NODE_MAX);
addToPresentConfig(netHandleId, OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->nodeId);
/* logical successor := own station */
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.destination = OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->nodeId;
/** @req OSEKNM007 */
OsekDirectNm_Networks[netHandleId].nmRxRetryCounter += (uint8)0x01;
/* Initialize the NMPDU data and opcode */
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.b = 0;
memset(OsekDirectNm_Networks[netHandleId].nmTransmitPdu.ringData, 0, sizeof(RingDataType));
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active) {
/* Send A alive message */
OsekDirectNm_Networks[netHandleId].nmTxRetryCounter += 1;
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.b = ALIVE_MASK;
sendNmMessage(netHandleId);
}
if((OsekDirectNm_Networks[netHandleId].nmRxRetryCounter <= OSEKNM_RX_COUNT_LIMIT) &&
(OsekDirectNm_Networks[netHandleId].nmTxRetryCounter <= OSEKNM_TX_COUNT_LIMIT)) {
/* Set timer TTyp*/ /** @req OSEKNM009 */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTTyp + 1);
/* Enter Normal state */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_NORMAL;
#if (STD_ON == ASR_OSEK_NM)
Nm_NetworkMode(OsekNmConfig.osekNmNetwork[netHandleId].osekNmNetworkHandle);
#endif
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_NORMAL);
#endif
}else {
/** @req OSEKNM008 */
/* Set timer TError */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
/* Enter limphome state */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOME);
#endif
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 1;
}
}
/**
* @brief function find out the next logical successor
* @param source
* @param receiver
* @param logsuccesor
* @return
*/
static NodeIdType determineLSnode(NodeIdType source,NodeIdType receiver,NodeIdType logsuccesor) {
NodeIdType nextLogsuccesor = logsuccesor;
/** @req OSEKNM010 */
/* Figure 19 in ISO spec */
if(logsuccesor == receiver){
nextLogsuccesor = source;
}else {
if(logsuccesor < receiver){
if(source < logsuccesor){
/* SLR */
nextLogsuccesor = source;
}else {
if(source < receiver){
/* LSR */
}else{
/* LRS */
nextLogsuccesor = source;
}
}
}else {
if(source < logsuccesor){
if(source < receiver){
/* SRL */
}else{
/* RSL */
nextLogsuccesor = source;
}
}else{
/* RLS */
}
}
}
return nextLogsuccesor;
}
/**
* @brief function to check is Node is skipped from ring
* @param source
* @param receiver
* @param destination
* @return
*/
/** @req OSEKNM011 */
static boolean isNodeSkipped(NodeIdType source, NodeIdType receiver,NodeIdType destination) {
boolean isSkippedRing = FALSE;
/* Figure 18 in ISO spec */
if(destination < receiver){
if(source < destination){
/* not skipped SDR */
}else{
if(source < receiver){
/* DRS */
isSkippedRing = TRUE;
}else{
/* not skipped DSR */
}
}
}else{
if(source < destination){
if(source < receiver){
/* SRD */
isSkippedRing = TRUE;
}else{
/* RSD */
}
}else{
/* RDS */
isSkippedRing = TRUE;
}
}
return isSkippedRing;
}
/**
* @brief Function to remember list of relevant configured nodes
* @param netId
* @param configKind
* @param CMask
*/
void OsekDirectNm_InitCMaskTable(NetIdType netHandleId,ConfigKindName configKind, ConfigRefType cMask){
switch(configKind){
case NM_CKNORMAL:
memcpy(OsekDirectNm_Networks[netHandleId].nmDirectMask.normal, cMask, OSEKNM_NODE_MAX);
break;
case NM_CKLIMPHOME:
memcpy(OsekDirectNm_Networks[netHandleId].nmDirectMask.limphome, cMask, OSEKNM_NODE_MAX);
break;
default:
break;
}
}/*lint !e818 STANDARDIZED_API */
/**
* @brief
* @param netId
* @param configKind
* @param TargetConfig
*/
void Direct_InitTargetConfigTable(NetIdType netHandleId,ConfigKindName configKind,ConfigRefType targetConfig){
switch(configKind){
case NM_CKNORMAL:
memcpy(OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal,targetConfig,OSEKNM_NODE_MAX);
break;
case NM_CKLIMPHOME:
memcpy(OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome,targetConfig,OSEKNM_NODE_MAX);
break;
default:
break;
}
}/*lint !e818 STANDARDIZED_API */
/**
* @brief This service provides the actual configuration of the kind specified by <configKind>
* @param netHandleId
* @param config
* @param configKind
* @return
*/
/** @req OSEKNM043 */
StatusType OsekDirectNm_GetConfig(NetIdType netHandleId, ConfigRefType config,ConfigKindName configKind){
switch(configKind){
case NM_CKNORMAL:
memcpy(config, OsekDirectNm_Networks[netHandleId].nmDirectConfig.normal, OSEKNM_NODE_MAX);
break;
case NM_CKLIMPHOME:
memcpy(config, OsekDirectNm_Networks[netHandleId].nmDirectConfig.limphome, OSEKNM_NODE_MAX);
break;
default:
break;
}
return E_OK;
}
/**
* @brief The test configuration <TestConfig> is compared to the specified reference configuration
* <RefConfig> taking account of the mask <CMask>.
* @param netHandleId
* @param TestConfig
* @param RefConfig
* @param CMask
* @return
*/
/** @req OSEKNM044 */
StatusType OsekDirectNm_CmpConfig(NetIdType netHandleId, ConfigRefType testConfig, ConfigRefType refConfig,ConfigRefType cMask){
StatusType retStatus = E_OK;
uint8 result;
uint8 i;
(void)netHandleId;
/* (<TestConfig> EXOR <RefConfig>) of the node within the network is identified within the <CMask> by TRUE. */
for(i=0; i < OSEKNM_NODE_MAX; i++){
result = testConfig[i]^refConfig[i];
result &= cMask[i];
result = ~result;
if(result != 0xFFU){
retStatus = E_NOT_OK;
break;
}
}
return retStatus;
}/*lint !e818 STANDARDIZED_API */
/**
* @brief StartNM starts the local Network Management. This causes the state transition from NMOff to NMOn
* @param netId
* @return
*/
/** @req OSEKNM005 */
StatusType OsekDirectNm_StartNM(NetIdType netId){
NetIdType netHandleId;
StatusType retStatus = E_OK;
uint8 config[OSEKNM_NODE_MAX];
/* Figure 30 in ISO spec - Start Nm */
/* Get NetHandle mapped to Actual netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
/* By default set NM status to active */
OsekDirectNm_Networks[netHandleId].networkStatus.status = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active = 1;
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepInd = 0;
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepAck = 0;
memset(config, 0x01 ,OSEKNM_NODE_MAX);
OsekDirectNm_InitCMaskTable(netHandleId, NM_CKNORMAL, config);
OsekDirectNm_InitCMaskTable(netHandleId, NM_CKLIMPHOME, config);
OsekDirectNm_Networks[netHandleId].rcvdNmpdu = FALSE;
OsekDirectNm_Networks[netHandleId].nmRxPduCount = 0;
#if (STD_OFF == ASR_OSEK_NM)
/* Set State to NMInit */
OsekDirectNm_Networks[netHandleId].nmState= OSEKNM_INIT;
/* Initialize the hardware */
D_Init(netId,BusInit);
initFromBusSleep(netHandleId);
#else
/* Set State to OSEKNM_BUSSLEEP to support ASR NM */
OsekDirectNm_Networks[netHandleId].nmState= OSEKNM_BUSSLEEP;
OsekDirectNm_Networks[netHandleId].nmMerker.b = 0;
#endif
return retStatus;
}
/**
* @brief StopNM stops the local Network Management. This causes the state transition from NMOn
* to NMShutDown and after processing of the shutdown activities to NMOff
* @param netId
* @return
*/
/** @req OSEKNM040 */
StatusType OsekDirectNm_StopNM(NetIdType netId){
uint8 netHandleId;
/* Figure 30 in ISO spec - Stop NM */
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
/* Change the state to NMOff */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_OFF;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.nmOff = 1;
return E_OK;
}
/**
* @brief GotoMode serves to set the NM operating mode specified by <NewMode>
* @param netId
* @param NewMode
* @return
*/
/** @req OSEKNM042 */
StatusType OsekDirectNm_GotoMode(NetIdType netHandleId,NMModeName newMode){
NetIdType netId;
if(newMode == NM_BUSSLEEP){
/* Set status to bus sleep */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep = 1; /* Figure 39 */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.gotoModeSleep = 1;
switch(OsekDirectNm_Networks[netHandleId].nmState){
case OSEKNM_NORMAL: /* Figure 32 in ISO spec */ /** @req OSEKNM014 */
if(0 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active) {
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_NORMALPREPSLEEP;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_NORMALPREPSLEEP);
#endif
} /* else OSEKNM_NORMAL */
break;
default:
break;
}
}else if(newMode == NM_AWAKE) {
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep = 0; /* Figure 39 */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.gotoModeSleep = 0;
switch(OsekDirectNm_Networks[netHandleId].nmState){
case OSEKNM_NORMALPREPSLEEP:/* Figure 33 in ISO spec */ /** @req OSEKNM019 */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_NORMAL;
#if (STD_ON == ASR_OSEK_NM)
Nm_NetworkMode(OsekNmConfig.osekNmNetwork[netHandleId].osekNmNetworkHandle);
#endif
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_NORMAL);
#endif
break;
case OSEKNM_TwbsNORMAL: /* Figure 34 in ISO spec */
/* Cancel timer TWbs */ /** @req OSEKNM022 */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 0;
/* AF modified */
/* Get Actual netId and enable the communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Online(netId);
/* End AF modified */
/* NmInitReset */
initFromNormal(netHandleId);
break;
case OSEKNM_BUSSLEEP:/* Figure 31 in ISO spec */
/* Get actual netId and Enable application communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Init(netId,BusAwake);
initFromBusSleep(netHandleId);
break;
case OSEKNM_LIMPHOMEPREPSLEEP:/* Figure 36 in ISO spec */ /** @req OSEKNM031 */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
/* set timer TError */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOME);
#endif
break;
case OSEKNM_TwbsLIMPHOME:/* Figure 37 in ISO spec */ /** @req OSEKNM035 */
/* Cancel timer TWbs */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 1;
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
/* set timer TError */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOME);
#endif
break;
default:
break;
}
}else {}
return E_OK;
}
/**
* @brief Function to check status of self Node by application
* @param netId
* @param networkStatus
* @return
*/
/*lint --e{9018}*/ /* 'networkStatus' with union based type 'StatusRefType' */
StatusType OsekDirectNm_GetStatus(NetIdType netHandleId, StatusRefType networkStatus) {
/** @req OSEKNM045 */
StatusType status = E_OK;
memcpy(networkStatus, &OsekDirectNm_Networks[netHandleId].networkStatus, sizeof(NetworkStatusType));
return status;
}
/**
* @brief Function call to perform actions in NmNormalStandard
* @param netHandleId Handle identifier for network
* @param rxBufIndex index of the rx buffer applicable
*/
static void normalStandardNm(NetIdType netHandleId, uint8 rxBufIndex ) {
uint8 newDestination;
boolean isSkippedRing;
/* Figure 38 in ISO doc */
/* Clear NMRxcount */ /** @req OSEKNM012 */
OsekDirectNm_Networks[netHandleId].nmRxRetryCounter = 0;
if(1 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.limphome) {
/* add sender to config.limphome */
addToLimphomeConfig(netHandleId, OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].source);
}else{
/* add sender to config.present */
addToPresentConfig(netHandleId, OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].source);
/* determine logical successor */ /** @req OSEKNM010 */
newDestination = determineLSnode(OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].source, \
OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->nodeId, \
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.destination);
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.destination = newDestination;
if(1 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.ring){
/* Cancle timer TTyp and TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = 0; /** @req OSEKNM009 */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
/* transfer application data via the logical ring */
memcpy(OsekDirectNm_Networks[netHandleId].nmTransmitPdu.ringData, OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].ringData, sizeof(RingDataType));
/* check destination station to me or destination = source */
if((OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].destination == OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->nodeId)
|| (OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].destination == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].source)) {
/* Set timer TTyp */ /** @req OSEKNM009 */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTTyp + 1);
/* ringData indication to application */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.ringdataNotallowed = 0;
}else {
/* Set timer TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTMax + 1);
isSkippedRing = isNodeSkipped(OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].source, OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->nodeId, OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].destination);
if(TRUE == isSkippedRing) {
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active) {
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.b = ALIVE_MASK;
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.destination = OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->nodeId;
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep){
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepInd = 1;
}
/* Send message */ /** @req OSEKNM011 */
sendNmMessage(netHandleId);
}
}
}
}else {
OsekDirectNm_Networks[netHandleId].nmMerker.B.stable = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.configurationstable = 0;
}
}
}
/**
* @brief Actions to perform when TError elapsed In LimpHome state
* @param netHandleId
*/
static void limphomeMainFunc(NetIdType netHandleId) {
NetIdType netId;
/* Figure 35 in ISO doc - Time-out TError part */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError--;
}
/* Check timeout */ /** @req OSEKNM024 */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError) {
/* cancel timer TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = 0;
/* Get Actual netId and Enable communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Online(netId);
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.b = LIMPHOME_MASK;
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTMax + 1);
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepInd = 1;
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOMEPREPSLEEP; /** @req OSEKNM025 */
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOMEPREPSLEEP);
#endif
}else {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
}
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active) {
sendNmMessage(netHandleId);
}
}
}
}
/**
* @brief Actions to perform when TWbs elapsed In TwbsLimpHome state
* @param netHandleId
*/
static void twbsLimphomeMainFunc(NetIdType netHandleId) {
NetIdType netId;
/* Figure 37 in ISO doc - Time-out Twbs */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs--;
}
/* Check timeout */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs) {
/* cancel timer TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
/* Get Actual netId and Initialize the sleep mode of the bus hardware */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Init(netId, BusSleep);
/* Set State to NMBussleep */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_BUSSLEEP; /** @req OSEKNM034 */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 0;
#if (ASR_OSEK_NM == STD_ON)
Nm_BusSleepMode(OsekNmConfig.osekNmNetwork[netHandleId].osekNmNetworkHandle);
#endif
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_BUSSLEEP);
#endif
}
}
}
/**
* @brief Actions to perform when TMax elapsed In LimphomePrepSleep state
* @param netHandleId
*/
static void limphomePrepSleepMainFunc(NetIdType netHandleId){
NetIdType netId;
/* Figure 36 in ISO doc - Time-out Tmax */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax--;
}
/* Check timeout */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax) {
/* cancel timer TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
/* Get Actual netId and Disable communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Offline(netId);
/* Set timer Twbs */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTWbs + 1);
/* Set State to NM_TwbsLIMPHOME */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_TwbsLIMPHOME; /** @req OSEKNM032 */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 0;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_TwbsLIMPHOME);
#endif
}
}
}
/**
* @brief Actions to perform when TWbs elapsed In NormalTwbs state
* @param netHandleId
*/
static void normalTwbsMainFunc(NetIdType netHandleId) {
NetIdType netId;
/* Figure 34 in ISO doc - Time-out Twbs part */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs--;
}
/* Check timeout */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs) {
/* cancel timer TWbs */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 0;
/* Get Actual netId and Initialize the sleep mode of the bus hardware */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Init(netId, BusSleep);
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_BUSSLEEP; /** @req OSEKNM020 */
#if (ASR_OSEK_NM == STD_ON)
Nm_BusSleepMode(OsekNmConfig.osekNmNetwork[netHandleId].osekNmNetworkHandle);
#endif
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_BUSSLEEP);
#endif
}
}
}
/**
* @brief Actions to perform when TTyp elapsed In NormalPrepSleep state
* @param netHandleId
*/
static void normalPrepSleepMainFunc(NetIdType netHandleId) {
NetIdType netId;
/* Figure 33 in ISO doc - Timeout Typ part */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp--;
}
/* Check timeout */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp) {
/* cancel timer TTyp */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = 0;
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active)
{
/* Send ring message with set sleep.ack bit */ /** @req OSEKNM018 */
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.b = SLEEP_ACK_SET;
sendNmMessage(netHandleId);
}
}
}
/* Deviation:- If other nodes stop transmitting message when Node is in NMNormalPresleep , TTyp timer wont set and if GotoMode(Awake) is not called,
* Node Stuck into NMNormalPresleep, To avoid this situation implemented below functionality */
/* TMax timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax) {
/* Decrement timer TMax*/
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax--;
}
/* Check timeout of TMax*/
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax) {
/* cancel timer TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
/* Get Actual netId and Disable communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Offline(netId);
/* Set timer Twbs */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTWbs + 1);
/* Set State to NM_TwbsNORMAL */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_TwbsNORMAL;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 0;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_TwbsNORMAL);
#endif
}
}
}
/**
* @brief Actions to perform when TTyp elapsed In NormalMain state
* @param netHandleId
*/
static void normalMainFunc(NetIdType netHandleId) {
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
NetIdType netId;
#endif
/* Figure 32 in ISO doc - Time */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp--;
}
/* Check timeout */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp) {
/* cancel timer TTyp and TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
/* Set timer TMax*/
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTMax + TIMER_2);
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active) {
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.b = RING_MASK;
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep){
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepInd = 1;
}
sendNmMessage(netHandleId);
OsekDirectNm_Networks[netHandleId].nmTxRetryCounter++;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.ringdataNotallowed = 1;
}
if(OsekDirectNm_Networks[netHandleId].nmTxRetryCounter > OSEKNM_TX_COUNT_LIMIT) {
/* Enter state NMLimpHome */
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOME);
#endif
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 1;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
}else {
if(1 == OsekDirectNm_Networks[netHandleId].nmMerker.B.stable) {
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.configurationstable = 1;
}else {
OsekDirectNm_Networks[netHandleId].nmMerker.B.stable = 1;
}
}
}
}
/* Figure 32 in ISO doc - Time-Out Tmax */
/* TMax timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax) {
/* Decrement timer TMax*/
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax--;
}
/* Check timeout of TMax*/
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax) {
/* cancel timer TMax */ /** @req OSEKNM013 */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
initFromNormal(netHandleId);
}
}
}
/**
* @brief Function is to enable passive communication
* @param netId
* @return
*/
/** @req OSEKNM046 */
StatusType OsekDirectNm_SilentNM(NetIdType netId){
uint8 netHandleId;
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
/* Figure 31 in ISO doc */
/* Change the N/w status to passive */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active = 0;
return E_OK;
}
/**
* @brief function is to disable passive communication
* @param netId
* @return
*/
/** @req OSEKNM047 */
StatusType OsekDirectNm_TalkNM(NetIdType netId){
uint8 netHandleId;
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
/* Figure 31 in ISO doc */
/* Set N/W status to Active */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active = 1;
return E_OK;
}
/**
* @brief Function to process the transmitted message confirmation
* @param netHandleId
*/
static void txNmpduProcessFunc(NetIdType netHandleId) {
NetIdType netId;
OsekDirectNm_Networks[netHandleId].nmTxRetryCounter = 0;
switch(OsekDirectNm_Networks[netHandleId].nmState)
{
case OSEKNM_NORMAL: /* Figure 32 in ISO doc - Transmit message part */
if(1 == OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.ring) {
/* Cancel timer TTyp and TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
/* Set timer TMax */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTMax + 1);
if(1 == OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepInd){
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep){
OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.sleepAck = 1;
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_NORMALPREPSLEEP; /** @req OSEKNM016 */
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_NORMALPREPSLEEP);
#endif
}
}
}
break;
case OSEKNM_NORMALPREPSLEEP: /* Figure 33 in ISO doc - Transmit message part */
if(1 == OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.ring) {
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Offline(netId);
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTWbs + 1);
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_TwbsNORMAL;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 1;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_TwbsNORMAL);
#endif
}
break;
case OSEKNM_LIMPHOME:/* Figure 35 in ISO doc - Transmit message part */
if(1 == OsekDirectNm_Networks[netHandleId].nmTransmitPdu.OpCode.B.limphome) {
OsekDirectNm_Networks[netHandleId].nmMerker.B.limphome = 1;
}
break;
default:
break;
}
}
/**
* @brief Function to process the received limpHome message
* @param netHandleId Network HandleId
* @param rxBufIndex index of rx buffer
*/
static void rxNmpduLimpHomemsg(NetIdType netHandleId, uint8 rxBufIndex) {
NetIdType netId;
if((1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep) && (1 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepAck)) {
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Offline(netId);
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTWbs + 1);
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_TwbsLIMPHOME;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 1;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_TwbsLIMPHOME);
#endif
}else {
initFromLimpHome(netHandleId);
}
}
/**
* @brief Function to process the received message with sleep acknowledgment
* @param netHandleId Network HandleId
* @param rxBufIndex index of rx buffer
*/
static void rxNmpduSleepAckProc(NetIdType netHandleId,uint8 rxBufIndex) {
NetIdType netId;
if(1 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepAck) {
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.bussleep) {
/* NMInitBusSleep */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Offline(netId);
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTWbs + 1);
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_TwbsNORMAL;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 1;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_TwbsNORMAL);
#endif
}
}
}
/**
* @brief Function to process the received message
* @param netHandleId Network HandleId
* @param rxBufIndex index of rx buffer
*/
static void rxNmpduProcessFunc(NetIdType netHandleId, uint8 rxBufIndex) {
NetIdType netId;
switch(OsekDirectNm_Networks[netHandleId].nmState){
case OSEKNM_NORMAL: /* Figure 32 in ISO doc */
case OSEKNM_NORMALPREPSLEEP:
/* figure 38 in ISO doc */
normalStandardNm(netHandleId,rxBufIndex);
rxNmpduSleepAckProc(netHandleId,rxBufIndex);
/* Figure33 - process for NM_stNormalPrepSleep only */
if(OSEKNM_NORMALPREPSLEEP == OsekDirectNm_Networks[netHandleId].nmState){
if(0 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepInd){
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_NORMAL; /** @req OSEKNM017 */
#if (STD_ON == ASR_OSEK_NM)
Nm_NetworkMode(OsekNmConfig.osekNmNetwork[netHandleId].osekNmNetworkHandle);
#endif
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_NORMAL);
#endif
}/* Else stay in NormalPresleep */
}
break;
case OSEKNM_LIMPHOME: /* Figure 35 - Received msg part */
if(1 == OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.active) {
if(1 == OsekDirectNm_Networks[netHandleId].nmMerker.B.limphome) { /** @req OSEKNM029 */
rxNmpduLimpHomemsg(netHandleId,rxBufIndex);/** @req OSEKNM027 */ /** @req OSEKNM030 */
}else {
if(1 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepAck) {
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Offline(netId);
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTWbs + 1);
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_TwbsLIMPHOME; /** @req OSEKNM028 */
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 1;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_TwbsLIMPHOME);
#endif
}else {
initFromLimpHome(netHandleId); /** @req OSEKNM026 */
}
}
}else {
rxNmpduLimpHomemsg(netHandleId, rxBufIndex);
}
break;
case OSEKNM_LIMPHOMEPREPSLEEP: /* Figure 36 - Received msg part */ /** @req OSEKNM033 */
if(0 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepInd) {
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOME);
#endif
}/* Else stay in LimpHomePreSleep */
break;
case OSEKNM_TwbsNORMAL: /* Figure 34 - Received msg part */
if(0 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepInd) {
/* Cancel timer TWbs */ /** @req OSEKNM023 */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 0;
/* AF modified */
/* Get Actual netId and enable the communication */
netId = OsekNm_Internal_GetNetId(netHandleId);
D_Online(netId);
/* End AF modified */
initFromNormal(netHandleId);
}/** @req OSEKNM021 */
break;
case OSEKNM_TwbsLIMPHOME: /* Figure 37 - Received msg part */ /** @req OSEKNM036 */
if(0 == OsekDirectNm_Networks[netHandleId].nmRxPdu[rxBufIndex].OpCode.B.sleepInd) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
/* Setting timer was missing in Spec */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + 1);
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.twbsNormalLimp = 0;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 1;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION(OSEKNM_LIMPHOME);
#endif
}/* else stay in same state */
break;
default:
break;
}
}
/**
* @brief OsekNm Direct main function processing
* @param netId
*/
/** @req OSEKNM041 */
void OsekDirectNm_MainFunction(NetIdType netId){
NetIdType netHandleId;
uint8 i;
boolean exitFlag = FALSE;
/* Get NetHandle mapped to Actual netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
/* Enter Critical section */
SchM_Enter_OsekNm_EA_0();
/* Check Rx indication is set */
if(TRUE == OsekDirectNm_Networks[netHandleId].rcvdNmpdu) {
for (i=0; i < OsekDirectNm_Networks[netHandleId].nmRxPduCount; i++) {
rxNmpduProcessFunc(netHandleId, i);
}
OsekDirectNm_Networks[netHandleId].rcvdNmpdu = FALSE;
OsekDirectNm_Networks[netHandleId].nmRxPduCount = 0;
}
/* Check Tx Indication is set */
if(TRUE == OsekDirectNm_Networks[netHandleId].transNmpdu) {
OsekDirectNm_Networks[netHandleId].transNmpdu = FALSE;
txNmpduProcessFunc(netHandleId);
}
/* exit Critical section */
SchM_Exit_OsekNm_EA_0();
/* Figure 39 - DLL transmit Rejection */
/* timer started */
if(0 != OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx) {
/* Decrement timer */
if(OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx > 1) {
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx--;
}
/* Check timeout */
if(1 == OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx) {
/* cancel timer TTx */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx = 0;
sendNmMessage(netHandleId);
exitFlag = TRUE;
}
}
if(FALSE == exitFlag){
switch(OsekDirectNm_Networks[netHandleId].nmState){
case OSEKNM_NORMAL:
normalMainFunc(netHandleId);
break;
case OSEKNM_NORMALPREPSLEEP:
normalPrepSleepMainFunc(netHandleId);
break;
case OSEKNM_LIMPHOME:
limphomeMainFunc(netHandleId);
break;
case OSEKNM_LIMPHOMEPREPSLEEP:
limphomePrepSleepMainFunc(netHandleId);
break;
case OSEKNM_TwbsNORMAL:
normalTwbsMainFunc(netHandleId);
break;
case OSEKNM_TwbsLIMPHOME:
twbsLimphomeMainFunc(netHandleId);
break;
default:
break;
}
}
}
#if NOT_SUPPORTED_YET
/**
* @brief function is to read received ring data by application
* @param netId
* @param ringData
*/
void ReadRingData(NetIdType netId,RingDataRefType ringData){
NetIdType netHandleId;
/* Get NetHandle mapped to Actual netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
memcpy(ringData, OsekDirectNm_Networks[netHandleId].nmTransmitPdu.ringData, sizeof(RingDataType));
}
/**
* @brief function is to update Transmit ring data by application
* @param netId
* @param ringData
*/
/*lint -e{818} STANDARDIZED_API */
void TransmitRingData(NetIdType netId,RingDataRefType ringData){
NetIdType netHandleId;
/* Get NetHandle mapped to Actual netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
memcpy(OsekDirectNm_Networks[netHandleId].nmTransmitPdu.ringData, ringData, sizeof(RingDataType));
}
#endif
/**
* @brief Controller bus-off function
* @param netId
*/
void OsekDirectNm_ControllerBusOff(NetIdType netId){
uint8 netHandleId;
/* Figure 31 in ISO doc */ /** @req OSEKNM039 */
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
D_Offline(netId);
D_Init(netId,BusRestart);
/* Cancel all timers */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTyp = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTTx = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTMax = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = 0;
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTWbs = 0;
/* set timer TError */
OsekDirectNm_Networks[netHandleId].timer.osekdirectNmTError = (OsekNm_ConfigPtr->osekNmNetwork[netHandleId].osekDirectNmNodeconfParams->osekdirectNmTError + TIMER_2);
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.busoff = 1;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.limpHome = 1;
OsekDirectNm_Networks[netHandleId].nmState = OSEKNM_LIMPHOME;
#if (STD_ON == OSEKNM_DIRECT_STATE_CHANGE_INDICATION)
OsekNm_ConfigPtr->osekNmDirectCallBack(netId,OSEKNM_LIMPHOME);
#endif
}
/**
* @brief Transmission confirmation function
* @param netId
*/
void OsekDirectNm_TxConformation(NetIdType netId) {
uint8 netHandleId;
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.busoff = 0;
OsekDirectNm_Networks[netHandleId].transNmpdu = TRUE;
}
/**
* @brief Received message indication function
* @param netId
* @param NMPDU
*/
void OsekDirectNm_RxIndication(NetIdType netId, const OsekNm_PduType* nmPdu) {
uint8 netHandleId;
uint8 rxCount;
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
rxCount = OsekDirectNm_Networks[netHandleId].nmRxPduCount;
OsekDirectNm_Networks[netHandleId].nmRxPduCount++;
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.busoff = 0;
memcpy(&OsekDirectNm_Networks[netHandleId].nmRxPdu[rxCount], nmPdu, sizeof(OsekNm_PduType));
OsekDirectNm_Networks[netHandleId].rcvdNmpdu = TRUE;
}
#if (ISO_OSEK_NM == STD_ON)
/**
* @brief WakeUp indication function
* @param netId
*/
void OsekDirectNm_WakeupIndication(NetIdType netId){
uint8 netHandleId;
/* Get Mapped Network handle id to netId */
netHandleId = OsekNm_Internal_CheckNetId(netId);
OsekDirectNm_Networks[netHandleId].networkStatus.nodeStatus.busoff = 0;
if(OSEKNM_BUSSLEEP == OsekDirectNm_Networks[netHandleId].nmState) {
/* Wake up signal of the bus*/
D_Init(netId,BusAwake);
initFromBusSleep(netHandleId);
}
}
#endif
#ifdef HOST_TEST
OsekDirect_InternalType* readinternal_OsekNmDirectStat(void );
OsekDirect_InternalType* readinternal_OsekNmDirectStat(void)
{
return OsekDirectNm_Networks;
}
#endif
#endif
|
2301_81045437/classic-platform
|
communication/OsekNm/src/OsekDirectNm.c
|
C
|
unknown
| 58,055
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef OSEKNM_OSEKDIRECTNM_H_
#define OSEKNM_OSEKDIRECTNM_H_
#include "Std_Types.h"
#include "OsekNm_ConfigTypes.h"
#include "OsekNm_Cfg.h"
typedef struct {
TickType osekdirectNmTTx;
TickType osekdirectNmTTyp;
TickType osekdirectNmTMax;
TickType osekdirectNmTError;
TickType osekdirectNmTWbs;
}OseknmDirectTimer;
typedef struct {
NetworkStatusType sMask;
NetworkStatusType networkStatus;
SignallingMode sMode;
TaskType taskId;
EventMaskType eMask;
}OseknmStatusType;
typedef union{
uint32 b;
struct {
unsigned stable : 1;
unsigned limphome : 1;
}B;
}OsekNMMerkerType;
typedef struct{
OseknmStatusType osekNmStatus;
OsekNmDirectNmStateType nmState;
OsekNm_PduType nmTxPdu;
}OsekNm_InternalNetType;
typedef struct {
OsekNm_PduType nmTransmitPdu;
OsekNm_PduType nmRxPdu[OSEKNM_DIRECT_MAX_NODE_NUM];
NetworkStatusType networkStatus;
OsekNMMerkerType nmMerker;
OseknmDirectTimer timer;
OsekNm_CmaskParamsType nmDirectMask;
OsekNm_ConfigParamsType nmDirectConfig;
StatusRefType sMask;
StatusRefType targetStatus;
OsekNmDirectNmStateType nmState;
uint8 nmRxRetryCounter;
uint8 nmTxRetryCounter;
uint8 nmRxPduCount;
boolean rcvdNmpdu;
boolean transNmpdu;
}OsekDirect_InternalType;
/******* Function Declerations ***********/
/* ********* System Generation Support ************* */
/*InitNMType is a directive to select a NM from a given set of NM implementations.*/
void InitNMType(NetIdType netId, NMType nmType);
/* InitNMScaling is a directive for scaling the given NM of the referenced net */
void InitNMScaling(NetIdType netId,ScalingParamType scalingParams);
/*SelectHWRoutines is a directive to select routines from a given set of routines to drive the bus hardware.*/
void SelectHWRoutines(NetIdType netId,RoutineRefType busInit,RoutineRefType busAwake, RoutineRefType busSleep,RoutineRefType busRestart,RoutineRefType busShutdown);
/*InitCMaskTable is a directive for initializing an element of a table of relevant configuration
masks to be used by the signalling of changed configurations*/
void OsekDirectNm_InitCMaskTable(NetIdType netId,ConfigKindName configKind,ConfigRefType cMask);
/*InitTargetConfigTable is a directive for initializing an element of a table of relevant target
configurations to be used by the signalling of changed configurations*/
void Direct_InitTargetConfigTable(NetIdType netId,ConfigKindName configKind,ConfigRefType targetConfig);
/* InitIndDeltaConfig is a directive for specifying the indication of configuration changes. The concerned configuration is specified by <ConfigKind>. */
void InitIndDeltaConfig(NetIdType netId,ConfigKindName configKind,SignallingMode sMode,TaskType taskId,EventMaskType eMask);
/* InitSMaskTable is a directive for initializing an element of a table of relevant status masks
to be used by the signalling of changed network states */
/* void InitSMaskTable(NetIdType NetId,StatusRefType SMask); */
/*InitTargetStatusTable is a directive for initializing an element of a table of relevant target
network states to be used by the signalling of changed network states */
/* void InitTargetStatusTable(NetIdType NetId,StatusRefType TargetStatus); */
/*InitIndDeltaStatus is a directive for specifying the indication of status changes*/
/* void InitIndDeltaStatus(NetIdType NetId,SignallingMode SMode,TaskType TaskId,EventMaskType EMask); */
/* ********* Services Support for Config ************* */
/* This service makes the NM start or restart the configuration management */
StatusType InitConfig(NetIdType netId);
/* This service provides the actual configuration of the kind specified by <ConfigKind> */
StatusType OsekDirectNm_GetConfig(NetIdType netId,ConfigRefType config,ConfigKindName configKind);
/* The test configuration <TestConfig> is compared to the specified reference configuration
<RefConfig> taking account of the mask <CMask>.*/
StatusType OsekDirectNm_CmpConfig(NetIdType netId,ConfigRefType testConfig,ConfigRefType refConfig,ConfigRefType cMask);
/* A set of predefined parameter is selectable to drive the signalling of changed configurations */
StatusType SelectDeltaConfig(NetIdType netId,ConfigKindName configKind,ConfigHandleType configHandle,ConfigHandleType cMaskHandle);
/** @req OSEKNM004 */
/* StartNM starts the local Network Management. This causes the state transition from NMOff to NMOn*/
StatusType OsekDirectNm_StartNM(NetIdType netId);
/* StopNM stops the local Network Management. This causes the state transition from NMOn
* to NMShutDown and after processing of the shutdown activities to NMOff*/
StatusType OsekDirectNm_StopNM(NetIdType netId);
/* GotoMode serves to set the NM operating mode specified by <NewMode> */
StatusType OsekDirectNm_GotoMode(NetIdType netId,NMModeName newMode);
/* This service provides the current status of the network */
StatusType OsekDirectNm_GetStatus(NetIdType netId,StatusRefType networkStatus); /*lint !e9018 'NetworkStatus' with union based type 'StatusRefType */
/* A set of predefined parameter is selectable to drive the signaling of changed states */
/* StatusType SelectDeltaStatus(NetIdType NetId,StatusHandleType StatusHandle,StatusHandleType SMaskHandle); */
void OsekDirectNm_MainFunction(NetIdType netId);
/* ********* Services Support Direct Nm ************* */
/* InitDirectNMParams is a directive for initializing the parameters of the direct NM */
void InitDirectNMParams(NetIdType NetId,NodeIdType nodeId,TickType timerTyp,TickType timerMax, TickType timerError,TickType timerWaitBusSleep,TickType timerTx);
/* SilentNM disables the communication of the NM. This causes the state transition from NMActive to NMPassive*/
StatusType OsekDirectNm_SilentNM(NetIdType netId);
/* TalkNM enables the communication of the NM again, after a previous call of SilentNM. */
StatusType OsekDirectNm_TalkNM(NetIdType netId);
/* InitIndRingData is a directive for specifying the indication of received data in the data field
of a ring message, which is addressed to this node */
void InitIndRingData(NetIdType netId,SignallingMode sMode,TaskType taskId,EventMaskType eMask);
/* ReadRingData enables the application to read the data that has been received by a ring message */
void ReadRingData(NetIdType netId,RingDataRefType ringData);
/* This service enables the application to transmit data via the ring message */
void TransmitRingData(NetIdType netId,RingDataRefType ringData);
/* ********* DLL Functions ************* */
void OsekDirectNm_ControllerBusOff(NetIdType netId);
void OsekDirectNm_TxConformation(NetIdType netId);
void OsekDirectNm_RxIndication(NetIdType netId, const OsekNm_PduType* nmPdu);
#if (ISO_OSEK_NM == STD_ON)
void OsekDirectNm_WakeupIndication(NetIdType netId);
#endif
#endif /* OSEKNM_OSEKDIRECTNM_H_ */
|
2301_81045437/classic-platform
|
communication/OsekNm/src/OsekDirectNm.h
|
C
|
unknown
| 7,765
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include"OsekNm.h"
#if (OSEKNM_INDIRECT_NET_NUM > 0)
#include "OsekNm_ConfigTypes.h"
#include"OsekIndirectNm.h"
#include <string.h>
#include "SchM_OsekNm.h"
/** @req OSEKNM051 */ /* OSEKNM support indirect and direct modes */
typedef uint8 OsekNmNetHandleType;
extern const OsekNm_ConfigType* OsekNm_ConfigPtr;
OsekIndNm_InternalNetType OsekNm_Indirect_NetChannels[OSEKNM_INDIRECT_NET_NUM];
/** @req OSEKNM050 */
#define STATE_CHANGE_INDICATION_INDIRECT(state) \
netId = OsekNm_Internal_GetNetId(netHandle); \
OsekNm_ConfigPtr->osekNmIndirectCallBack(netId, state ); \
/** Static function declarations */
static void indirectInitNetworkStatus(OsekNmNetHandleType netHandle);
static void indirectInitPrivateConfig(OsekNmNetHandleType netHandle );
static void indirectInitConfig(OsekNmNetHandleType netHandle);
static void indirectTOBTimeoutEventHandle(OsekNmNetHandleType netHandle);
static void indirectTxandRxMsgNormalNotification(OsekNmNetHandleType netHandle, NodeIdType nodeId);
static void indirectTxandRxMsgLimphomeNotification(OsekNmNetHandleType netHandle, NodeIdType nodeId);
static uint8 indirectCheckNodeId(OsekNmNetHandleType netHandle, uint8 nodeId);
static void indirectAddToConfig(OsekNmNetHandleType netHandleId,ConfigKindName configKind,NodeIdType nodeId);
static void indirectRemoveFromConfig(OsekNmNetHandleType netHandleId,ConfigKindName configKind,NodeIdType nodeId);
static void indirectAddToPrivateConfig(OsekNmNetHandleType netHandleId,NodeIdType nodeId);
static void indirectInitExtendedNetworkStatus(OsekNmNetHandleType netHandle);
static void indirectInitExtendedConfig(OsekNmNetHandleType netHandle);
static void indirectIncConfigCount(OsekNmNetHandleType netHandle, uint8 nodeHandle);
static void indirectDecConfigCount(OsekNmNetHandleType netHandle, uint8 nodeHandle);
static void indirectIncStatusCount(OsekNmNetHandleType netHandle );
static void indirectDecStatusCount(OsekNmNetHandleType netHandle );
/**
* @brief Initialization of the configuration as per Figure 54 and Figure 62 in OsekNM ISO17356-5 document
* reset all bits of representing nodes in the network
* @param netHandle
*/
static void indirectInitConfig(OsekNmNetHandleType netHandle){
/* Considering the config as per NmConfigParams structure all nodes are represendted as bit position per configured node ID
* it will give the each node active status as per node ID */
memset(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectConfig.normal, 0 ,OSEKNM_NODE_MAX);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
/* as per Figure 62 in OsekNM ISO17356-5 document*/
indirectInitExtendedConfig(netHandle);
}
}
/**
* @brief Initialization of the private configuration as per fig 54 in OsekNM ISO17356-5 document
* reset all bits of representing nodes in the network
* @param netHandle
*/
static void indirectInitPrivateConfig(OsekNmNetHandleType netHandle){
/* this is replacement implemenation for init private config per bit per node as configured */
memset(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectPrivateConfig, 0 ,OSEKNM_NODE_MAX);
}
/**
* @brief Handling of TOB events during NMNormal and NNLimpome state as per Figure 51 and 52
* in OsekNM ISO17356-5 document.
* @param netHandle
*/
/* @req OSEKNM059 */ /* @req OSEKNM060 */
static void indirectTOBTimeoutEventHandle(OsekNmNetHandleType netHandle){
/* Last private config is saved in to Config and reset private config on TOB time out */
memcpy(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectConfig.normal,OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectPrivateConfig, OSEKNM_NODE_MAX);
indirectInitPrivateConfig(netHandle);
/* SetTimer TOB */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTOB+1u ;
}
/**
* @brief Function is to add Node status bit to present config based on the configKind
* @param netHandleId
* @param configKind
* @param nodeId
*/
static void indirectAddToConfig(OsekNmNetHandleType netHandleId,ConfigKindName configKind,NodeIdType nodeId){
ConfigRefType ConfigNode = NULL;
uint8 byte;
uint8 bit;
switch(configKind)
{
case NM_CKNORMAL:
ConfigNode = OsekNm_Indirect_NetChannels[netHandleId].indirectConfig.normal;
break;
case NM_CKNORMALEXTENDED:
ConfigNode = OsekNm_Indirect_NetChannels[netHandleId].indirectConfig.normalExtended;
break;
default:
break;
}
if(NULL != ConfigNode)
{
/* Set the corresponding bit in array to represent nodeId */
byte = nodeId / 8;
bit = nodeId % 8;
ConfigNode[byte] |= (uint8)(1u<<bit);
}
}
/**
* @brief Function call is to remove node status bit from configuration based on the configKind
* @param netHandleId
* @param configKind
* @param nodeId
*/
static void indirectRemoveFromConfig(OsekNmNetHandleType netHandleId,ConfigKindName configKind,NodeIdType nodeId) {
ConfigRefType ConfigNode = NULL;
uint8 byte;
uint8 bit;
switch(configKind)
{
case NM_CKNORMAL:
ConfigNode = OsekNm_Indirect_NetChannels[netHandleId].indirectConfig.normal;
break;
case NM_CKNORMALEXTENDED:
ConfigNode = OsekNm_Indirect_NetChannels[netHandleId].indirectConfig.normalExtended;
break;
default:
break;
}
if(NULL != ConfigNode)
{
/* Set the corresponding bit in array to represent nodeId */
byte = nodeId / 8;
bit = nodeId % 8;
ConfigNode[byte] &= (~(1u<<bit));
}
}
/**
* @brief Function is to add Node status bit to private config this is applicable only to TOB mode selected
* @param netHandleId
* @param nodeId
*/
static void indirectAddToPrivateConfig(OsekNmNetHandleType netHandleId,NodeIdType nodeId){
ConfigRefType ConfigNode;
uint8 byte;
uint8 bit;
ConfigNode = OsekNm_Indirect_NetChannels[netHandleId].indirectPrivateConfig;
/* Set the corresponding bit in array to represent nodeId */
byte = nodeId / 8;
bit = nodeId % 8;
ConfigNode[byte] |= (uint8)(1u<<bit);
}
/**
* @brief Function for incrementing config count for each node
* as per Figure 64 in OsekNM ISO17356-5 document
* @param netHandle
* @param nodeHandle
*/
/* @req OSEKNM068 *//* @req OSEKNM069 *//* @req OSEKNM070 */
static void indirectIncConfigCount(OsekNmNetHandleType netHandle, uint8 nodeHandle){
uint8 configuredvalue;
uint8 calculatedvalue;
/* Allocation of nodehandle in local structure for master at index 0 */
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] <=
(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectThreshold
- OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectNodevalues[nodeHandle-1].osekNmIndirectDeltaInc )){
configuredvalue = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectNodevalues[nodeHandle-1].osekNmIndirectDeltaInc;
calculatedvalue = OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] + configuredvalue;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] = calculatedvalue;
}else{
/* @req OSEKNM080*/
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectThreshold;
}
}
/**
* @brief Function for decrementing config count for each slave node
* as per Figure 65 in OsekNM ISO17356-5 document
* @param netId
* @param nodeId
*/
static void indirectDecConfigCount(OsekNmNetHandleType netHandle, uint8 nodeHandle){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] >= OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectNodevalues[nodeHandle-1].osekNmIndirectDeltaDec){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] = OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle]
-OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectNodevalues[nodeHandle-1].osekNmIndirectDeltaInc;
}else{
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] = 0;
}
}
/**
* @brief Function for decrementing status count for monitoring node
* as per Figure 65 in OsekNM ISO17356-5 document
* @param netHandle
*/
/* @req OSEKNM068 *//* @req OSEKNM069 *//* @req OSEKNM070 */
static void indirectDecStatusCount(OsekNmNetHandleType netHandle ){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount >=
OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectDeltaDec){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount = OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount - OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectDeltaDec;
}else{
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount = 0;
}
}
/**
* @brief Function for incrementing status count for monitoring node
* as per Figure 64 in OsekNM ISO17356-5 document
* @param netHandle
*/
/* @req OSEKNM068 *//* @req OSEKNM069 *//* @req OSEKNM070 */
static void indirectIncStatusCount(OsekNmNetHandleType netHandle ){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount <=
(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectThreshold
- OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectDeltaInc)){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount = OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount + OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectDeltaInc;
}else{
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectThreshold;
}
}
/**
* @brief Message notification from CanIF during NMNormal state
* Monitored application message received from remote node and monitored application transmitted by own node
* as per Figure 51 and 57 in OsekNM ISO17356-5 document
* @param netHandle
* @param nodeId
*/
/* @req OSEKNM053 */
static void indirectTxandRxMsgNormalNotification(OsekNmNetHandleType netHandle,NodeIdType nodeId){
uint8 nodeHandle;
nodeHandle = indirectCheckNodeId((netHandle-OSEKNM_DIRECT_NET_NUM),nodeId);
/* @req OSEKNM077*//* @req OSEKNM078*/
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == GLOBAL_TIMEOUT){
/* resetTimer TOB to initial value after receiving message */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTOB;
indirectAddToPrivateConfig((netHandle-OSEKNM_DIRECT_NET_NUM),nodeId);
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == TIMEOUT_PER_MESSAGE){
indirectAddToConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMAL, nodeId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
indirectDecConfigCount(netHandle,nodeHandle );
indirectAddToConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMALEXTENDED, nodeId);
}
}else{
/*do nothing */
}
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.limpHome = NMLIMPHOME_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.busoff = OSEKNM_NO_BUS_ERROR;
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == TIMEOUT_PER_MESSAGE){
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.ExtendedNetworkstatus = OSEKNM_NO_BUS_ERROR;
indirectDecStatusCount(netHandle);
}
}
}
/**
* @brief Message notification from CanIF during limphome state
* Monitored application message received from remote node and monitored application transmitted by own node
* as per Figure 52 and 58 in OsekNM ISO17356-5 document
* @param netHandle
* @param nodeId
*/
static void indirectTxandRxMsgLimphomeNotification(OsekNmNetHandleType netHandle, NodeIdType nodeId){
uint8 nodeHandle;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
NetIdType netId;
#endif
nodeHandle = indirectCheckNodeId((netHandle-OSEKNM_DIRECT_NET_NUM),nodeId);
/* @req OSEKNM077*//* @req OSEKNM078*/
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == GLOBAL_TIMEOUT){
/*as per Figure 52*/
/* SetTimer TOB */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTOB ;
indirectAddToPrivateConfig((netHandle-OSEKNM_DIRECT_NET_NUM),nodeId);
(void)nodeHandle;
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
/*as per Figure 58*/
indirectAddToConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMAL, nodeId);
indirectDecConfigCount(netHandle,nodeHandle );
indirectAddToConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMALEXTENDED, nodeId);
}else{
/* do nothing */
}
if(nodeId == OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectSourceNodeId){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TxOk = TRUE;
}else{
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].RxOk = TRUE;
}
if((OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TxOk == TRUE)&&(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].RxOk == TRUE)){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.limpHome = NMLIMPHOME_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.busoff = OSEKNM_NO_BUS_ERROR;
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
/*as per Figure 58*/
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.ExtendedNetworkstatus = OSEKNM_NO_BUS_ERROR;
/* As per ISO document in fig 58 it worngly mentioned as DecConfigCount instead of DecStatusCount so corrected in code */
indirectDecStatusCount(netHandle);
}
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_NORMAL;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION_INDIRECT(OSEKINDNM_NORMAL);
#endif
#if (STD_ON == ASR_OSEK_NM)
Nm_NetworkMode(OsekNmConfig.osekNmNetwork[netHandle-OSEKNM_DIRECT_NET_NUM].osekNmNetworkHandle);
#endif
}
}
/**
* @brief Message notification from CanIF after receiving and transmitting the message
* implemenation as per as per fig 57,51,52 and 58 in OsekNM ISO17356-5 document
* @param netId
* @param nodeId
*/
/* @req OSEKNM053 *//* @req OSEKNM056 *//* @req OSEKNM057 */
void OsekInDirectNm_Com_MsgNotification(NetIdType netId, NodeIdType nodeId){
/* @req OSEKNM074*//* @req OSEKNM075*/
uint8 netHandle;
netHandle = OsekNm_Internal_CheckNetId(netId);
/* After Message received/ Trnasmitted in nomal and limphome */
if(OsekNm_Indirect_NetChannels[netHandle].nmState == OSEKINDNM_LIMPHOME){
/* Message received durng LIMphome state as per fig 52 nad 58 */
indirectTxandRxMsgLimphomeNotification(netHandle,nodeId);
}else if(OsekNm_Indirect_NetChannels[netHandle].nmState == OSEKINDNM_NORMAL){
/* Message received durng normal state as per fig 51 and 57 */
indirectTxandRxMsgNormalNotification(netHandle,nodeId);
}else{
/* do noting */
}
}
/**
* @brief Initialisation of indirect Nm nodes network status
* implemenation as per as per fig 55 for TOB and Fig 63 for extended mode,
* @param netHandle
*/
static void indirectInitNetworkStatus(OsekNmNetHandleType netHandle){
/* As per ISO after init state transition should be to Normal, but as per ASR state should be BUS_SLEEP
* so to comply with ASR added this below case with condition compilation */
#if (ISO_OSEK_NM == STD_ON)
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.busoff = OSEKNM_NO_BUS_ERROR;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.nmOff = NM_ON;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.limpHome = NMLIMPHOME_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.bussleep = NMBUSSLEEP_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp = NMWAITBUSSLEEP_OFF;
#endif
#if (ASR_OSEK_NM == STD_ON)
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.busoff = OSEKNM_NO_BUS_ERROR;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.nmOff = NM_ON;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.limpHome = NMLIMPHOME_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.bussleep = NMBUSSLEEP_ON;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp = NMWAITBUSSLEEP_OFF;
#endif
}
/**
* @brief Initialisation of indirect Nm nodes extended network status
* implemenation as per as per Fig 63 for extended mode,
* @param netHandle
*/
static void indirectInitExtendedNetworkStatus(OsekNmNetHandleType netHandle){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.ExtendedNetworkstatus = OSEKNM_NO_BUS_ERROR;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount= 0u;
}
/**
* @brief Initialisation of indirect Nm nodes extended network configuration
* implemenation as per as per Fig 62 for extended mode,
* @param netHandle
*/
static void indirectInitExtendedConfig(OsekNmNetHandleType netHandle){
memset(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectConfig.normalExtended, 0x00 ,OSEKNM_NODE_MAX);
/* Considering monitoring node will be always in 0 th index */
memset(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter,0, OSEKNM_INDIRECT_NODES+1);
}
/**
* @brief Get NodeHandle Id from actual Nodeid and net handle
* @param NethandleId
* @param nodeId
* @return
*/
static uint8 indirectCheckNodeId(OsekNmNetHandleType NethandleId, uint8 nodeId){
uint8 NodehandleId;
NodehandleId = (uint8)OSEKNM_INVALID_NODEID;
if(OsekNm_ConfigPtr->osekNmNetwork[NethandleId].OsekNmIndirectNodeIdPrams->osekNmIndirectSourceNodeId==nodeId){
NodehandleId = 0;
}else{
for (uint8 i = 0; i < OsekNm_ConfigPtr->osekNmNetwork[NethandleId].OsekNmIndirectNodeIdPrams->osekNmIndirectNodeCount; i++) {
if(nodeId == OsekNm_ConfigPtr->osekNmNetwork[NethandleId].OsekNmIndirectNodeIdPrams->osekNmIndirectNodevalues[i].osekNmIndirectNodeId){
NodehandleId = (uint8)i+1;
break;
}
}
}
return NodehandleId;
}
/**
* @brief Handling of COM messge timeout notification for respective net and node ID
* Time out at monitoring application message from remote node expired
* or time out at monitoring transmission of own application message expired
* @param netid
* @param nodeid
*/
/* @req OSEKNM055*/ /* @req OSEKNM061*/
void OsekInDirectNm_comMsg_TimeoutHandle(NetIdType netHandle,NodeIdType nodeid){
/* @req OSEKNM074*//* @req OSEKNM076*/
/* implemenation as per as per Fig 57 */
uint8 nodeHandle;
/* @req OSEKNM077*//* @req OSEKNM079*/
nodeHandle = indirectCheckNodeId(netHandle-OSEKNM_DIRECT_NET_NUM,nodeid);
if((OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_NORMAL )
||(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_LIMPHOME)){
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == TIMEOUT_PER_MESSAGE){
indirectRemoveFromConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMAL, nodeid);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
indirectIncConfigCount(netHandle, nodeHandle);
/* @req OSEKNM080*/
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter[nodeHandle] == OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectThreshold){
indirectRemoveFromConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMALEXTENDED, nodeid);
}else{
indirectAddToConfig((netHandle-OSEKNM_DIRECT_NET_NUM), NM_CKNORMALEXTENDED, nodeid);
}
}
}
}
}
/**
* @brief This function is to execute fatal bus error like BusOff occured for CAN
* implemenation as per as per Fig 53 for tob and 59 for extended mode
* @param netId
*/
void OsekInDirectNm_FatalBusError_Handle(NetIdType netId){
uint8 netHandle;
netHandle = OsekNm_Internal_CheckNetId(netId);
if((OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_NORMAL )||(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_LIMPHOME)
||(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_WAITBUSSLEEP)
){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.limpHome = NMLIMPHOME_ON;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.busoff = ERROR_BUSBLOCKED;
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp == NMWAITBUSSLEEP_ON ){
/* @req OSEKNM065 */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_WAITBUSSLEEP;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
OsekNm_ConfigPtr->osekNmIndirectCallBack(netId, OSEKINDNM_WAITBUSSLEEP );
#endif
}
}
#if (ISO_OSEK_NM == STD_ON)
D_Offline(netId);
D_Init(netId,BusRestart);
#endif
/* SetTimer Terror */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTError;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TxOk = FALSE;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].RxOk = FALSE;
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
indirectIncStatusCount(netHandle);
/* @req OSEKNM080*/
if( OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount == OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectThreshold){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.ExtendedNetworkstatus = ERROR_BUS_COMM_NOT_POSSIBLE;
}else{
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.ExtendedNetworkstatus = OSEKNM_NO_BUS_ERROR;
}
}
/* @req OSEKNM064 */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_LIMPHOME;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
OsekNm_ConfigPtr->osekNmIndirectCallBack(netId, OSEKINDNM_LIMPHOME );
#endif
}
}
/**
* @brief StartNM starts the local Network Management. This causes the state transition from NMOff to NMOn
* implemenation as per as per Fig 50 for tob and 56 for extended mode
* @param netId
* @return
*/
/** @req OSEKNM005 */
StatusType OsekInDirectNm_StartNM(NetIdType netId){
uint8 config[OSEKNM_NODE_MAX];
uint8 netHandle;
netHandle = OsekNm_Internal_CheckNetId(netId);
StatusType retStatus = E_OK;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].RxOk = FALSE;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TxOk = FALSE;
#if (ISO_OSEK_NM == STD_ON)
D_Init(netId,BusInit);
D_Online(netId);
#endif
memset(config, 0x01 ,OSEKNM_NODE_MAX);
OsekInDirectNm_InitCMaskTable(netHandle, NM_CKNORMAL, config);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == GLOBAL_TIMEOUT){
/* SetTimer TOB */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTOB ;
indirectInitPrivateConfig(netHandle);
}
indirectInitConfig(netHandle);
/* As per ISO flow chart in Figure 56 Pg(69) InitExtendedConfig is called after InitConfig, But removed here
* because in InitConfig already InitExtendedConfig function is called */
indirectInitNetworkStatus(netHandle);
/*As per ISO flow chart in Figure 50 Pg(64) during init nmState is Normal, but as per ASR initialised to BUSSLEEP */
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
OsekInDirectNm_InitCMaskTable(netHandle, NM_CKNORMALEXTENDED, config);
indirectInitExtendedNetworkStatus(netHandle);
}
#if (ISO_OSEK_NM == STD_ON)
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_NORMAL;
#endif
#if (ASR_OSEK_NM == STD_ON)
/* @req OSEKNM066 */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_BUSSLEEP;
#endif
return retStatus;
}
/**
* @brief OsekIndNm_Processing contains state machine and timeouts handling
* @param netId
* @return void
*/
/** @req OSEKNM041 */ /** @req OSEKNM063 */
void OsekInDirectNm_Processing(NetIdType netId){
uint8 netHandle;
SchM_Enter_OsekNm_EA_0();
netHandle = OsekNm_Internal_CheckNetId(netId);
/* As per fig 59 and fig 53 handling of fatal bus error in limphome ste to decrement Terror timer
* in both extended and normal, TOB and timeout indication *//* @req OSEKNM062 */
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_LIMPHOME){
if (0 != OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft ){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft ==1){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft =0;
#if (ISO_OSEK_NM == STD_ON)
D_Online(netId);
#endif
}
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft >1){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft--;
}
}
}
/* @req OSEKNM077*//* @req OSEKNM078*/
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == GLOBAL_TIMEOUT){
/* This as per fig 51 and fig 52 TOB timeout events handling as per main function if message not received */
if((OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_LIMPHOME)
||(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_NORMAL)){
if (0!=OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft ){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft==1){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft =0;
indirectTOBTimeoutEventHandle(netHandle);
}
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft>1){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft--;
}
}
}
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTimeoutConf == TIMEOUT_PER_MESSAGE){
/* As per fig 60 handling Twait bus sleep timer time out and enter to bus sleep */
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState == OSEKINDNM_WAITBUSSLEEP){
if (OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft !=0){
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft==1){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft =0;
#if (ISO_OSEK_NM == STD_ON)
D_Init(netId, BusSleep);
#endif
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp = NMWAITBUSSLEEP_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.bussleep = NMBUSSLEEP_ON;
/* @req OSEKNM066 */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_BUSSLEEP;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
OsekNm_ConfigPtr->osekNmIndirectCallBack(netId, OSEKINDNM_BUSSLEEP );
#endif
#if (ASR_OSEK_NM == STD_ON)
Nm_BusSleepMode(OsekNmConfig.osekNmNetwork[netHandle].osekNmNetworkHandle);
#endif
}
if(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft>1){
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft--;
}
}
}
}else{
/* do nothing */
}
SchM_Exit_OsekNm_EA_0();
}
/**
* @brief StopNM stops the local Network Management. This causes the state transition from NMOn
* to NMShutDown and after processing of the shutdown activities to NMOff
* implemenation as per as per Fig 50 for tob and 56 for extended mode
* @param netId
* @return
*/
/** @req OSEKNM040 */
StatusType OsekInDirectNm_StopNM(NetIdType netId){
uint8 netHandle;
netHandle = OsekNm_Internal_CheckNetId(netId);
#if (ISO_OSEK_NM == STD_ON)
/* To perform shutdown activities*/
D_Init(netId,BusShutdown);
#endif
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.nmOff = NM_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState = OSEKINDNM_OFF;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
OsekNm_ConfigPtr->osekNmIndirectCallBack(netId, OSEKINDNM_OFF );
#endif
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp = NMWAITBUSSLEEP_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.bussleep = NMBUSSLEEP_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.limpHome = NMLIMPHOME_OFF;
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->configName == NM_CKNORMALEXTENDED ){
memset(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].indirectSlaveNodeCounter,0, OSEKNM_INDIRECT_NODES+1);
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].IndirectMasterNodeCount =0;
}
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft =0;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft =0; /* time out indirectSlaveNodeCounter for wait bus sleep */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft =0;
return E_OK;
}
/**
* @brief GotoMode serves to set the NM operating mode specified by <newMode>
* implemenation as per as per Fig 60 for tob and 61 for extended mode
* @param netId
* @param newMode
* @return
*/
/* @req OSEKNM062 */ /* @req OSEKNM071 */
StatusType OsekInDirectNm_GotoMode(NetIdType netHandle,NMModeName newMode){
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)||(ISO_OSEK_NM == STD_ON)
NetIdType netId;
netId = OsekNm_Internal_GetNetId(netHandle);
#endif
SchM_Enter_OsekNm_EA_0();
if(newMode == NM_BUSSLEEP) {
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].ToBTimeLeft =0;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TErrorTimeLeft=0;
switch(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState ){
case OSEKINDNM_NORMAL:
case OSEKINDNM_LIMPHOME:
#if (ISO_OSEK_NM == STD_ON)
D_Offline(netId);
#endif
/* SetTimer Twait bus sleep */
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].TwbsTimeLeft = OsekNm_ConfigPtr->osekNmNetwork[netHandle].OsekNmIndirectNodeIdPrams->osekNmIndirectTWBS;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp = NMWAITBUSSLEEP_ON;
/* @req OSEKNM065*/
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState =OSEKINDNM_WAITBUSSLEEP;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION_INDIRECT(OSEKINDNM_WAITBUSSLEEP)
#endif
break;
default:
/*do nothing*/
break;
}
} else if(newMode == NM_AWAKE) {
switch(OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState ){
case OSEKINDNM_WAITBUSSLEEP:
#if (ISO_OSEK_NM == STD_ON)
D_Online(netId);
#endif
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.twbsNormalLimp = NMWAITBUSSLEEP_OFF;
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState =OSEKINDNM_NORMAL;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION_INDIRECT(OSEKINDNM_NORMAL)
#endif
#if (STD_ON == ASR_OSEK_NM)
Nm_NetworkMode(OsekNmConfig.osekNmNetwork[netHandle-OSEKNM_DIRECT_NET_NUM].osekNmNetworkHandle);
#endif
break;
case OSEKINDNM_BUSSLEEP:
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.bussleep = NMBUSSLEEP_OFF;
#if (ISO_OSEK_NM == STD_ON)
D_Init(netId,BusAwake);
D_Online(netId);
#endif
OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].nmState =OSEKINDNM_NORMAL;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
STATE_CHANGE_INDICATION_INDIRECT(OSEKINDNM_NORMAL)
#endif
#if (STD_ON == ASR_OSEK_NM)
Nm_NetworkMode(OsekNmConfig.osekNmNetwork[netHandle-OSEKNM_DIRECT_NET_NUM].osekNmNetworkHandle);
#endif
break;
default:
/*do nothing*/
break;
}
}else{
/*do nothing */
}
SchM_Exit_OsekNm_EA_0();
return E_OK;
}
/**
* @brief This service provides the current status of the network.
* @param netId
* @param networkStatus
* @return
*/
/** @req OSEKNM054 *//* @req OSEKNM055*/
/* @req OSEKNM058 */
/*lint --e{9018}*/ /* 'networkStatus' with union based type 'StatusRefType' */
StatusType OsekInDirectNm_GetStatus(NetIdType netHandle,StatusRefType networkStatus){
/** @req OSEKNM045 */
StatusType status = E_OK;
memcpy(networkStatus, &OsekNm_Indirect_NetChannels[netHandle-OSEKNM_DIRECT_NET_NUM].networkStatus, sizeof(NetworkStatusType));
return status;
}
/**
* @brief InitCMaskTable is a directive for initializing an element of a table of relevant configuration
* masks to be used by the signalling of changed configurations.
* @param netId
* @param configKind
* @param cMask
*/
void OsekInDirectNm_InitCMaskTable(NetIdType netHandleId,ConfigKindName configKind, ConfigRefType cMask)
{
switch(configKind)
{
case NM_CKNORMAL:
memcpy(OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].NmInDirectMask.normal, cMask, OSEKNM_NODE_MAX);
break;
case NM_CKNORMALEXTENDED:
memcpy(OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].NmInDirectMask.normalExtended, cMask, OSEKNM_NODE_MAX);
break;
default:
break;
}
}/*lint !e818 STANDARDIZED_API */
/**
* @brief This service provides the actual configuration of the kind specified by <configKind>
* @param netId
* @param configKind
* @param targetConfig
*/
void OsekInDirectNm_InitTargetConfigTable(NetIdType netHandleId,ConfigKindName configKind,ConfigRefType targetConfig)
{
switch(configKind)
{
case NM_CKNORMAL:
memcpy(OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].indirectConfig.normal,targetConfig,OSEKNM_NODE_MAX);
break;
case NM_CKNORMALEXTENDED:
memcpy(OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].indirectConfig.normalExtended,targetConfig,OSEKNM_NODE_MAX);
break;
default:
break;
}
}/*lint !e818 STANDARDIZED_API */
/**
* @brief This service provides the actual configuration of the kind specified by <configKind>
* @param netHandleId
* @param Config
* @param configKind
* @return
*/
/** @req OSEKNM043 */
StatusType OsekInDirectNm_GetConfig(NetIdType netHandleId,ConfigRefType Config,ConfigKindName configKind){
switch(configKind)
{
case NM_CKNORMAL:
memcpy(Config, OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].indirectConfig.normal, OSEKNM_NODE_MAX);
break;
case NM_CKNORMALEXTENDED:
memcpy(Config, OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].indirectConfig.normalExtended, OSEKNM_NODE_MAX);
break;
default:
break;
}
return E_OK;
}
/**
* @brief The test configuration <testConfig> is compared to the specified reference configuration
* <RefConfig> taking account of the mask <cMask>.
* @param netHandleId
* @param testConfig
* @param RefConfig
* @param cMask
* @return
*/
/** @req OSEKNM044 */
StatusType OsekInDirectNm_CmpConfig(NetIdType netHandleId,ConfigRefType testConfig,ConfigRefType RefConfig,ConfigRefType cMask){
StatusType retStatus = E_OK;
uint8 result;
uint8 i;
(void)netHandleId;
/* (<testConfig> EXOR <RefConfig>) of the node within the network is identified within the <cMask> by TRUE. */
for(i=0; i < OSEKNM_NODE_MAX; i++)
{
result = testConfig[i]^RefConfig[i];
result &= cMask[i];
result = ~result;
if(result != 0xFFU)
{
retStatus = E_NOT_OK;
break;
}
}
return retStatus;
}/*lint !e818 STANDARDIZED_API */
#if (ISO_OSEK_NM == STD_ON)
/**
* @brief WakeUp indication function
* @param netId
*/
void OsekInDirectNm_WakeupIndication(NetIdType netId)
{
uint8 netHandleId;
netHandleId = OsekNm_Internal_CheckNetId(netId);
OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].networkStatus.nodeStatus.bussleep = NMBUSSLEEP_OFF;
D_Init(netId,BusAwake);
D_Online(netId);
OsekNm_Indirect_NetChannels[netHandleId-OSEKNM_DIRECT_NET_NUM].nmState =OSEKINDNM_NORMAL;
#if (STD_ON == OSEKNM_INDIRECT_STATE_CHANGE_INDICATION)
OsekNm_ConfigPtr->osekNmIndirectCallBack(netId, OSEKINDNM_NORMAL );
#endif
}
#endif
#ifdef HOST_TEST
OsekIndNm_InternalNetType* readInternal_OsekNmIndirectStatus(void );
OsekIndNm_InternalNetType* readInternal_OsekNmIndirectStatus(void)
{
return OsekNm_Indirect_NetChannels;
}
#endif
#endif
|
2301_81045437/classic-platform
|
communication/OsekNm/src/OsekIndirectNm.c
|
C
|
unknown
| 43,277
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef OSEKNM_OSEKINDIRECTNM_H_
#define OSEKNM_OSEKINDIRECTNM_H_
#include "Std_Types.h"
/* OsekNm Indirect Internal types
* Encoding of the network status as per Table 3 and page 17 */
/* @req OSEKNM052 */
#define OSEKNM_NO_BUS_ERROR 0u
#define ERROR_BUSBLOCKED 1u
#define ERROR_BUS_COMM_NOT_POSSIBLE 2u
#define RESERVED 3u
#define NM_ON 0u
#define NM_OFF 1u
#define NMLIMPHOME_OFF 0u
#define NMLIMPHOME_ON 1u
#define NMBUSSLEEP_OFF 0u
#define NMBUSSLEEP_ON 1u
#define NMWAITBUSSLEEP_OFF 0u
#define NMWAITBUSSLEEP_ON 1u
/* Internal node status of indirect NM */
typedef struct
{
volatile TickType ToBTimeLeft;
volatile TickType TwbsTimeLeft; /* time out counter for wait bus sleep */
volatile TickType TErrorTimeLeft; /* time out counter for bus error */
NetworkStatusType networkStatus;
OsekNmIndirectNmStateType nmState;
OsekNm_PduType nmTxPdu;
/* Node monitor counter for slaves if configured as master and monitoring node index is 0
* Considering monitored node index is always 0 */
uint8 indirectSlaveNodeCounter[OSEKNM_INDIRECT_NODES+1];
uint8 IndirectMasterNodeCount;
OsekNm_CmaskParamsType NmInDirectMask;
OsekNm_ConfigParamsType indirectConfig;
uint8 indirectPrivateConfig[OSEKNM_NODE_MAX]; /* internal private config */
boolean TxOk;
boolean RxOk;
}OsekIndNm_InternalNetType;
/******* Function Declerations ***********/
/* ********* Services Support for Config ************* */
/* StartNM starts the local Network Management. This causes the state transition from NMOff to NMOn*/
StatusType OsekInDirectNm_StartNM(NetIdType netId);
/* StopNM stops the local Network Management. This causes the state transition from NMOn
* to NMShutDown and after processing of the shutdown activities to NMOff*/
/** @req OSEKNM004 */
StatusType OsekInDirectNm_StopNM(NetIdType netId);
/* GotoMode serves to set the NM operating mode specified by <NewMode> */
StatusType OsekInDirectNm_GotoMode(NetIdType netHandle,NMModeName newMode);
StatusType OsekInDirectNm_GetStatus(NetIdType netHandle,StatusRefType networkStatus);/*lint !e9018 'NetworkStatus' with union based type 'StatusRefType */
void OsekInDirectNm_FatalBusError_Handle(NetIdType netId);
void OsekInDirectNm_comMsg_TimeoutHandle(NetIdType netid,NodeIdType nodeid);
void OsekInDirectNm_Processing(NetIdType netId);
void OsekInDirectNm_Com_MsgNotification(NetIdType netId, NodeIdType nodeId);
StatusType OsekInDirectNm_CmpConfig(NetIdType netHandleId,ConfigRefType testConfig,ConfigRefType RefConfig,ConfigRefType cMask);
StatusType OsekInDirectNm_GetConfig(NetIdType netHandleId,ConfigRefType Config,ConfigKindName configKind);
#if (ISO_OSEK_NM == STD_ON)
void OsekInDirectNm_WakeupIndication(NetIdType netId);
#endif
void OsekInDirectNm_InitCMaskTable(NetIdType netHandleId,ConfigKindName configKind, ConfigRefType cMask);
void OsekInDirectNm_InitTargetConfigTable(NetIdType netHandleId,ConfigKindName configKind,ConfigRefType targetConfig);
#endif /* OSEKNM_OSEKINDIRECTNM_H_ */
|
2301_81045437/classic-platform
|
communication/OsekNm/src/OsekIndirectNm.h
|
C
|
unknown
| 3,982
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include"OsekNm.h"
#include"OsekDirectNm.h"
#include"OsekIndirectNm.h"
#if (OSEKNM_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
#ifdef HOST_TEST
boolean nwRequestCalled;
boolean nwReleaseCalled;
#endif
/* Configuration of oseknm channel */
const OsekNm_ConfigType* OsekNm_ConfigPtr = NULL;
OsekNm_Internal_InitStatusType osekNmInitStatus =OSEKNM_STATUS_UNINIT;
#if !(((OSEKNM_SW_MAJOR_VERSION == 1) && (OSEKNM_SW_MINOR_VERSION == 0)) )
#error OsekNm: Configuration file expected BSW module version to be 1.0.*
#endif
/*lint -emacro(904,OSEKNM_DET_REPORTERROR) //904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
#if (OSEKNM_DEV_ERROR_DETECT == STD_ON)
#define OSEKNM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
(void)Det_ReportError(OSEKNM_MODULE_ID, 0, _api, _error); \
return __VA_ARGS__; \
}
#else
#define OSEKNM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
return __VA_ARGS__; \
}
#endif
static Std_ReturnType OsekNm_Internal_ValidateNetId(const NetIdType netId);
static Std_ReturnType OsekNm_Internal_ValidateNmChannel(const NetworkHandleType nmHandle );
/**
* @brief Get NetHandle Id from actual netId
* @param netId
* @return
*/
uint8 OsekNm_Internal_CheckNetId ( uint8 netId){
uint8 nethandleId;
nethandleId = (uint8)OSEKNM_INVALID_NETID;
for (uint8 i = 0; i < OsekNm_ConfigPtr->osekNmNetworkCount; i++) {
if(netId == OsekNmConfig.osekNmNetwork[i].netId) {
nethandleId = (uint8)i;
break;
}
}
return nethandleId;
}
/**
* @brief - To validated the correct net ID received.
* @param netId
* @return
*/
static Std_ReturnType OsekNm_Internal_ValidateNetId(const NetIdType netId){
uint8 loopIndex;
Std_ReturnType retValue;
retValue = E_NOT_OK;
for (loopIndex = 0; loopIndex < (OSEKNM_INDIRECT_NET_NUM+OSEKNM_DIRECT_NET_NUM); loopIndex++) {
if(netId == OsekNmConfig.osekNmNetwork[loopIndex].netId){
retValue = E_OK;
break;
}
}
return retValue;
}
/**
* @brief - To validated the correct nm channel received.
* @param nmHandle
* @return
*/
static Std_ReturnType OsekNm_Internal_ValidateNmChannel(const NetworkHandleType nmHandle ){
uint8 loopIndex;
Std_ReturnType retValue;
retValue = E_NOT_OK;
for (loopIndex = 0; loopIndex < (OSEKNM_INDIRECT_NET_NUM+OSEKNM_DIRECT_NET_NUM); loopIndex++) {
if(nmHandle == OsekNmConfig.osekNmNetwork[loopIndex].osekNmNetworkHandle) {
retValue = E_OK;
break;
}
}
return retValue;
}
/**
* @brief To get the networkHandle from NmNetwork handle
* @param nmHandle
* @return
*/
uint8 OsekNm_Internal_nmHandleToNetHandle( const NetworkHandleType nmHandle){
uint8 nethandleId;
nethandleId = (uint8)OSEKNM_INVALID_NETID;
for (uint8 i = 0; i < OsekNm_ConfigPtr->osekNmNetworkCount; i++) {
if(nmHandle == OsekNmConfig.osekNmNetwork[i].osekNmNetworkHandle) {
nethandleId = OsekNmConfig.osekNmNetwork[i].networkHandle;
break;
}
}
return nethandleId;
}
/**
* @brief Get Actual Node Id from nethandleId
* @param nethandleId
* @return
*/
uint8 OsekNm_Internal_GetNetId ( uint8 nethandleId){
uint8 netId;
netId = (uint8)OSEKNM_INVALID_NETID;
for (uint8 i = 0; i < OsekNm_ConfigPtr->osekNmNetworkCount; i++) {
if(nethandleId == OsekNmConfig.osekNmNetwork[i].networkHandle) {
netId = OsekNmConfig.osekNmNetwork[i].netId;
break;
}
}
return netId;
}
/**
* @brief function is to start of NM
* @param oseknmConfigPtr
*/
void OsekNm_Init( const OsekNm_ConfigType * const oseknmConfigPtr ){
uint8 net;
NetIdType netId;
OsekNm_ConfigPtr = oseknmConfigPtr;
osekNmInitStatus = OSEKNM_STATUS_UNINIT;
OSEKNM_DET_REPORTERROR((NULL != oseknmConfigPtr),OSEKNM_SERVICE_ID_INIT,OSEKNM_E_INVALID_POINTER);
for (net=0; net < OsekNm_ConfigPtr->osekNmNetworkCount; net++){
netId = OsekNm_Internal_GetNetId(net);
if(OsekNm_ConfigPtr->osekNmNetwork[net].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
(void)OsekInDirectNm_StartNM(netId);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork->osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
(void)OsekDirectNm_StartNM(netId);
#endif
}else{
/*do nothing */
}
}
osekNmInitStatus =OSEKNM_STATUS_INIT;
}
/**
* @brief to get version info of the oseknm Module
* @param versioninfo
*/
#if ( OSEKNM_VERSION_INFO_API == STD_ON )
void OsekNm_GetVersionInfo(Std_VersionInfoType* versioninfo){
OSEKNM_DET_REPORTERROR((NULL != versioninfo),OSEKNM_SERVICE_ID_GET_VERSION_INFO,OSEKNM_E_INVALID_POINTER);
STD_GET_VERSION_INFO(versioninfo, OSEKNM);
return;
}
#endif /* OSEKNM_VERSION_INFO_API */
/**
* @brief function is to stop NM network
* @param netId
*/
void OsekNm_DeInit(NetIdType netId){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_DEINIT,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If Net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_DEINIT,OSEKNM_E_INVALID_NETID);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
(void)OsekInDirectNm_StopNM(netId);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
(void)OsekDirectNm_StopNM(netId);
#endif
}else{
/*do nothing */
}
}
/**
* @brief Transmission confirmation indication
* @param netId
* @param nodeId
*/
void OsekNm_TxConfirmation(NetIdType netId, NodeIdType nodeId){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_TX_CONFIRMATION,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_TX_CONFIRMATION,OSEKNM_E_INVALID_NETID);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_Com_MsgNotification(netId,nodeId);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
OsekDirectNm_TxConformation(netId);
(void)nodeId; /* To avoid Lint warning */
#endif
}else{
/*do nothing */
}
}
/**
* @brief function is to indicate reception of NMPDU message
* @param netId
* @param nodeId
* @param nmPdu
*/
void OsekNm_RxIndication(NetIdType netId,NodeIdType nodeId, const OsekNm_PduType* nmPdu){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_RX_INDICATION,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_RX_INDICATION,OSEKNM_E_INVALID_NETID);
OSEKNM_DET_REPORTERROR((NULL != nmPdu),OSEKNM_SERVICE_ID_RX_INDICATION,OSEKNM_E_INVALID_POINTER);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_Com_MsgNotification(netId,nodeId);
(void)*nmPdu;/* To avoid Lint warning */
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
(void)nodeId;/* To avoid Lint warning */
OsekDirectNm_RxIndication(netId, nmPdu);
#endif
}else{
/*do nothing */
}
}
/**
* @brief OsekNm_MainFuntion
* @return void
*/
void OsekNm_MainFuntion(void){
uint8 net;
NetIdType netId;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_MAINFUNCTION,OSEKNM_E_NOT_INITIALIZED);
for (net=0; net < OsekNm_ConfigPtr->osekNmNetworkCount; net++){
netId = OsekNm_Internal_GetNetId(net);
if(NM_INDIRECT == OsekNm_ConfigPtr->osekNmNetwork[net].osekNmType) {
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_Processing(netId);
#endif
}
if(NM_DIRECT == OsekNm_ConfigPtr->osekNmNetwork[net].osekNmType) {
#if (OSEKNM_DIRECT_NET_NUM > 0)
OsekDirectNm_MainFunction(netId);
#endif
}
}
}
/**
* @brief Controller bus off indication
* @param netId
*/
void OsekNm_ControllerBusOff(NetIdType netId){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_CONTROLLER_BUSOFF,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_CONTROLLER_BUSOFF,OSEKNM_E_INVALID_NETID);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_FatalBusError_Handle(netId);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
OsekDirectNm_ControllerBusOff(netId);
#endif
}else{
/*do nothing */
}
}
/**
* @brief timeout notification indication
* @param netId
* @param nodeId
*/
void OsekNm_TimeoutNotification(NetIdType netId,NodeIdType nodeId){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_TIMEOUT_NOTIFICATION,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_TIMEOUT_NOTIFICATION,OSEKNM_E_INVALID_NETID);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_comMsg_TimeoutHandle(netHandle,nodeId);
#endif
}else{
#if (OSEKNM_DIRECT_NET_NUM > 0)
(void)nodeId; /* Added to fix lint error Direct Nm will not use this API*/
#endif
}
}
/**
* @brief function to request for communication
* @param nmHandle
* @return
*/
Std_ReturnType OsekNm_NetworkRequest( const NetworkHandleType nmHandle ){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_NETWORK_REQUEST,OSEKNM_E_NOT_INITIALIZED,E_NOT_OK);
status = OsekNm_Internal_ValidateNmChannel(nmHandle);
/* If nm network handle not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_NETWORK_REQUEST,OSEKNM_E_INVALID_NMCHANNEL,E_NOT_OK);
netHandle = OsekNm_Internal_nmHandleToNetHandle(nmHandle);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
status = OsekInDirectNm_GotoMode(netHandle,NM_AWAKE);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
status = OsekDirectNm_GotoMode(netHandle,NM_AWAKE);
#endif
}else{
/*do nothing */
}
#ifdef HOST_TEST
nwRequestCalled = TRUE;
#endif
return status;
}
/**
* @brief function is to release communication and goto sleep
* @param nmHandle
* @return
*/
Std_ReturnType OsekNm_NetworkRelease( const NetworkHandleType nmHandle ){
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_NETWORK_RELEASE,OSEKNM_E_NOT_INITIALIZED,E_NOT_OK);
status = OsekNm_Internal_ValidateNmChannel(nmHandle);
/* If nm network handle not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_NETWORK_RELEASE,OSEKNM_E_INVALID_NMCHANNEL,E_NOT_OK);
netHandle = OsekNm_Internal_nmHandleToNetHandle(nmHandle);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
status = OsekInDirectNm_GotoMode(netHandle,NM_BUSSLEEP);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
status = OsekDirectNm_GotoMode(netHandle,NM_BUSSLEEP);
#endif
}else{
/*do nothing */
}
#ifdef HOST_TEST
nwReleaseCalled = TRUE;
#endif
return status;
}
/**
* @brief Function to remember list of relevant configured nodes
* @param netId
* @param configKind
* @param cMask
*/
void OsekNm_InitCMaskTable(NetIdType netId,ConfigKindName configKind, ConfigRefType cMask)
{
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_INIT_CMASK_TABLE,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_INIT_CMASK_TABLE,OSEKNM_E_INVALID_NETID);
/*lint -e{685} range check for enum */
OSEKNM_DET_REPORTERROR(((configKind >=NM_CKNORMAL)&&(configKind <=NM_CKLIMPHOME)),OSEKNM_SERVICE_ID_INIT_CMASK_TABLE,OSEKNM_E_INVALID_CONFIGKIND);
OSEKNM_DET_REPORTERROR((NULL != cMask),OSEKNM_SERVICE_ID_INIT_CMASK_TABLE,OSEKNM_E_INVALID_POINTER);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_InitCMaskTable(netId,configKind,cMask);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
OsekDirectNm_InitCMaskTable(netId,configKind,cMask);
#endif
}else{
/*do nothing */
}
}/*lint !e818 STANDARDIZED_API */
/**
* @brief InitTargetConfigTable
* @param netId
* @param configKind
* @param targetConfig
*/
void OsekNm_InitTargetConfigTable(NetIdType netId,ConfigKindName configKind,ConfigRefType targetConfig)
{
uint8 netHandle;
Std_ReturnType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_INIT_TARGETCONFIG_TABLE,OSEKNM_E_NOT_INITIALIZED);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_INIT_TARGETCONFIG_TABLE,OSEKNM_E_INVALID_NETID);
/*lint -e{685} range check for enum */
OSEKNM_DET_REPORTERROR(((configKind >=NM_CKNORMAL)&&(configKind <=NM_CKLIMPHOME)),OSEKNM_SERVICE_ID_INIT_TARGETCONFIG_TABLE,OSEKNM_E_INVALID_CONFIGKIND);
OSEKNM_DET_REPORTERROR((NULL != targetConfig),OSEKNM_SERVICE_ID_INIT_TARGETCONFIG_TABLE,OSEKNM_E_INVALID_POINTER);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
OsekInDirectNm_InitTargetConfigTable(netHandle,configKind,targetConfig);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
Direct_InitTargetConfigTable(netHandle,configKind,targetConfig);
#endif
}else{
/*do nothing */
}
}/*lint !e818 STANDARDIZED_API */
/**
* @brief Function is to check comparison of two configuration
* @param netId
* @param testConfig
* @param refConfig
* @param cMask
* @return
*/
StatusType OsekNm_CmpConfig(NetIdType netId,ConfigRefType testConfig,ConfigRefType refConfig,ConfigRefType cMask){
uint8 netHandle;
StatusType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_CMP_CONFIG,OSEKNM_E_NOT_INITIALIZED,E_NOT_OK);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_CMP_CONFIG,OSEKNM_E_INVALID_NETID,E_NOT_OK);
OSEKNM_DET_REPORTERROR((NULL != testConfig),OSEKNM_SERVICE_ID_CMP_CONFIG,OSEKNM_E_INVALID_POINTER,E_NOT_OK);
OSEKNM_DET_REPORTERROR((NULL != refConfig),OSEKNM_SERVICE_ID_CMP_CONFIG,OSEKNM_E_INVALID_POINTER,E_NOT_OK);
OSEKNM_DET_REPORTERROR((NULL != cMask),OSEKNM_SERVICE_ID_CMP_CONFIG,OSEKNM_E_INVALID_POINTER,E_NOT_OK);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
status = OsekInDirectNm_CmpConfig(netHandle,testConfig,refConfig,cMask);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
status = OsekDirectNm_CmpConfig(netHandle,testConfig,refConfig,cMask);
#endif
}else{
/*do nothing */
}
return status;
}
/**
* @brief function is to make current configuration available
* @param netId
* @param Config
* @param configKind
* @return
*/
StatusType OsekNm_GetConfig(NetIdType netId,ConfigRefType config,ConfigKindName configKind){
uint8 netHandle;
StatusType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_GET_CONFIG,OSEKNM_E_NOT_INITIALIZED,E_NOT_OK);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_GET_CONFIG,OSEKNM_E_INVALID_NETID,E_NOT_OK);
OSEKNM_DET_REPORTERROR((NULL != config),OSEKNM_SERVICE_ID_GET_CONFIG,OSEKNM_E_INVALID_POINTER,E_NOT_OK);
/*lint -e{685} range check for enum */
OSEKNM_DET_REPORTERROR(((configKind >=NM_CKNORMAL)&&(configKind <=NM_CKLIMPHOME)),OSEKNM_SERVICE_ID_GET_CONFIG,OSEKNM_E_INVALID_CONFIGKIND,E_NOT_OK);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
status = OsekInDirectNm_GetConfig(netHandle,config,configKind);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
status = OsekDirectNm_GetConfig(netHandle,config,configKind);
#endif
}else{
/*do nothing */
}
return status;
}
/**
* @brief Function is to make current status available
* @param netId
* @param networkStatus
* @return
*/
/*lint --e{9018}*/ /* 'networkStatus' with union based type 'StatusRefType' */
StatusType OsekNm_GetStatus(NetIdType netId, StatusRefType networkStatus) {
uint8 netHandle;
StatusType status;
OSEKNM_DET_REPORTERROR((OSEKNM_STATUS_INIT == osekNmInitStatus),OSEKNM_SERVICE_ID_GET_STATUS,OSEKNM_E_NOT_INITIALIZED,E_NOT_OK);
status = OsekNm_Internal_ValidateNetId(netId);
/* If net Id not found */
OSEKNM_DET_REPORTERROR((status != E_NOT_OK),OSEKNM_SERVICE_ID_GET_STATUS,OSEKNM_E_INVALID_NETID,E_NOT_OK);
OSEKNM_DET_REPORTERROR((NULL != networkStatus),OSEKNM_SERVICE_ID_GET_STATUS,OSEKNM_E_INVALID_POINTER,E_NOT_OK);
netHandle = OsekNm_Internal_CheckNetId(netId);
if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_INDIRECT){
#if (OSEKNM_INDIRECT_NET_NUM > 0)
status = OsekInDirectNm_GetStatus(netHandle,networkStatus);
#endif
}else if(OsekNm_ConfigPtr->osekNmNetwork[netHandle].osekNmType == NM_DIRECT){
#if (OSEKNM_DIRECT_NET_NUM > 0)
status = OsekDirectNm_GetStatus(netHandle,networkStatus);
#endif
}else{
/*do nothing */
}
return status;
/*lint --e{715,818}*/ /* 'networkStatus' with union based type 'StatusRefType' */
}
|
2301_81045437/classic-platform
|
communication/OsekNm/src/OsekNm.c
|
C
|
unknown
| 21,232
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "OsekNm_ConfigTypes.h"
#include "OsekDirectNm.h"
#include "OsekNm.h"
#include "CanIf.h"
#include <string.h>
#include "OsekNm_Cfg.h"
extern const OsekNm_ConfigType* OsekNm_ConfigPtr;
/**
* @brief function is used to init five service ex businit, bussleep etc..
* @param netId
* @param InitRoutine
*/
void D_Init(NetIdType netId,RoutineRefType initRoutine)
{
initRoutine(netId);
}
/**
*
* @param netId
*/
void D_Online(NetIdType netId) {
(void)netId;
}
void D_Offline(NetIdType netId) {
(void)netId;
}
/**
* @brief Function needed by DLL to initialize the bus hardware once at the start of the network
* @param netId
*/
void BusInit(NetIdType netId) {
(void)netId;
}
/**
* @brief Function needed by DLL to reinitialize the bus hardware to leave the power down mode
* @param netId
*/
void BusAwake(NetIdType netId) {
(void)netId;
}
/**
* @brief Function needed by DLL to shut down the bus hardware
* @param netId
*/
void BusShutdown(NetIdType netId) {
(void)netId;
}
/**
* @brief Function needed by DLL to initialize the power down mode of the bus hardware
* @param netId
*/
void BusSleep(NetIdType netId) {
(void)netId;
}
/**
* @brief Function needed by DLL to restart the bus hardware in the case of a fatal bus error
* @param netId
*/
void BusRestart(NetIdType netId) {
(void)netId;
}
/**
* @brief Function is transmit message by decoding nmPdu data to the network
* @param netId
* @param nmPdu
* @param dlc
* @return
*/
StatusType D_Window_Data_req(NetIdType netId, const OsekNm_PduType* nmPdu,uint8 dlc)
{
StatusType status;
NetIdType netHandleId;
PduInfoType pdu;
uint8 data[8];
netHandleId = OsekNm_Internal_CheckNetId(netId);
pdu.SduLength = dlc;
pdu.SduDataPtr = data;
data[0] = nmPdu->destination;
data[1] = nmPdu->OpCode.b;
memcpy(&data[2], nmPdu->ringData, (dlc-2));
status = CanIf_Transmit(OsekNm_ConfigPtr->osekNmNetwork[netHandleId].canIfTxLPduRef,&pdu);
return status;
}
|
2301_81045437/classic-platform
|
communication/OsekNm/src/OsekNmDllStubs.c
|
C
|
unknown
| 2,858
|
# PduR
obj-$(USE_PDUR) += PduR_CanNm.o
obj-$(USE_PDUR) += PduR_Com.o
obj-$(USE_PDUR) += PduR_Logic.o
obj-$(USE_PDUR) += PduR_LinIf.o
obj-$(USE_PDUR) += PduR_CDD_LinSlvIf.o
obj-$(USE_PDUR) += PduR_CddPduR.o
pb-obj-$(USE_PDUR) += PduR_PbCfg.o
pb-pc-file-$(USE_PDUR) += PduR_Cfg.h PduR_Cfg.c
obj-$(USE_PDUR) += PduR_Cfg.o
obj-$(USE_PDUR) += PduR_CanIf.o
obj-$(USE_PDUR) += PduR_CanTp.o
obj-$(USE_PDUR) += PduR_J1939Tp.o
obj-$(USE_PDUR) += PduR_IpduM.o
obj-$(USE_PDUR) += PduR_Dcm.o
obj-$(USE_PDUR) += PduR_SoAd.o
obj-$(USE_PDUR) += PduR_DoIP.o
obj-$(USE_PDUR) += PduR_Routing.o
obj-$(USE_PDUR) += PduR.o
obj-$(USE_PDUR) += PduR_FrIf.o
obj-$(USE_PDUR) += PduR_FrNm.o
obj-$(USE_PDUR) += PduR_FrTp.o
obj-$(USE_PDUR) += PduR_UdpNm.o
obj-$(USE_PDUR) += PduR_LdCom.o
obj-$(USE_PDUR) += PduR_SecOC.o
inc-$(USE_PDUR) += $(ROOTDIR)/communication/Com/inc
inc-$(USE_PDUR) += $(ROOTDIR)/communication/PduR/inc
vpath-$(USE_PDUR) += $(ROOTDIR)/communication/PduR/src
|
2301_81045437/classic-platform
|
communication/PduR/PduR.mod.mk
|
Makefile
|
unknown
| 978
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR292 */
/* @req PDUR0778 */
#ifndef PDUR_H
#define PDUR_H
#define PDUR_VENDOR_ID 60u
#define PDUR_AR_RELEASE_MAJOR_VERSION 4u
#define PDUR_AR_RELEASE_MINOR_VERSION 0u
#define PDUR_AR_RELEASE_REVISION_VERSION 3u
#define PDUR_MODULE_ID 51u
#define PDUR_AR_MAJOR_VERSION PDUR_AR_RELEASE_MAJOR_VERSION
#define PDUR_AR_MINOR_VERSION PDUR_AR_RELEASE_MINOR_VERSION
#define PDUR_AR_PATCH_VERSION PDUR_AR_RELEASE_REVISION_VERSION
#define PDUR_SW_MAJOR_VERSION 3u
#define PDUR_SW_MINOR_VERSION 0u
#define PDUR_SW_PATCH_VERSION 1u
// ERROR CODES
/* @req PDUR231 */
#define PDUR_E_CONFIG_PTR_INVALID 0x00u
#define PDUR_E_INVALID_REQUEST 0x01u
#define PDUR_E_PDU_ID_INVALID 0x02u
#define PDUR_E_TP_TX_REQ_REJECTED 0x03u
#define PDUR_E_PARAM_INVALID 0x04u
#define PDUR_E_DUPLICATE_IPDU_ID 0x06u
#define PDUR_E_IPDU_TOO_LONG 0x07u
#define PDUR_E_ROUTING_PATH_GROUP_ID_INVALID 0x08u
#define PDUR_E_NULL_POINTER 0x09u
#define PDUR_E_PDU_INSTANCES_LOST 0x0au
#define PDUR_E_INIT_FAILED 0x0bu
#define PDUR_E_DATA_PTR_INVALID PDUR_E_NULL_POINTER
#define PDUR_E_BUFFER_ERROR 0x0cu
#define PDUR_INSTANCE_ID 0u
#define PDUR_SERVICEID_CANIFRXINDICATION 0x00u
#define PDUR_SERVICEID_ENABLEROUTING 0xf3u
#define PDUR_SERVICEID_GETCONFIGURATIONID 0xf2u
#define PDUR_SERVICEID_DISABLEROUTING 0xf4u
#define PDUR_INVALID_CONFIGID 0xFFu
/* @req PDUR132 */
#include "PduR_Types.h"
#include "PduR_Cfg.h"
#include "PduR_If.h"
#if PDUR_COM_SUPPORT == STD_ON
#include "PduR_Com.h"
#endif
#if PDUR_CANIF_SUPPORT == STD_ON
#include "PduR_CanIf.h"
#endif
#if PDUR_CANNM_SUPPORT == STD_ON
#include "PduR_CanNm.h"
#endif
#if PDUR_UDPNM_SUPPORT == STD_ON
#include "PduR_UdpNm.h"
#endif
#if PDUR_LINIF_SUPPORT == STD_ON
#include "PduR_LinIf.h"
#endif
#if PDUR_CANTP_SUPPORT == STD_ON
#include "PduR_CanTp.h"
#endif
#if PDUR_J1939TP_SUPPORT == STD_ON
#include "PduR_J1939Tp.h"
#endif
#if PDUR_DCM_SUPPORT == STD_ON
#include "PduR_Dcm.h"
#endif
#if PDUR_SOAD_SUPPORT == STD_ON
#include "PduR_SoAd.h"
#endif
#if PDUR_DOIP_SUPPORT == STD_ON
#include "PduR_DoIP.h"
#endif
#if PDUR_J1939TP_SUPPORT == STD_ON
#include "PduR_J1939Tp.h"
#endif
#if PDUR_IPDUM_SUPPORT == STD_ON
#include "PduR_IpduM.h"
#endif
#if PDUR_FRIF_SUPPORT == STD_ON
#include "PduR_FrIf.h"
#endif
#if PDUR_FRTP_SUPPORT == STD_ON
#include "PduR_FrTp.h"
#endif
#if PDUR_FRNM_SUPPORT == STD_ON
#include "PduR_FrNm.h"
#endif
#if PDUR_LINTP_SUPPORT == STD_ON
#include "PduR_LinTp.h"
#endif
#if PDUR_CDD_LINSLV_SUPPORT == STD_ON
#include "PduR_CDD_LinSlvIf.h"
#endif
#if PDUR_SECOC_SUPPORT == STD_ON
#include "PduR_SecOC.h"
#endif
#if PDUR_CDD_PDUR_SUPPORT == STD_ON
#include "PduR_CddPduR.h"
#endif
#if PDUR_LDCOM_SUPPORT == STD_ON
#include "PduR_LdCom.h"
#endif
/* Contain the current state of the PDU router. The router is uninitialized
* until PduR_Init has been run.
*/
//PduR_StateType PduRState;
/*lint -e{9046} */
extern const PduR_PBConfigType *PduRConfig;
/*
* Allocated RAM buffers for PduR
*/
/*lint -e9003 PduR_RamBufCfg cannot be defined at block scope because it is used in multiple places */
extern const PduR_RamBufCfgType PduR_RamBufCfg;
/*
* The state of the PDU router.
*/
extern PduR_StateType PduRState;
#define PduR_IsUpModule(_mod) ((_mod > ARC_PDUR_UP_MODULES) && (_mod < ARC_PDUR_LOIF_MODULES))
#define PduR_IsIfModule(_mod) ((_mod > ARC_PDUR_LOIF_MODULES) && (_mod < ARC_PDUR_LOTP_MODULES))
#define PduR_IsTpModule(_mod) ((_mod > ARC_PDUR_LOTP_MODULES) && (_mod < ARC_PDUR_END_OF_MODULES))
#define PduR_IsLoModule(_mod) (PduR_IsIfModule(_mod) || PduR_IsTpModule(_mod))
/* @req PDUR101 */
/* @req PDUR331 */
#if (PDUR_DEV_ERROR_DETECT == STD_ON)
#define PDUR_DET_REPORTERROR(_x,_y,_z,_o) (void)Det_ReportError(_x,_y,_z,_o)
#define PDUR_VALIDATE_INITIALIZED(_api,...) \
if ((PduRState == PDUR_UNINIT) || (PduRState == PDUR_REDUCED)) { \
(void)Det_ReportError(PDUR_MODULE_ID, PDUR_INSTANCE_ID, _api, PDUR_E_INVALID_REQUEST); \
return __VA_ARGS__; \
}
#define PDUR_VALIDATE_PDUPTR(_api, _pduPtr, ...) \
if (_pduPtr == NULL) { \
(void)Det_ReportError(PDUR_MODULE_ID, PDUR_INSTANCE_ID, _api, PDUR_E_NULL_POINTER); \
return __VA_ARGS__; \
}
#define PDUR_VALIDATE_PDUID(_api, _pduId, ...) \
if (_pduId >= PduRConfig->NRoutingPaths) { \
(void)Det_ReportError(PDUR_MODULE_ID, PDUR_INSTANCE_ID, _api, PDUR_E_PDU_ID_INVALID); \
return __VA_ARGS__; \
}
#else
#define PDUR_DET_REPORTERROR(_x,_y,_z,_o)
#define PDUR_VALIDATE_INITIALIZED(_api,...) \
if ((PduRState == PDUR_UNINIT) || (PduRState == PDUR_REDUCED)) { \
return __VA_ARGS__; \
}
#define PDUR_VALIDATE_PDUPTR(_api, _pduPtr, ...) \
if (_pduPtr == NULL) { \
return __VA_ARGS__; \
}
#define PDUR_VALIDATE_PDUID(_api, _pduId, ...) \
if (_pduId >= PduRConfig->NRoutingPaths) { \
return __VA_ARGS__; \
}
#endif
/* Zero Cost Operation function definitions
* These macros replaces the original functions if zero cost
* operation is desired. */
#if PDUR_ZERO_COST_OPERATION == STD_ON
#define PduR_Init(...)
#define PduR_GetVersionInfo(...)
#define PduR_GetConfigurationId(...) 0
#else // Not zero cost operation
//#error fail
/* @req PDUR334 */
void PduR_Init(const PduR_PBConfigType* ConfigPtr);
#if PDUR_VERSION_INFO_API == STD_ON
/* @req PDUR234 */
void PduR_GetVersionInfo(Std_VersionInfoType* versionInfo);
#endif
PduR_PBConfigIdType PduR_GetConfigurationId(void);
void PduR_EnableRouting(PduR_RoutingPathGroupIdType id);
void PduR_DisableRouting(PduR_RoutingPathGroupIdType id);
#endif
#endif /* PDUR_H */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR.h
|
C
|
unknown
| 6,696
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef PDUR_CDD_LINSLVIF_H_
#define PDUR_CDD_LINSLVIF_H_
#include "PduR.h"
#if ((PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CDD_LINSLV_SUPPORT == STD_ON))
void PduR_LinSlvIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_LinSlvIfTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_LinSlvIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif /*PDUR_LINIF_H_*/
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_CDD_LinSlvIf.h
|
C
|
unknown
| 1,183
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_CANIF_H_
#define PDUR_CANIF_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CANIF_SUPPORT == STD_ON)
void PduR_CanIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_CanIfTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_CanIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif /* PDUR_CANIF_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_CanIf.h
|
C
|
unknown
| 1,175
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_CANNM_H
#define PDUR_CANNM_H
#include "ComStack_Types.h"
#if PDUR_ZERO_COST_OPERATION == STD_OFF
void PduR_CanNmRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_CanNmTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_CanNmTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_CanNm.h
|
C
|
unknown
| 1,120
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_CANTP_H_
#define PDUR_CANTP_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CANTP_SUPPORT == STD_ON)
BufReq_ReturnType PduR_CanTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr);
void PduR_CanTpRxIndication(PduIdType id, NotifResultType result);
BufReq_ReturnType PduR_CanTpStartOfReception(PduIdType id, PduLengthType TpSduLength, PduLengthType* bufferSizePtr);
BufReq_ReturnType PduR_CanTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
void PduR_CanTpTxConfirmation(PduIdType id, NotifResultType result);
#endif
#endif /* PDUR_CANTP_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_CanTp.h
|
C
|
unknown
| 1,459
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_CDD_PDUR_H_
#define PDUR_CDD_PDUR_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CDDPDUR_SUPPORT == STD_ON)
Std_ReturnType PduR_CddPduRTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr);
#endif
#endif /*PDUR_LINIF_H_*/
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_CddPduR.h
|
C
|
unknown
| 1,061
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_COM_H_
#define PDUR_COM_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_COM_SUPPORT == STD_ON)
Std_ReturnType PduR_ComTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr);
Std_ReturnType PduR_ComCancelTransmit(PduIdType pduId);
void PduR_ComChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value);
Std_ReturnType PduR_ComCancelReceive(PduIdType pduId);
#endif
#endif /* PDUR_COM_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_Com.h
|
C
|
unknown
| 1,245
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_DCM_H_
#define PDUR_DCM_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_DCM_SUPPORT == STD_ON)
Std_ReturnType PduR_DcmTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr);
Std_ReturnType PduR_DcmCancelTransmit(PduIdType pduId);
void PduR_DcmChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value);
Std_ReturnType PduR_DcmCancelReceive(PduIdType pduId);
#endif
#endif /*PDUR_DCM_H_*/
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_Dcm.h
|
C
|
unknown
| 1,249
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_DOIP_H_
#define PDUR_DOIP_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_DOIP_SUPPORT == STD_ON)
/* DoIP acts as interface module */
void PduR_DoIPIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_DoIPIfTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_DoIPIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
/* DoIP acts as transport protocol module */
BufReq_ReturnType PduR_DoIPTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr);
void PduR_DoIPTpRxIndication(PduIdType id, NotifResultType result);
BufReq_ReturnType PduR_DoIPTpStartOfReception(PduIdType id, const PduInfoType* info,PduLengthType TpSduLength, PduLengthType* bufferSizePtr);
BufReq_ReturnType PduR_DoIPTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
void PduR_DoIPTpTxConfirmation(PduIdType id, NotifResultType result);
#endif
#endif /* PDUR_DOIP_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_DoIP.h
|
C
|
unknown
| 1,778
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_FRIF_H_
#define PDUR_FRIF_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_FRIF_SUPPORT == STD_ON)
void PduR_FrIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_FrIfTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_FrIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif /* PDUR_FRIF_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_FrIf.h
|
C
|
unknown
| 1,168
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef PDUR_FRNM_H
#define PDUR_FRNM_H
#include "ComStack_Types.h"
#if PDUR_ZERO_COST_OPERATION == STD_OFF
void PduR_FrNmRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_FrNmTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_FrNmTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_FrNm.h
|
C
|
unknown
| 1,095
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_FRTP_H_
#define PDUR_FRTP_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_FRTP_SUPPORT == STD_ON)
BufReq_ReturnType PduR_FrTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr);
void PduR_FrTpRxIndication(PduIdType id, NotifResultType result);
BufReq_ReturnType PduR_FrTpStartOfReception(PduIdType id, PduLengthType TpSduLength, PduLengthType* bufferSizePtr);
BufReq_ReturnType PduR_FrTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
void PduR_FrTpTxConfirmation(PduIdType id, NotifResultType result);
#endif
#endif /* PDUR_FRTP_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_FrTp.h
|
C
|
unknown
| 1,448
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef PDUR_IF_H_
#define PDUR_IF_H_
#include "PduR.h"
#if defined(USE_DET)
#include "Det.h"
#endif
#if PDUR_ZERO_COST_OPERATION == STD_OFF
typedef enum {
PDUR_E_REJECTED,
PDUR_E_DISABLED,
PDUR_E_OK
}PduRRouteStatusType;
// PduR Interface used by Upper modules
Std_ReturnType PduR_UpTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr, uint8 serviceId);
Std_ReturnType PduR_UpCancelTransmit(PduIdType pduId, uint8 serviceId);
void PduR_UpChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value, uint8 serviceId);
Std_ReturnType PduR_UpCancelReceive(PduIdType pduId, uint8 serviceId);
// PduR Interface used by Lower If modules
void PduR_LoIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr, uint8 serviceId);
void PduR_LoIfTxConfirmation(PduIdType pduId, uint8 serviceId);
Std_ReturnType PduR_LoIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr, uint8 serviceId);
// PduR Interface used by Lower Tp modules
BufReq_ReturnType PduR_LoTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr, uint8 serviceId);
void PduR_LoTpRxIndication(PduIdType id, NotifResultType result, uint8 serviceId);
BufReq_ReturnType PduR_LoTpStartOfReception(PduIdType id, PduLengthType TpSduLength, PduLengthType* bufferSizePtr, uint8 serviceId);
BufReq_ReturnType PduR_LoTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr, uint8 serviceId);
void PduR_LoTpTxConfirmation(PduIdType id, NotifResultType result, uint8 serviceId);
// ARC internal route API
PduRRouteStatusType PduR_ARC_RouteTransmit(const PduRDestPdu_type * destination, const PduInfoType * pduInfo);
void PduR_ARC_RouteRxIndication(const PduRDestPdu_type * destination, const PduInfoType *PduInfo);
void PduR_ARC_RouteTxConfirmation(const PduRRoutingPath_type *route, uint8 result);
Std_ReturnType PduR_ARC_RouteTriggerTransmit(const PduRRoutingPath_type *route, PduInfoType * pduInfo);
BufReq_ReturnType PduR_ARC_RouteCopyRxData(const PduRDestPdu_type * destination, PduInfoType* info, PduLengthType* bufferSizePtr);
BufReq_ReturnType PduR_ARC_RouteCopyTxData(const PduRRoutingPath_type *route, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr);
BufReq_ReturnType PduR_ARC_RouteStartOfReception(const PduRDestPdu_type * destination, PduLengthType TpSduLength, PduLengthType* bufferSizePtr);
void PduR_ARC_RouteTpTxConfirmation(const PduRRoutingPath_type *route, Std_ReturnType result);
void PduR_ARC_RouteTpRxIndication(const PduRDestPdu_type * destination, Std_ReturnType result );
// ARC internal TP API
void PduR_ARC_TpTxConfirmation(PduIdType PduId, uint8 result, uint8 serviceId);
Std_ReturnType PduR_ARC_Transmit(PduIdType PduId, const PduInfoType* PduInfo, uint8 serviceId);
void PduR_ARC_TpRxIndication(PduIdType PduId, NotifResultType Result, uint8 serviceId);
void PduR_ARC_RxIndication(PduIdType PduId, const PduInfoType* PduInfo, uint8 serviceId);
void PduR_ARC_TxConfirmation(PduIdType PduId, uint8 result, uint8 serviceId);
Std_ReturnType PduR_ARC_TriggerTransmit(PduIdType PduId, PduInfoType* PduInfo, uint8 serviceId);
/* Internal function for checking if routing path for destination is enabled */
boolean PduRRoutingPathEnabled(const PduRDestPdu_type * destination);
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
/* Internal function for enabling/disabling a routing path group */
void PdurSetRoutingPathEnabled(PduR_RoutingPathGroupIdType id, boolean enabled);
#endif
#endif
#endif /* PDUR_IF_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_If.h
|
C
|
unknown
| 4,347
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_IPDUM_H_
#define PDUR_IPDUM_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_IPDUM_SUPPORT == STD_ON)
Std_ReturnType PduR_IpduMTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr);
Std_ReturnType PduR_IpduMCancelTransmit(PduIdType pduId);
void PduR_IpduMChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value);
Std_ReturnType PduR_IpduMCancelReceive(PduIdType pduId);
void PduR_IpduMRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_IpduMTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_IpduMTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif /* PDUR_COM_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_IpduM.h
|
C
|
unknown
| 1,465
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_J1939TP_H_
#define PDUR_J1939TP_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_J1939TP_SUPPORT == STD_ON)
BufReq_ReturnType PduR_J1939TpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr);
void PduR_J1939TpRxIndication(PduIdType id, NotifResultType result);
/* See item SWS_PduR_00507 in version 4.1 of PduR */
BufReq_ReturnType PduR_J1939TpStartOfReception
(
PduIdType id,
PduInfoType* info, // new in v4.1 of PduR
PduLengthType TpSduLength,
PduLengthType* bufferSizePtr
);
BufReq_ReturnType PduR_J1939TpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
void PduR_J1939TpTxConfirmation(PduIdType id, NotifResultType result);
#endif
#endif /* PDUR_CANTP_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_J1939Tp.h
|
C
|
unknown
| 1,634
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef PDUR_LDCOM_H_
#define PDUR_LDCOM_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_LDCOM_SUPPORT == STD_ON)
Std_ReturnType PduR_LdComTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr);
#endif
#endif /* PDUR_CANTP_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_LdCom.h
|
C
|
unknown
| 1,020
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_LINIF_H_
#define PDUR_LINIF_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_LINIF_SUPPORT == STD_ON)
void PduR_LinIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_LinIfTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_LinIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif /*PDUR_LINIF_H_*/
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_LinIf.h
|
C
|
unknown
| 1,173
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.1.2 */
/** @tagSettings DEFAULT_ARCHITECTURE=GENERIC */
#ifndef PDUR_SECOC_H_
#define PDUR_SECOC_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_SECOC_SUPPORT == STD_ON)
void PduR_SecOCRxIndication(PduIdType pduId, const PduInfoType* pduInfoPtr);
void PduR_SecOCTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_SecOCTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr);
Std_ReturnType PduR_SecOCCancelTransmit(PduIdType pduId);
#endif
#endif /* PDUR_SECOC_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_SecOC.h
|
C
|
unknown
| 1,323
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_SOAD_H_
#define PDUR_SOAD_H_
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_SOAD_SUPPORT == STD_ON)
/* SoAd acts as interface module */
void PduR_SoAdIfRxIndication(PduIdType pduId, const PduInfoType* pduInfoPtr);
void PduR_SoAdIfTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_SoAdIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
/* SoAd acts as transport protocol module */
BufReq_ReturnType PduR_SoAdTpCopyRxData(PduIdType id, const PduInfoType* info, PduLengthType* bufferSizePtr);
void PduR_SoAdTpRxIndication(PduIdType id, NotifResultType result);
BufReq_ReturnType PduR_SoAdTpStartOfReception(PduIdType id, const PduInfoType* info,PduLengthType TpSduLength, PduLengthType* bufferSizePtr);
BufReq_ReturnType PduR_SoAdTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr );
void PduR_SoAdTpTxConfirmation(PduIdType id, NotifResultType result);
#endif
#endif /* PDUR_SOAD_H_ */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_SoAd.h
|
C
|
unknown
| 1,790
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @addtogroup PduR PDU Router
* @{ */
/** @file PduR_Types.h
* Type definitions for PDU Router.
*/
#ifndef PDUR_TYPES_H
#define PDUR_TYPES_H
#include "ComStack_Types.h"
/* @req PDUR293 */
typedef enum {
ARC_PDUR_UP_MODULES = 0,
ARC_PDUR_COM,
ARC_PDUR_DCM,
ARC_PDUR_IPDUM,
ARC_PDUR_SECOC,
ARC_PDUR_CDDPDUR,
ARC_PDUR_LDCOM,
ARC_PDUR_LOIF_MODULES,
ARC_PDUR_CANIF,
ARC_PDUR_CANNM,
ARC_PDUR_LINIF,
ARC_PDUR_SOADIF,
ARC_PDUR_DOIPIF,
ARC_PDUR_UDPNM,
ARC_PDUR_FRIF,
ARC_PDUR_FRNM,
ARC_PDUR_CDD_LINSLVIF,
ARC_PDUR_LOTP_MODULES,
ARC_PDUR_CANTP,
ARC_PDUR_LINTP,
ARC_PDUR_SOADTP,
ARC_PDUR_DOIPTP,
ARC_PDUR_SOAD,
ARC_PDUR_DOIP,
ARC_PDUR_J1939TP,
ARC_PDUR_FRTP,
ARC_PDUR_END_OF_MODULES
} ARC_PduR_ModuleType;
/* @req PDUR654 */
/* Identification of a Routing Table */
typedef uint16 PduR_RoutingPathGroupIdType;
/** PduR_StateType defines the states of which the PDU router can be in */
/* @req PDUR742 */
/* @req PDUR324 */
typedef enum {
PDUR_UNINIT, /**< PDU Router is not initialized. */
PDUR_ONLINE, /**< PDU Router initialized successfully. */
PDUR_REDUCED /**< PDU Router initialization did not succeed. Only minimum routing is provided. */
} PduR_StateType;
typedef enum {
PDU_CNLDO, /**< Cancel transfer since data is outdated. */
PDU_CNLNB, /**< Cancel transfer since buffer is full. */
PDU_CNLOR /**< Cancel transfer of another reason. */
} PduR_CancelReasonType;
typedef uint8 PduR_ParameterValueType;
typedef enum {
PDUR_NO_PROVISION, /**< No data provision. */
PDUR_TRIGGER_TRANSMIT, /**< Trigger transmit type. */
PDUR_DIRECT /**< Data provision type. */
} PduR_DataProvisionType;
/*
typedef struct {
uint16 BufferId;
PduR_DataProvisionType BufferType;
//uint8 SduLength;
uint8 *Last;
uint8 *First;
uint8 NrItems;
uint8 TxConfP;
// uint8 TxIdx; // This is the same as First, hence left out.
uint8 *Buffer;
uint8 Depth;
uint8 Length;
} PduRTxBuffer_type;
*/
typedef struct {
uint32 BufSize;
uint8 *DataPtr;
}PduRTxBuffer_type;
typedef enum {
PDUR_BUFFER_FREE = 0,
PDUR_BUFFER_RX_READY,
PDUR_BUFFER_RX_BUSY,
PDUR_BUFFER_TX_READY,
PDUR_BUFFER_TX_BUSY,
PDUR_BUFFER_NOT_ALLOCATED_FROM_UP_MODULE,
PDUR_BUFFER_ALLOCATED_FROM_UP_MODULE
} PduRTpBufferStatus_type;
#define PDUR_MAX_GW_DESTINATIONS 8u
typedef struct {
PduInfoType *pduInfoPtr;
PduRTpBufferStatus_type status;
uint16 bufferSize;
PduLengthType rxByteCount;
PduLengthType txByteCount[PDUR_MAX_GW_DESTINATIONS];
uint8 nAcc;
} PduRTpBufferInfo_type;
typedef struct {
/**
* Data provision mode for this PDU.
*/
const PduR_DataProvisionType DataProvision;
/**
* Reference to unique PDU identifier which shall
* be used by the PDU router instead of the source identifier.
*/
const uint16 DestPduId;
/**
* Id of the assigned Tx buffer.
*
* Comment: Only required for non-TP gateway PDUs.
*/
const uint16 TxBufferId;
const ARC_PduR_ModuleType DestModule;
const PduR_RoutingPathGroupIdType NofGroupRefs;
const PduR_RoutingPathGroupIdType *RoutingPathGroupRefs;
} PduRDestPdu_type;
typedef struct {
uint8 ElementBytePosition;
uint8 DefaultValueElement[];
} PduRDefaultValueElement_type;
typedef struct {
uint8 PduR_Arc_Dummy; // Needed in order to compile without errors.
PduRDefaultValueElement_type *PduRDefaultValueElement;
} PduRDefaultValue_type;
typedef struct {
/**
* PduRTpThreshold for routing on the fly.
*
* Comment: Only required for TP gateway PDUs.
*/
uint16 PduRTpThreshld;
/**
* Specifies the default value of the PDU.
*
* Comment: Only require for gateway operation.
*/
PduRDefaultValue_type PduRDefaultValue;
/**
* Specifies the source ID of the PDU to be routed.
*/
const uint16 SrcPduId;
/**
* Specifies the source module for this route.
*/
const ARC_PduR_ModuleType SrcModule;
/**
* Specifies the destination(s) of the PDU to be routed.
*/
const PduRDestPdu_type * const *PduRDestPdus;
/* Number of destinations */
uint8 PduRDestinatnNum;
/* Indicates whether gateway on fly or Direct gateway */
boolean PduRDirectGateway;
} PduRRoutingPath_type;
/* @req PDUR0771 */
typedef uint8 PduR_PBConfigIdType;
typedef struct {
const PduRDestPdu_type * const *Destinations;
uint32 NofDestinations;
boolean EnabledAtInit;
}PduR_RoutingPathGroupType;
/* @req PDUR743 */
/* @req PDUR241 */
typedef struct {
/**
* The routing table of this PDU router configuration.
*/
const PduRRoutingPath_type * const*RoutingPaths;
/**
* The nubmer of routing paths in the routing table.
*/
PduIdType NRoutingPaths;
/**
* Unique configuration identifier.
*/
PduR_PBConfigIdType PduRConfigurationId;
/**
* List of default value byte arrays.
*/
const uint8 * const * const DefaultValues;
/**
* List of default value byte array lengths.
*/
const uint32 * const * const DefaultValueLengths;
PduR_RoutingPathGroupIdType NofRoutingPathGroups;
const PduR_RoutingPathGroupType *RoutingPathGroups;
} PduR_PBConfigType;
typedef struct {
PduRTpBufferInfo_type *TpBuffers;
PduRTpBufferInfo_type **TpRouteBuffers;
const PduRTxBuffer_type * TxBuffers;
uint8 NTpBuffers;
uint16 NTpRouteBuffers;
uint16 NTxBuffers;
} PduR_RamBufCfgType;
#endif
/** @} */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_Types.h
|
C
|
unknown
| 6,654
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* @req PDUR216 */
#ifndef PDUR_UDPNM_H
#define PDUR_UDPNM_H
#include "ComStack_Types.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF)
void PduR_UdpNmRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr);
void PduR_UdpNmTxConfirmation(PduIdType pduId);
Std_ReturnType PduR_UdpNmTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr);
#endif
#endif /* PDUR_UDPNM_H */
|
2301_81045437/classic-platform
|
communication/PduR/inc/PduR_UdpNm.h
|
C
|
unknown
| 1,137
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/* Generally implemented requirements */
/* @req PDUR221 *//* Check of PDU id */
/* @req PDUR328 *//* Shall perform routing when ONLINE. See PDUR_VALIDATE_INITIALIZED */
/* @req PDUR330 *//* No routing when uninitialized. Satisfied by PDUR_VALIDATE_INITIALIZED */
/* @req PDUR332 *//* If error detected (when DevErroDetect is enabled), report to Det and return error */
/* @req PDUR0780 *//* Generic service ids for upper layer modules */
/* @req PDUR0781 *//* Generic service ids for lower layer interface modules */
/* @req PDUR0782 *//* Generic service ids for lower layer transport protocol modules */
/*#include <stdlib.h>*/
#include <string.h>
#include "PduR.h"
#if (PDUR_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
/* @req PDUR232 */
#if defined(USE_DEM)
#include "Dem.h"
#endif
#include "debug.h"
#if !(((PDUR_SW_MAJOR_VERSION == 3) && (PDUR_SW_MINOR_VERSION == 0)) )
#error PduR: Expected BSW module version to be 3.0.*
#endif
#if !(((PDUR_AR_RELEASE_MAJOR_VERSION == 4) && (PDUR_AR_RELEASE_MINOR_VERSION == 0)) )
#error PduR: Expected AUTOSAR version to be 4.0.*
#endif
/*
* The state of the PDU router.
*/
/* @req PDUR644 */
/* @req PDUR325 */
PduR_StateType PduRState = PDUR_UNINIT;
#if PDUR_ZERO_COST_OPERATION == STD_OFF
const PduR_PBConfigType * PduRConfig;
/*
* Initializes the PDU Router.
*/
void PduR_Init (const PduR_PBConfigType* ConfigPtr) {
uint32 i;
/* !req PDUR106 */
// Make sure the PDU Router is uninitialized.
// Otherwise raise an error.
if (PduRState != PDUR_UNINIT) {
// Raise error and return.
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, 0x00, PDUR_E_INVALID_REQUEST);
}else if (ConfigPtr == NULL) {/* @req PDUR0776 */
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, 0x00, PDUR_E_NULL_POINTER);
} else {
PduRConfig = ConfigPtr;
// Start initialization!
DEBUG(DEBUG_LOW,"--Initialization of PDU router--\n");
// Initialize buffers
/* @req PDUR308 */
if((PduRConfig->DefaultValues != NULL) && (PduRConfig->DefaultValueLengths != NULL)) {
for (i = 0u; i < PduR_RamBufCfg.NTxBuffers; i++) {
if (*PduRConfig->DefaultValueLengths[i] > 0u) {
memcpy(PduR_RamBufCfg.TxBuffers[i].DataPtr, PduRConfig->DefaultValues[i], *PduRConfig->DefaultValueLengths[i]);
}
}
}
for (i=0; i < PduR_RamBufCfg.NTpBuffers; i++) {
PduR_RamBufCfg.TpBuffers[i].status= PDUR_BUFFER_FREE; //Reset Tp buffer status
}
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
/* Init routing path groups */
/* @req PDUR0709 */
for( i = 0; i < PduRConfig->NofRoutingPathGroups; i++ ) {
PdurSetRoutingPathEnabled((PduR_RoutingPathGroupIdType)i, PduRConfig->RoutingPathGroups[i].EnabledAtInit);
}
#endif
/* @req PDUR326 */
PduRState = PDUR_ONLINE;
DEBUG(DEBUG_LOW,"--Initialization of PDU router completed --\n");
}
}
#if PDUR_VERSION_INFO_API == STD_ON
/* @req PDUR217 */
/* @req PDUR338 */
void PduR_GetVersionInfo (Std_VersionInfoType* versionInfo){
versionInfo->moduleID = (uint16)PDUR_MODULE_ID;
versionInfo->vendorID = 60u;
versionInfo->sw_major_version = PDUR_SW_MAJOR_VERSION;
versionInfo->sw_minor_version = PDUR_SW_MINOR_VERSION;
versionInfo->sw_patch_version = PDUR_SW_PATCH_VERSION;
}
#endif
/* @req PDUR341 Change return type */
PduR_PBConfigIdType PduR_GetConfigurationId (void) {
/* @req PDUR119 */
/* @req PDUR280 */
if( PDUR_UNINIT == PduRState ) {
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, PDUR_SERVICEID_GETCONFIGURATIONID, PDUR_E_INVALID_REQUEST);
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return PDUR_INVALID_CONFIGID;
}
return PduRConfig->PduRConfigurationId;
}
/* @req PDUR615 */
void PduR_EnableRouting(PduR_RoutingPathGroupIdType id) {
/* @req PDUR119 */
if( PDUR_UNINIT == PduRState ) {
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, PDUR_SERVICEID_ENABLEROUTING, PDUR_E_INVALID_REQUEST);
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return;
}
if( id < PduRConfig->NofRoutingPathGroups ) {
/* @req PDUR715 */
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
PdurSetRoutingPathEnabled(id, TRUE);
#endif
} else {
/* @req PDUR647 */
/* @req PDUR648 */
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, PDUR_SERVICEID_ENABLEROUTING, PDUR_E_ROUTING_PATH_GROUP_ID_INVALID);
}
}
/* @req PDUR617 */
void PduR_DisableRouting(PduR_RoutingPathGroupIdType id) {
/* @req PDUR119 */
/* !req PDUR646 *//* Only transmit request disabled. */
if( PDUR_UNINIT == PduRState ) {
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, PDUR_SERVICEID_DISABLEROUTING, PDUR_E_INVALID_REQUEST);
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return;
}
if(id < PduRConfig->NofRoutingPathGroups) {
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
PdurSetRoutingPathEnabled(id, FALSE);
/* Clear all buffers */
const PduR_RoutingPathGroupType *groupPtr = &PduRConfig->RoutingPathGroups[id];
const PduRDestPdu_type *destPtr;
for( uint32 i = 0; i < groupPtr->NofDestinations; i++ ) {
destPtr = groupPtr->Destinations[i];
/* !req PDUR663 *//* TP buffers not cleared */
if( (PDUR_TRIGGER_TRANSMIT == destPtr->DataProvision) && (PDUR_NO_BUFFER != destPtr->TxBufferId) ) {
memset(PduR_RamBufCfg.TxBuffers[destPtr->TxBufferId].DataPtr, 0, PduR_RamBufCfg.TxBuffers[destPtr->TxBufferId].BufSize);
}
}
#endif
} else {
/* @req PDUR716 */
/* @req PDUR649 */
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, PDUR_SERVICEID_DISABLEROUTING, PDUR_E_ROUTING_PATH_GROUP_ID_INVALID);
}
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR.c
|
C
|
unknown
| 6,992
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CDD_LINSLV_SUPPORT == STD_ON)
// Autosar4 API
void PduR_LinSlvIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x71);
}
void PduR_LinSlvIfTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x72);
}
Std_ReturnType PduR_LinSlvIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x73);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_CDD_LinSlvIf.c
|
C
|
unknown
| 1,310
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CANIF_SUPPORT == STD_ON)
// Autosar4 API
void PduR_CanIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x01);
}
void PduR_CanIfTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x02);
}
Std_ReturnType PduR_CanIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x03);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_CanIf.c
|
C
|
unknown
| 1,292
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#include "PduR_CanNm.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF)
// Autosar4 API
void PduR_CanNmRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x11);
}
void PduR_CanNmTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x12);
}
Std_ReturnType PduR_CanNmTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x13);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_CanNm.c
|
C
|
unknown
| 1,251
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CANTP_SUPPORT == STD_ON)
// Autosar4 API
BufReq_ReturnType PduR_CanTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr) {
return PduR_LoTpCopyRxData(id, info, bufferSizePtr, 0x04);
}
void PduR_CanTpRxIndication(PduIdType id, NotifResultType result) {
PduR_LoTpRxIndication(id, result, 0x05);
}
BufReq_ReturnType PduR_CanTpStartOfReception(PduIdType id, PduLengthType TpSduLength, PduLengthType* bufferSizePtr) {
return PduR_LoTpStartOfReception(id, TpSduLength, bufferSizePtr, 0x06);
}
BufReq_ReturnType PduR_CanTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr ) {
return PduR_LoTpCopyTxData(id, info, retry, availableDataPtr, 0x07);
}
void PduR_CanTpTxConfirmation(PduIdType id, NotifResultType result) {
PduR_LoTpTxConfirmation(id, result, 0x08);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_CanTp.c
|
C
|
unknown
| 1,738
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_CDDPDUR_SUPPORT == STD_ON)
// Autosar4 API
Std_ReturnType PduR_CddPduRTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr) {
return PduR_UpTransmit(pduId, pduInfoPtr, 0x89);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_CddPduR.c
|
C
|
unknown
| 1,057
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_COM_SUPPORT == STD_ON)
// Autosar4 API
Std_ReturnType PduR_ComTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr) {
return PduR_UpTransmit(pduId, pduInfoPtr, 0x89);
}
Std_ReturnType PduR_ComCancelTransmit(PduIdType pduId) {
return PduR_UpCancelTransmit(pduId, 0x8a);
}
void PduR_ComChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value) {
PduR_UpChangeParameter(pduId, parameter, value, 0x8b);
}
Std_ReturnType PduR_ComCancelReceive(PduIdType pduId) {
return PduR_UpCancelReceive(pduId, 0x8c);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_Com.c
|
C
|
unknown
| 1,426
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_DCM_SUPPORT == STD_ON)
Std_ReturnType PduR_DcmTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr) {
return PduR_UpTransmit(pduId, pduInfoPtr, 0x99);
}
Std_ReturnType PduR_DcmCancelTransmit(PduIdType pduId) {
return PduR_UpCancelTransmit(pduId, 0x9a);
}
void PduR_DcmChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value) {
PduR_UpChangeParameter(pduId, parameter, value, 0x9b);
}
Std_ReturnType PduR_DcmCancelReceive(PduIdType pduId) {
return PduR_UpCancelReceive(pduId, 0x9c);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_Dcm.c
|
C
|
unknown
| 1,403
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#if (PDUR_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
#include "debug.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_DOIP_SUPPORT == STD_ON)
// Autosar4 API
void PduR_DoIPIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x42);
}
void PduR_DoIPIfTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x40);
}
BufReq_ReturnType PduR_DoIPTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr) {
return PduR_LoTpCopyRxData(id, info, bufferSizePtr, 0x44);
}
void PduR_DoIPTpRxIndication(PduIdType id, NotifResultType result) {
PduR_LoTpRxIndication(id, result, 0x45);
}
BufReq_ReturnType PduR_DoIPTpStartOfReception(PduIdType id, const PduInfoType* info, PduLengthType TpSduLength, PduLengthType* bufferSizePtr) {
return PduR_LoTpStartOfReception(id, TpSduLength, bufferSizePtr, 0x46);
(void)info;
}
BufReq_ReturnType PduR_DoIPTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr ) {
return PduR_LoTpCopyTxData(id, info, retry, availableDataPtr, 0x43);
}
void PduR_DoIPTpTxConfirmation(PduIdType id, NotifResultType result) {
PduR_ARC_TpTxConfirmation(id, result, 0x48);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_DoIP.c
|
C
|
unknown
| 2,104
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_FRIF_SUPPORT == STD_ON)
// Autosar4 API
void PduR_FrIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x31);
}
void PduR_FrIfTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x32);
}
Std_ReturnType PduR_FrIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x33);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_FrIf.c
|
C
|
unknown
| 1,288
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#include "PduR_FrNm.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF)
// Autosar4 API
/* Need to Modify Service IDs in this function*/
void PduR_FrNmRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x41);
}
void PduR_FrNmTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x42);
}
Std_ReturnType PduR_FrNmTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x43);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_FrNm.c
|
C
|
unknown
| 1,297
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_FRTP_SUPPORT == STD_ON)
// Autosar4 API
BufReq_ReturnType PduR_FrTpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr) {
return PduR_LoTpCopyRxData(id, info, bufferSizePtr, 0x34);
}
void PduR_FrTpRxIndication(PduIdType id, NotifResultType result) {
PduR_LoTpRxIndication(id, result, 0x35);
}
BufReq_ReturnType PduR_FrTpStartOfReception(PduIdType id, PduLengthType TpSduLength, PduLengthType* bufferSizePtr) {
return PduR_LoTpStartOfReception(id, TpSduLength, bufferSizePtr, 0x36);
}
BufReq_ReturnType PduR_FrTpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr ) {
return PduR_LoTpCopyTxData(id, info, retry, availableDataPtr, 0x37);
}
void PduR_FrTpTxConfirmation(PduIdType id, NotifResultType result) {
PduR_LoTpTxConfirmation(id, result, 0x38);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_FrTp.c
|
C
|
unknown
| 1,734
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_IPDUM_SUPPORT == STD_ON)
// Autosar4 API
Std_ReturnType PduR_IpduMTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr) {
return PduR_UpTransmit(pduId, pduInfoPtr, 0xa9);
}
Std_ReturnType PduR_IpduMCancelTransmit(PduIdType pduId) {
return PduR_UpCancelTransmit(pduId, 0xaa);
}
void PduR_IpduMChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value) {
PduR_UpChangeParameter(pduId, parameter, value, 0xab);
}
Std_ReturnType PduR_IpduMCancelReceive(PduIdType pduId) {
return PduR_UpCancelReceive(pduId, 0xac);
}
void PduR_IpduMRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x21);
}
void PduR_IpduMTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x22);
}
Std_ReturnType PduR_IpduMTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x23);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_IpduM.c
|
C
|
unknown
| 1,819
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#if (PDUR_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
#if defined(USE_COM)
#include "Com.h"
#endif
#include "debug.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_J1939TP_SUPPORT == STD_ON)
// Autosar4 API
BufReq_ReturnType PduR_J1939TpCopyRxData(PduIdType id, PduInfoType* info, PduLengthType* bufferSizePtr) {
return PduR_LoTpCopyRxData(id, info, bufferSizePtr, 0x14);
}
void PduR_J1939TpRxIndication(PduIdType id, NotifResultType result) {
PduR_LoTpRxIndication(id, result, 0x15);
}
BufReq_ReturnType PduR_J1939TpStartOfReception(PduIdType id, PduInfoType* info, PduLengthType TpSduLength, PduLengthType* bufferSizePtr) {
(void) *info; /* new in v4.1 of PduR*/
return PduR_LoTpStartOfReception(id, TpSduLength, bufferSizePtr, 0x16);
/*lint -e818 used till v4.1 of PduR implemenation */
}
BufReq_ReturnType PduR_J1939TpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr ) {
return PduR_LoTpCopyTxData(id, info, retry, availableDataPtr, 0x17);
}
void PduR_J1939TpTxConfirmation(PduIdType id, NotifResultType result) {
PduR_ARC_TpTxConfirmation(id, result, 0x18);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_J1939Tp.c
|
C
|
unknown
| 2,006
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_LDCOM_SUPPORT == STD_ON)
// Autosar4 API
Std_ReturnType PduR_LdComTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr) {
return PduR_UpTransmit(pduId, pduInfoPtr, 0x89);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_LdCom.c
|
C
|
unknown
| 1,021
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
/* @req PDUR0764 */
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_LINIF_SUPPORT == STD_ON)
// Autosar4 API
void PduR_LinIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr) {
PduR_LoIfRxIndication(pduId, pduInfoPtr, 0x51);
}
void PduR_LinIfTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x52);
}
Std_ReturnType PduR_LinIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr) {
return PduR_LoIfTriggerTransmit(pduId, pduInfoPtr, 0x53);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_LinIf.c
|
C
|
unknown
| 1,296
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
//lint -emacro(904,PDUR_VALIDATE_INITIALIZED,PDUR_VALIDATE_PDUPTR,PDUR_VALIDATE_PDUID) //904 PC-Lint exception to MISRA 14.7 (validate macros).
//lint -emacro(506,PDUR_VALIDATE_PDUPTR,PDUR_VALIDATE_PDUID) //PC-Lint exception Misra 13.7, 14.1 Allow configuration variables in boolean expression.
//lint -emacro(774,PDUR_VALIDATE_PDUPTR,PDUR_VALIDATE_PDUID) //PC-Lint exception Misra 13.7, 14.1 Allow configuration variables in boolean expression.
/* Only static routing, hard to tag at a specific line.
* @req PDUR162 */
#include "PduR.h"
#include <string.h>
#include "debug.h"
#include "SchM_PduR.h"
#if (PDUR_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
#if defined(USE_DEM)
#include "Dem.h"
#endif
#if PDUR_LDCOM_SUPPORT == STD_ON
#include "LdCom.h"
#endif
#if PDUR_ZERO_COST_OPERATION == STD_OFF
#define PduRTpBuffer(_id) (&PduR_RamBufCfg.TpBuffers[_id])
#define PduRTpRouteBuffer(_id) (PduR_RamBufCfg.TpRouteBuffers[_id])
#define HAS_BUFFER_STATUS(_pduId, _status) ((_pduId < PduR_RamBufCfg.NTpRouteBuffers) && (PduRTpRouteBuffer(_pduId) != NULL) && (PduRTpRouteBuffer(_pduId)->status == _status))
#define REPORT_BUFFER_ERROR(_serviceId) PDUR_DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, _serviceId, PDUR_E_BUFFER_ERROR);
#define PDU_MAX_ROUTING_PATH 8192 /* Out of 16 bits of PduId we use 13 for representing a PDUR_PDU_ID_XXX. Only if a path contains
a gateway to multiple Tp destinations then the upper 3 bits are used for representing the GW destination index */
#define PDUR_PDU_ID_MASK 8191 // Mask for extraction of lower 13 bits
// Static function prototypes
static boolean PduR_ARC_HasTpModuleDest(const PduRDestPdu_type * const *destPdus);
static const PduRDestPdu_type * PduR_ARC_FindUPDest(const PduRDestPdu_type * const *destPdus);
static BufReq_ReturnType PduR_ARC_AllocateBuffer(PduIdType PduId, PduLengthType TpSduLength);
static BufReq_ReturnType PduR_ARC_CheckBufferStatus(PduIdType PduId, uint16 length);
static BufReq_ReturnType PduR_ARC_ReleaseRxBuffer(PduIdType PduId);
static BufReq_ReturnType PduR_ARC_ReleaseTxBuffer(PduIdType PduId);
static void PduR_ARC_RxIndicationDirect(const PduRDestPdu_type * destination, const PduInfoType *PduInfo);
static void PduR_ARC_RxIndicationTT(const PduRDestPdu_type * destination, const PduInfoType *PduInfo);
static inline void calculateMinBufferSize(PduLengthType *minBufSize, const PduLengthType *avblBufSize);
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
static boolean PdurRoutingGroupEnabled[PDUR_MAX_NOF_ROUTING_PATH_GROUPS];
#endif
static BufReq_ReturnType PduR_ARC_AllocateBuffer(PduIdType PduId, PduLengthType TpSduLength) {
BufReq_ReturnType retVal;
SchM_Enter_PduR_EA_0();//Disable interrupts
retVal = BUFREQ_BUSY;
for (uint8 i = 0; i < PduR_RamBufCfg.NTpBuffers; i++) {
if (PduRTpBuffer(i)->status == PDUR_BUFFER_FREE) {
if (PduRTpBuffer(i)->bufferSize < TpSduLength) {
retVal = BUFREQ_OVFL;
} else {
PduRTpRouteBuffer(PduId) = PduRTpBuffer(i);
PduRTpBuffer(i)->pduInfoPtr->SduLength = TpSduLength;
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_RX_READY;
memset(PduRTpRouteBuffer(PduId)->txByteCount,0, sizeof(PduLengthType)*PDUR_MAX_GW_DESTINATIONS);
PduRTpRouteBuffer(PduId)->rxByteCount = 0;
retVal = BUFREQ_OK;
break;
}
}
}
SchM_Exit_PduR_EA_0();//Enable interrupts
return retVal;
}
static BufReq_ReturnType PduR_ARC_CheckBufferStatus(PduIdType PduId, uint16 length) {
BufReq_ReturnType retVal = BUFREQ_BUSY;
if (PduRTpRouteBuffer(PduId) == NULL) {
retVal = BUFREQ_NOT_OK;
}
else if ((length > (PduRTpRouteBuffer(PduId)->pduInfoPtr->SduLength - PduRTpRouteBuffer(PduId)->rxByteCount))){
/* @req PDUR687 */
retVal = BUFREQ_NOT_OK;
}
else if (PduRTpRouteBuffer(PduId)->status == PDUR_BUFFER_RX_READY) {
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_RX_BUSY;
PduRTpRouteBuffer(PduId)->nAcc = 0;
retVal = BUFREQ_OK;
}
else if ((PduRTpRouteBuffer(PduId)->status == PDUR_BUFFER_TX_BUSY)
|| (PduRTpRouteBuffer(PduId)->status == PDUR_BUFFER_RX_BUSY)) {
retVal = BUFREQ_OK;
}else{
/*Do Nothing */
}
return retVal;
}
static BufReq_ReturnType PduR_ARC_ReleaseRxBuffer(PduIdType PduId) {
BufReq_ReturnType retVal;
if (PduId >= PduR_RamBufCfg.NTpRouteBuffers) {
retVal = BUFREQ_NOT_OK;
} else if (PduRTpRouteBuffer(PduId) == NULL) {
retVal = BUFREQ_OK;
} else if (PduRTpRouteBuffer(PduId)->status == PDUR_BUFFER_ALLOCATED_FROM_UP_MODULE) {
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_NOT_ALLOCATED_FROM_UP_MODULE;
retVal = BUFREQ_BUSY;
} else if (PduRTpRouteBuffer(PduId)->status == PDUR_BUFFER_RX_BUSY) {
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_TX_READY;
retVal = BUFREQ_BUSY;
} else {
retVal = BUFREQ_OK;
}
return retVal;
}
static BufReq_ReturnType PduR_ARC_ReleaseTxBuffer(PduIdType PduId) {
BufReq_ReturnType retVal = BUFREQ_NOT_OK;
if ((PduRTpRouteBuffer(PduId) != NULL) &&
(PduRTpRouteBuffer(PduId)->status == PDUR_BUFFER_TX_BUSY)) {
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_FREE;
PduRTpRouteBuffer(PduId)->nAcc = 0;
PduRTpRouteBuffer(PduId) = NULL;
retVal = BUFREQ_OK;
}
return retVal;
}
Std_ReturnType PduR_ARC_Transmit(PduIdType PduId, const PduInfoType* PduInfo, uint8 serviceId) {
PDUR_VALIDATE_INITIALIZED(serviceId,E_NOT_OK);
PDUR_VALIDATE_PDUPTR(serviceId, PduInfo, E_NOT_OK);
PDUR_VALIDATE_PDUID(serviceId, PduId, E_NOT_OK);
/* @req PDUR629 */
/* @req PDUR218 */
/* @req PDUR745 */
/* @req PDUR625 */
/* @req PDUR626 */
/* @req PDUR675 */
/* @req PDUR718 Same as 675? */
/* @req PDUR772 Same as 675/718? */
/* @req PDUR634 */
/* @req PDUR432 */
Std_ReturnType ret;
ret = E_OK;
PduRRouteStatusType status;
/* If at least one is rejected we should return E_NOT_OK,
* if all are disabled we should return E_NOT_OK */
/* @req PDUR714 */
/* @req PDUR717 */
PduRRouteStatusType totalStatus = PDUR_E_DISABLED;
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[PduId];
for (uint8 i = 0; route->PduRDestPdus[i] != NULL; i++) {
const PduRDestPdu_type * destination = route->PduRDestPdus[i];
status = PduR_ARC_RouteTransmit(destination, PduInfo);
if( (PDUR_E_REJECTED == totalStatus) || (PDUR_E_REJECTED == status)) {
totalStatus = PDUR_E_REJECTED;
} else if(PDUR_E_OK == status) {
totalStatus = PDUR_E_OK;
} else {
/* Rejected */
}
}
if( (PDUR_E_REJECTED == totalStatus) || (PDUR_E_DISABLED == totalStatus) ) {
ret = E_NOT_OK;
} else {
ret = E_OK;
}
return ret;
}
static void PduR_ARC_RxIndicationTT(const PduRDestPdu_type * destination, const PduInfoType *PduInfo) {
/* @req PDUR160 */
/* @req PDUR0661 */
if(TRUE == PduRRoutingPathEnabled(destination) ) {
memcpy(PduR_RamBufCfg.TxBuffers[destination->TxBufferId].DataPtr, PduInfo->SduDataPtr, PduInfo->SduLength);
}
if (PDUR_E_OK != PduR_ARC_RouteTransmit(destination, PduInfo)) {
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, 0, PDUR_SERVICEID_CANIFRXINDICATION, PDUR_E_PDU_INSTANCES_LOST);
}
/*
// This is a gateway request which uses trigger transmit data provision. PDUR255
if (destination->TxBufferRef->TxConfP) { // Transfer confirmation pending.
// Enqueue the new I-PDU. This will flush the buffer if it is full according to the buffer specification.
PduR_BufferQueue(destination->TxBufferRef, PduInfo->SduDataPtr);
}
if (destination->TxBufferRef->TxConfP) { // No transfer confirmation pending (anymore).
uint8 val[PduInfo->SduLength];
PduInfoType NewPduInfo = {
.SduDataPtr = val,
.SduLength = PduInfo->SduLength
};
PduR_BufferDeQueue(destination->TxBufferRef, val);
PduR_BufferQueue(destination->TxBufferRef, PduInfo->SduDataPtr);
retVal = PduR_ARC_RouteTransmit(destination, &NewPduInfo);
if (retVal == E_OK) {
setTxConfP(destination->TxBufferRef);
}
}
*/
}
static void PduR_ARC_RxIndicationDirect(const PduRDestPdu_type * destination, const PduInfoType *PduInfo) {
/* @req PDUR160 */
/* @req PDUR0745 */
PduRRouteStatusType retVal = PduR_ARC_RouteTransmit(destination, PduInfo);
if (retVal != PDUR_E_OK) {
PDUR_DET_REPORTERROR(PDUR_MODULE_ID, 0, PDUR_SERVICEID_CANIFRXINDICATION, PDUR_E_PDU_INSTANCES_LOST);
}
}
static void PduR_ARC_RxIndicationWithUpBuffer(PduIdType PduId, const PduInfoType* PduInfo, uint8 serviceId) {
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[PduId];
const PduRDestPdu_type * destination;
if (PduRTpRouteBuffer(PduId) == NULL) {
REPORT_BUFFER_ERROR(serviceId);
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return ;
}
// Save current buffer
const PduInfoType *const upBuffer = PduRTpRouteBuffer(PduId)->pduInfoPtr;
BufReq_ReturnType retVal = PduR_ARC_ReleaseRxBuffer(PduId);
if (retVal != BUFREQ_BUSY) {
REPORT_BUFFER_ERROR(serviceId);
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return;
}
// Get a new PduR buffer
retVal = PduR_ARC_AllocateBuffer(PduId, upBuffer->SduLength);
if (retVal != BUFREQ_OK) {
REPORT_BUFFER_ERROR(serviceId);
/*lint -e{904} Return statement is necessary in case of reporting a DET error */
return;
}
// Copy the data from old buffer to new.
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_RX_BUSY;
memcpy(PduRTpRouteBuffer(PduId)->pduInfoPtr->SduDataPtr, upBuffer->SduDataPtr, PduRTpRouteBuffer(PduId)->pduInfoPtr->SduLength);
// notify upper module
destination = PduR_ARC_FindUPDest(route->PduRDestPdus);
PduR_ARC_RouteRxIndication(destination, PduInfo);
// Then first transmit to all other destinations.
for (uint8 i = 0; route->PduRDestPdus[i] != NULL; i++) {
const PduRDestPdu_type * d = route->PduRDestPdus[i];
PduRRouteStatusType status = PduR_ARC_RouteTransmit(d, PduRTpRouteBuffer(PduId)->pduInfoPtr);
if(status!=PDUR_E_OK){
// IMPROVEMENT: Add DET error
}
}
}
void PduR_ARC_TpRxIndication(PduIdType PduId, NotifResultType Result, uint8 serviceId) {
PDUR_VALIDATE_INITIALIZED(serviceId);
PDUR_VALIDATE_PDUID(serviceId, PduId);
#if 0
PduInfoType PduInfo = {
.SduDataPtr = &Result,
.SduLength = 0 // To fix PC-Lint 785
};
#endif
if(Result != NTFRSLT_OK){
// There was an error in the lower layer while receiving the PDU.
// Release any buffers and notify upper layers
(void)PduR_ARC_ReleaseRxBuffer(PduId);
for (uint8 i = 0; PduRConfig->RoutingPaths[PduId]->PduRDestPdus[i] != NULL; i++) {
const PduRDestPdu_type * destination = PduRConfig->RoutingPaths[PduId]->PduRDestPdus[i];
if (PduR_IsUpModule(destination->DestModule)) {
PduR_ARC_RouteTpRxIndication(destination, Result );
}else if (PduRTpRouteBuffer(PduId) == NULL) {
REPORT_BUFFER_ERROR(serviceId);
}
else {
/*Gateway on Tp */
/* @req PDUR689 */
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_FREE;
PduRTpRouteBuffer(PduId)->nAcc = 0;
PduRTpRouteBuffer(PduId) = NULL;
}
}
} else {
for (uint8 i = 0; PduRConfig->RoutingPaths[PduId]->PduRDestPdus[i] != NULL; i++) {
const PduRDestPdu_type * destination = PduRConfig->RoutingPaths[PduId]->PduRDestPdus[i];
if(PduR_IsLoModule(destination->DestModule)){
/* @req PDUR551 */
if(PduRConfig->RoutingPaths[PduId]->PduRDirectGateway !=FALSE){
if (PDUR_E_OK == PduR_ARC_RouteTransmit(destination, PduRTpRouteBuffer(PduId)->pduInfoPtr)) {
PduRTpRouteBuffer(PduId)->status = PDUR_BUFFER_TX_BUSY;
}
}
}else{
PduR_ARC_RouteTpRxIndication(destination, Result );
}
}
}
}
void PduR_ARC_RxIndication(PduIdType PduId, const PduInfoType* PduInfo, uint8 serviceId) {
PDUR_VALIDATE_INITIALIZED(serviceId);
PDUR_VALIDATE_PDUPTR(serviceId, PduInfo);
PDUR_VALIDATE_PDUID(serviceId, PduId);
/* @req PDUR164 */
/* @req PDUR161 */
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[PduId];
/* @req PDUR160 */
/* @req PDUR766 */
/* @req PDUR621 */
/* @req PDUR744 */
/* @req PDUR673 */
/* @req PDUR673 */
/* @req PDUR436 */
/* @req PDUR437 */
/* @req PDUR303 */
/* @req PDUR306 */
/* @req PDUR783 */
/* @req PDUR643 ?*/
/* @req PDUR683 ?*/
if (HAS_BUFFER_STATUS(PduId, PDUR_BUFFER_ALLOCATED_FROM_UP_MODULE)) {
PduR_ARC_RxIndicationWithUpBuffer(PduId, PduInfo, serviceId);
} else {
for (uint8 i = 0; route->PduRDestPdus[i] != NULL; i++) {
const PduRDestPdu_type * destination = route->PduRDestPdus[i];
if (PduR_IsUpModule(destination->DestModule)) {
PduR_ARC_RouteRxIndication(destination, PduInfo);
} else if (PduR_IsLoModule(destination->DestModule)) {
if (destination->DataProvision == PDUR_TRIGGER_TRANSMIT) {
PduR_ARC_RxIndicationTT(destination, PduInfo);
} else if (destination->DataProvision == PDUR_DIRECT) {
PduR_ARC_RxIndicationDirect(destination, PduInfo);
} else {
// Do nothing
}
} else {
// Do nothing
}
}
}
(void)PduR_ARC_ReleaseRxBuffer(PduId);
}
void PduR_ARC_TpTxConfirmation(PduIdType PduId, uint8 result, uint8 serviceId) {
PduIdType sourcePduId;
PDUR_VALIDATE_INITIALIZED(serviceId);
if (PduId >= PDU_MAX_ROUTING_PATH) {
sourcePduId = (PduId & (uint16)PDUR_PDU_ID_MASK);
}else{
sourcePduId = PduId;
}
PDUR_VALIDATE_PDUID(serviceId, sourcePduId);
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[sourcePduId];
/* @req PDUR301 */
if (PduR_IsUpModule(route->SrcModule)) {
PduR_ARC_RouteTpTxConfirmation(route,result);
} else if (PduR_IsLoModule(route->SrcModule) && HAS_BUFFER_STATUS(sourcePduId, PDUR_BUFFER_TX_BUSY)) {
PduRTpRouteBuffer(sourcePduId)->nAcc++;
uint8 nDests = 0;
for (uint8 i = 0; route->PduRDestPdus[i] != NULL; i++) {
if (!PduR_IsUpModule(route->PduRDestPdus[i]->DestModule)) {
nDests++;
}
}
if (PduRTpRouteBuffer(sourcePduId)->nAcc >= nDests) {
// Release any buffer held by this route
/* @req PDUR637 */
BufReq_ReturnType status = PduR_ARC_ReleaseTxBuffer(sourcePduId);
if (status != BUFREQ_OK) {
REPORT_BUFFER_ERROR(serviceId);
}
}
} else {
// Do nothing
}
}
void PduR_ARC_TxConfirmation(PduIdType PduId, uint8 result, uint8 serviceId) {
PDUR_VALIDATE_INITIALIZED(serviceId);
PDUR_VALIDATE_PDUID(serviceId, PduId);
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[PduId];
/* @req PDUR627 */
if (PduR_IsUpModule(route->SrcModule)) {
PduR_ARC_RouteTxConfirmation(route, result);
} else if (PduR_IsLoModule(route->SrcModule) && HAS_BUFFER_STATUS(PduId, PDUR_BUFFER_TX_BUSY)) {
// Release any buffer held by this route
/* @req PDUR637 */
BufReq_ReturnType status = PduR_ARC_ReleaseTxBuffer(PduId);
if (status != BUFREQ_OK) {
REPORT_BUFFER_ERROR(serviceId);
}
} else {
// Do nothing
}
}
Std_ReturnType PduR_ARC_TriggerTransmit(PduIdType PduId, PduInfoType* PduInfo, uint8 serviceId) {
/*lint -esym(613,PduInfo)*/ /* PC-Lint 613 misunderstanding: PduInfo is not null since it is validated in PDUR_VALIDATE_PDUPTR */
PDUR_VALIDATE_INITIALIZED(serviceId, E_NOT_OK);
PDUR_VALIDATE_PDUPTR(serviceId, PduInfo, E_NOT_OK);
PDUR_VALIDATE_PDUID(serviceId, PduId, E_NOT_OK);
Std_ReturnType retVal = E_NOT_OK;
SchM_Enter_PduR_EA_0();
/* @req PDUR0766 */
/* @req PDUR773 */
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[PduId];
const PduRDestPdu_type * destination = route->PduRDestPdus[0];
if (PduR_IsUpModule(route->SrcModule)) {
retVal = PduR_ARC_RouteTriggerTransmit(route, PduInfo);
} else if (PduR_IsLoModule(route->SrcModule)) {
if (destination->DataProvision == PDUR_TRIGGER_TRANSMIT) {
if( TRUE == PduRRoutingPathEnabled(destination) ) {
/* @req PDUR662 */
memcpy((void *)PduInfo->SduDataPtr, (void *)PduR_RamBufCfg.TxBuffers[destination->TxBufferId].DataPtr, PduInfo->SduLength);
retVal = E_OK;
}
}
} else {
//IMPROVEMENT: Add DET error
}
SchM_Exit_PduR_EA_0();
return retVal;
}
/** List has at least one TP module */
static boolean PduR_ARC_HasTpModuleDest(const PduRDestPdu_type * const *destPdus)
{
boolean ret = FALSE;
for (uint32 i = 0; ((ret==FALSE) && (destPdus[i] != NULL)); i++)
{
if (PduR_IsTpModule(destPdus[i]->DestModule))
{
ret = TRUE;
}
}
return ret;
}
/** Find first upper module in list */
static const PduRDestPdu_type * PduR_ARC_FindUPDest(const PduRDestPdu_type * const *destPdus)
{
const PduRDestPdu_type *dest = NULL;
for (uint32 i = 0; (dest == NULL) && (destPdus[i] != NULL); i++)
{
if (PduR_IsUpModule(destPdus[i]->DestModule))
{
dest = destPdus[i];
}
}
return dest;
}
// PduR Interface used by Upper modules
/* @req PDUR406 */
Std_ReturnType PduR_UpTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr, uint8 serviceId) {
return PduR_ARC_Transmit(pduId, pduInfoPtr, serviceId);
}
/* @req PDUR0769 */
Std_ReturnType PduR_UpCancelTransmit(PduIdType pduId, uint8 serviceId) {
// IMPROVEMENT: Add support
(void)pduId;
(void)serviceId;
return E_NOT_OK;
}
/* @req PDUR482 */
void PduR_UpChangeParameter(PduIdType pduId, TPParameterType parameter, uint16 value, uint8 serviceId) {
// IMPROVEMENT: Add support
(void)pduId;
(void)parameter;
(void)value;
(void)serviceId;
}
/* @req PDUR0767 */
Std_ReturnType PduR_UpCancelReceive(PduIdType pduId, uint8 serviceId) {
// IMPROVEMENT: Add support
(void)pduId;
(void)serviceId;
return E_NOT_OK;
}
// PduR Interface used by Lower If modules
/* @req PDUR362 */
void PduR_LoIfRxIndication(PduIdType pduId, PduInfoType* pduInfoPtr, uint8 serviceId) {
PduR_ARC_RxIndication(pduId, pduInfoPtr, serviceId);
/*lint -e818 Diclaring pduInfoPtr as const PduInfoType* will cause deviation in ASR API prototype */
}
/* @req PDUR365 */
void PduR_LoIfTxConfirmation(PduIdType pduId, uint8 serviceId) {
uint8 dummy = 0;
PduR_ARC_TxConfirmation(pduId, dummy, serviceId);
}
/* @req PDUR369 */
Std_ReturnType PduR_LoIfTriggerTransmit(PduIdType pduId, PduInfoType* pduInfoPtr, uint8 serviceId) {
return PduR_ARC_TriggerTransmit(pduId, pduInfoPtr, serviceId);
}
/**
* @brief Function to check minimum buffer size for reception
* @param minBufSize Minimum buffer size computed
* @param avblBufSize Available buffer size
*/
static inline void calculateMinBufferSize(PduLengthType *minBufSize, const PduLengthType *avblBufSize) {
if (*minBufSize != 0 ) {
if ( *avblBufSize < *minBufSize) {
*minBufSize = *avblBufSize;
}
} else {
*minBufSize = *avblBufSize;
}
}
// PduR Interface used by Lower Tp modules
/* @req PDUR512 */
BufReq_ReturnType PduR_LoTpCopyRxData(PduIdType pduId, PduInfoType* info, PduLengthType* bufferSizePtr, uint8 serviceId) {
// Destination cases:
// 1. Only Upper modules: route without PduR buffering
// 2. At least one Lower TP module: route WITH PduR buffering
/* !req PDUR0708 */
const PduRRoutingPath_type *route;
const PduRDestPdu_type * destination;
PduLengthType tmpRxByteCnt;
PduLengthType minBufSize;
PduLengthType bufSize;
BufReq_ReturnType retVal;
uint8 i;
PDUR_VALIDATE_INITIALIZED(serviceId,BUFREQ_NOT_OK);
PDUR_VALIDATE_PDUID(serviceId, pduId, BUFREQ_NOT_OK);
PDUR_VALIDATE_PDUPTR(serviceId, info, BUFREQ_NOT_OK);
SchM_Enter_PduR_EA_0();
route = PduRConfig->RoutingPaths[pduId];
minBufSize = 0;
bufSize = 0;
retVal = BUFREQ_OK;
for (i = 0; route->PduRDestPdus[i] != NULL; i++) {
// For all upper destination modules
if (PduR_IsUpModule(route->PduRDestPdus[i]->DestModule))
{
destination = route->PduRDestPdus[i];
retVal = PduR_ARC_RouteCopyRxData(destination, info, &bufSize);
if (retVal == BUFREQ_OK) {
calculateMinBufferSize(&minBufSize, &bufSize);
}else if (route->PduRDestinatnNum > 1){
/* In case of gateway to multiple destinations:
* Even if one one copy fails for any reason (Busy, overflow etc.) set the status as BUFREQ_NOT_OK and terminate
*/
retVal = BUFREQ_NOT_OK;
break;
} else {
/* Do nothing */
}
}
}
if ((BUFREQ_OK == retVal) && (TRUE == PduR_ARC_HasTpModuleDest(route->PduRDestPdus))) {
retVal = PduR_ARC_CheckBufferStatus(pduId, info->SduLength);
if ((BUFREQ_NOT_OK == retVal) && (PduRTpRouteBuffer(pduId) != NULL)) {
/* @req PDUR687 */
PduRTpRouteBuffer(pduId)->status = PDUR_BUFFER_FREE;
PduRTpRouteBuffer(pduId)->nAcc = 0;
PduRTpRouteBuffer(pduId) = NULL;
}
else if (BUFREQ_OK == retVal) {
// Copy rx data to buffer
memcpy(&PduRTpRouteBuffer(pduId)->pduInfoPtr->SduDataPtr[PduRTpRouteBuffer(pduId)->rxByteCount], info->SduDataPtr, info->SduLength);
tmpRxByteCnt = PduRTpRouteBuffer(pduId)->rxByteCount;
tmpRxByteCnt += info->SduLength;
PduRTpRouteBuffer(pduId)->rxByteCount = tmpRxByteCnt;
bufSize = PduRTpRouteBuffer(pduId)->pduInfoPtr->SduLength - tmpRxByteCnt;
calculateMinBufferSize(&minBufSize, &bufSize);
if(PduRConfig->RoutingPaths[pduId]->PduRDirectGateway !=TRUE){
// Check whether PduRTpBuffer reached threshold
if ((PduRConfig->RoutingPaths[pduId]->PduRTpThreshld <= tmpRxByteCnt) && (PduRTpRouteBuffer(pduId)->status == PDUR_BUFFER_RX_BUSY))
{
/* @req PDUR317 */
PduRTpRouteBuffer(pduId)->status = PDUR_BUFFER_TX_READY;
}
// Transmit on lower TP destinations
if (PduRTpRouteBuffer(pduId)->status == PDUR_BUFFER_TX_READY)
{
for (i = 0; (route->PduRDestPdus[i] != NULL); i++) {
// For all lower destination modules
if (PduR_IsLoModule(route->PduRDestPdus[i]->DestModule))
{
destination = route->PduRDestPdus[i];
if (PDUR_E_OK != PduR_ARC_RouteTransmit(destination, PduRTpRouteBuffer(pduId)->pduInfoPtr)) {
retVal = BUFREQ_NOT_OK;
}
else
{
PduRTpRouteBuffer(pduId)->status = PDUR_BUFFER_TX_BUSY;
}
}
}
}
}
} else {
/* Do nothing */
}
}
SchM_Exit_PduR_EA_0();
// Out bufferSizePtr: available minimum buffer size
if (bufferSizePtr != NULL) {
*bufferSizePtr = minBufSize;
}
if (retVal != BUFREQ_OK)
{
REPORT_BUFFER_ERROR(serviceId);
}
return retVal;
}
/* @req PDUR375 */
void PduR_LoTpRxIndication(PduIdType id, NotifResultType result, uint8 serviceId) {
PduR_ARC_TpRxIndication(id, result, serviceId);
}
/* @req PDUR507 */
BufReq_ReturnType PduR_LoTpStartOfReception(PduIdType pduId, PduLengthType TpSduLength, PduLengthType* bufferSizePtr, uint8 serviceId) {
/* @req PDUR623 */
/* @req PDUR0749 */
// Destination cases:
// 1. Only Upper modules: route without PduR buffering
// 2. At least one Lower TP module: route WITH PduR buffering
const PduRRoutingPath_type *route;
const PduRDestPdu_type * destination;
BufReq_ReturnType retVal;
PduLengthType minBufSize;
PduLengthType bufSize;
uint8 i;
boolean startOfRxOk; //Variable to indicate at least one start of reception is successful
PDUR_VALIDATE_INITIALIZED(serviceId,BUFREQ_NOT_OK);
PDUR_VALIDATE_PDUID(serviceId, pduId, BUFREQ_NOT_OK);
route = PduRConfig->RoutingPaths[pduId];
minBufSize = 0;
retVal = BUFREQ_OK;
startOfRxOk = FALSE;
for (i = 0; route->PduRDestPdus[i] != NULL; i++) {
// For all upper destination modules
if (PduR_IsUpModule(route->PduRDestPdus[i]->DestModule))
{
destination = route->PduRDestPdus[i];
retVal = PduR_ARC_RouteStartOfReception(destination, TpSduLength, &bufSize);
if (retVal == BUFREQ_OK) {
startOfRxOk = TRUE;
calculateMinBufferSize(&minBufSize, &bufSize);
}else if (route->PduRDestinatnNum > 1){
/* In case of gateway to multiple destinations:
* Even if one start of reception fails for any reason (Busy, overflow etc.) set the status as BUFREQ_NOT_OK and terminate.
*/
retVal = BUFREQ_NOT_OK;
break;
} else {
/* Do nothing */
}
}
}
/* Routing to lower destination modules will be triggered i.e transmission is initiated
* 1. In case of gateway on fly: PduR_LoTpCopyRxData() when sufficient bytes are received
* 2. In case of direct gateway: PduR_LoTpRxIndication() when all bytes are received
*
*/
if ( (BUFREQ_OK == retVal) && (TRUE == PduR_ARC_HasTpModuleDest(route->PduRDestPdus)) ) {
/* If a gateway is already active (buffer not released). Return busy and LoTp is expected to try again */
if (PduRTpRouteBuffer(pduId) != NULL) {
retVal = BUFREQ_BUSY;
} else {
retVal = PduR_ARC_AllocateBuffer(pduId, TpSduLength);
if (retVal == BUFREQ_OK) {
bufSize = PduRTpRouteBuffer(pduId)->bufferSize;
calculateMinBufferSize(&minBufSize, &bufSize);
}else if (route->PduRDestinatnNum > 1){
/* In case of gateway to multiple destinations:
* Even if one start of reception fails for any reason (Busy, overflow etc.) set the status as BUFREQ_NOT_OK and terminate
*/
retVal = BUFREQ_NOT_OK;
} else {
/* Do nothing */
}
}
}
if ((startOfRxOk == TRUE) && (retVal != BUFREQ_OK)) {
/* If the start of reception for any upper layer module returns E_OK implies a buffer is locked for subsequent reception by that module.
* Now the overall status of this API is not equal to BUFREQ_OK. So in order to unlock the buffers we need to call
* Module_TpRxIndication(). Ex. Dcm_TpRxIndication().
* Module_TpRxIndication() will be ignored by modules which did not return E_OK.
*/
for (i = 0; route->PduRDestPdus[i] != NULL; i++) {
// For all upper destination modules
if (PduR_IsUpModule(route->PduRDestPdus[i]->DestModule))
{
destination = route->PduRDestPdus[i];
PduR_ARC_RouteTpRxIndication(destination, NTFRSLT_E_NOT_OK );
}
}
}
// Out bufferSizePtr: available minimum buffer size
if (bufferSizePtr != NULL) {
*bufferSizePtr = minBufSize;
}
if (retVal != BUFREQ_OK) {
REPORT_BUFFER_ERROR(serviceId);
}
return retVal;
}
/* @req PDUR518 */
BufReq_ReturnType PduR_LoTpCopyTxData(PduIdType pduId, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr, uint8 serviceId) {
/* !req PDUR435 *//* Always forwarded to upper layer module */
/* @req PDUR0676 */
PDUR_VALIDATE_INITIALIZED(serviceId,BUFREQ_NOT_OK);
PDUR_VALIDATE_PDUPTR(serviceId, info, BUFREQ_NOT_OK);
PduIdType sourcePduId;
uint8 destionId;
destionId =0; //This is for the 1st destination
if (pduId >= PDU_MAX_ROUTING_PATH) {
destionId = (pduId >> 13U); // This gives the destination number among the destinations configured.
sourcePduId = (pduId & (uint16)PDUR_PDU_ID_MASK); // This gives the Source PduId
}else{
sourcePduId= pduId;
}
PDUR_VALIDATE_PDUID(serviceId, sourcePduId, BUFREQ_NOT_OK);
SchM_Enter_PduR_EA_0();
BufReq_ReturnType retVal = BUFREQ_OK;
const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[sourcePduId];
RetryInfoType checkedRetry;
const uint8 *srcPtr;
PduLengthType length;
if (PduR_IsUpModule(route->SrcModule)) {
// Upper module, just forward the copy request
retVal = PduR_ARC_RouteCopyTxData(route, info, retry, availableDataPtr);
} else if (PduR_IsLoModule(route->SrcModule) && ( (PduRTpRouteBuffer(sourcePduId) != NULL))) {
/* Lower tp module, copy from existing transmit data buffer (gateway) */
/* Check retry info, null ptr */
if (retry != NULL) {
checkedRetry.TpDataState = retry->TpDataState;
checkedRetry.TxTpDataCnt = retry->TxTpDataCnt;
if ((PduRConfig->RoutingPaths[sourcePduId]->PduRDirectGateway!= TRUE) && (retry->TpDataState != TP_DATACONF)) {
/* @req PDUR690 */
PduRTpRouteBuffer(sourcePduId)->status = PDUR_BUFFER_FREE;
PduRTpRouteBuffer(sourcePduId)->nAcc = 0;
PduRTpRouteBuffer(sourcePduId) = NULL;
checkedRetry.TxTpDataCnt = 0;
SchM_Exit_PduR_EA_0();
/*lint -e{904} PERFORMANCE PduR_LoTpCopyTxData() will return E_NOT_OK because the TP buffers are cleared */
return BUFREQ_NOT_OK;
}
}else {
// Retry not supported, copy all
checkedRetry.TpDataState = TP_DATACONF;
checkedRetry.TxTpDataCnt = 0;
}
// Check retry info, data state
if (checkedRetry.TpDataState != TP_DATARETRY)
{
// No retry, copy all
checkedRetry.TxTpDataCnt = 0;
}
length = info->SduLength;
if (NULL == PduRTpRouteBuffer(sourcePduId)) {
retVal = BUFREQ_NOT_OK;
}
else if ( ( checkedRetry.TxTpDataCnt > PduRTpRouteBuffer(sourcePduId)->pduInfoPtr->SduLength) ||
( length > PduRTpRouteBuffer(sourcePduId)->bufferSize))
{
retVal = BUFREQ_NOT_OK;
}
/* Check if requested data is already buffered incase of gateway on fly */
else if (((PduRConfig->RoutingPaths[sourcePduId]->PduRDirectGateway !=TRUE)) && ((PduRTpRouteBuffer(sourcePduId)->txByteCount[destionId] + length) > PduRTpRouteBuffer(sourcePduId)->rxByteCount))
{
retVal = BUFREQ_BUSY;
}
else if ((PduRConfig->RoutingPaths[sourcePduId]->PduRDirectGateway ==TRUE) && ((PduRTpRouteBuffer(sourcePduId)->txByteCount[destionId] + length) > PduRTpRouteBuffer(sourcePduId)->rxByteCount)){
retVal = BUFREQ_NOT_OK;
}
else {
//Check whether gateway
if ((checkedRetry.TpDataState !=TP_DATARETRY))
{
/* @req PDUR707*/
// Copy from PduR transmit buffer to Lower tp module buffer
srcPtr = &PduRTpRouteBuffer(sourcePduId)->pduInfoPtr->SduDataPtr[PduRTpRouteBuffer(sourcePduId)->txByteCount[destionId]];
PduRTpRouteBuffer(sourcePduId)->txByteCount[destionId] += length;
}
else {
// Copy from PduR transmit buffer to Lower tp module buffer
srcPtr = &PduRTpRouteBuffer(sourcePduId)->pduInfoPtr->SduDataPtr[checkedRetry.TxTpDataCnt];
PduRTpRouteBuffer(sourcePduId)->txByteCount[destionId] = checkedRetry.TxTpDataCnt + length;
}
memcpy(info->SduDataPtr, srcPtr, length);
// Indicate remaining data in tx buffer
if (availableDataPtr != NULL) {
*availableDataPtr = (PduRTpRouteBuffer(sourcePduId)->pduInfoPtr->SduLength - PduRTpRouteBuffer(sourcePduId)->txByteCount[destionId]);
}
retVal = BUFREQ_OK;
}
} else {
retVal = BUFREQ_NOT_OK;
}
SchM_Exit_PduR_EA_0();
return retVal;
}
/* @req PDUR381 */
void PduR_LoTpTxConfirmation(PduIdType id, NotifResultType result, uint8 serviceId) {
PduR_ARC_TpTxConfirmation(id, result, serviceId);
}
/**
* Checks if a destination is enabled
* @param destination
* @return
*/
boolean PduRRoutingPathEnabled(const PduRDestPdu_type * destination)
{
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
boolean enabled = TRUE;
if( NULL != destination ) {
if( 0 != destination->NofGroupRefs ) {
for(PduR_RoutingPathGroupIdType i = 0; ((i < destination->NofGroupRefs) && (enabled==TRUE)); i++) {
enabled = PdurRoutingGroupEnabled[destination->RoutingPathGroupRefs[i]];
}
} else {
enabled = TRUE;
}
} else {
/* Invalid destination. Cannot be enabled. */
enabled = FALSE;
}
return enabled;
#else
(void)destination;/*lint !e920*/
return TRUE;
#endif
}
#if (PDUR_MAX_NOF_ROUTING_PATH_GROUPS > 0)
void PdurSetRoutingPathEnabled(PduR_RoutingPathGroupIdType id, boolean enabled)
{
PdurRoutingGroupEnabled[id] = enabled;
}
#endif
#endif /* PDUR_ZERO_COST_OPERATION */
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_Logic.c
|
C
|
unknown
| 36,443
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#if defined(USE_DEM)
#include "Dem.h"
#endif
#if PDUR_CANIF_SUPPORT == STD_ON
#include "CanIf.h"
#endif
#if PDUR_CANNM_SUPPORT == STD_ON
#include "CanNm.h"
#endif
#if PDUR_UDPNM_SUPPORT == STD_ON
#include "UdpNm.h"
#endif
#if PDUR_CANTP_SUPPORT == STD_ON
#include "CanTp.h"
#endif
#if PDUR_LINIF_SUPPORT == STD_ON
#include "LinIf.h"
#endif
#if PDUR_COM_SUPPORT == STD_ON
#include "Com.h"
#endif
#if PDUR_DCM_SUPPORT == STD_ON
#include "Dcm.h"
#endif
#if PDUR_SOAD_SUPPORT == STD_ON
#include "SoAd.h"
#endif
#if PDUR_DOIP_SUPPORT == STD_ON
#include "DoIP.h"
#endif
#if PDUR_J1939TP_SUPPORT == STD_ON
#include "J1939Tp.h"
#endif
#if PDUR_IPDUM_SUPPORT == STD_ON
#include "IpduM.h"
#include "IpduM_Cbk.h"
#endif
#if PDUR_FRIF_SUPPORT == STD_ON
#include "FrIf.h"
#endif
#if PDUR_FRNM_SUPPORT == STD_ON
#include "FrNm.h"
#endif
#if PDUR_FRTP_SUPPORT == STD_ON
#include "FrTp.h"
#endif
#if PDUR_SECOC_SUPPORT == STD_ON
#include "SecOC.h"
#endif
#if PDUR_CDDPDUR_SUPPORT == STD_ON
#include "CddPduR_Cbk.h"
#endif
#if PDUR_LDCOM_SUPPORT == STD_ON
#include "LdCom.h"
#endif
#if PDUR_ZERO_COST_OPERATION == STD_OFF
PduRRouteStatusType PduR_ARC_RouteTransmit(const PduRDestPdu_type * destination, const PduInfoType * pduInfo) {
/* @req PDUR160 */
/* @req PDUR629 */
/* @req PDUR0745 */
/* @req PDUR625 */
/* @req PDUR423 *//* Dem_ReportError N/A since PduR has no production errors */
PduRRouteStatusType ret = PDUR_E_DISABLED;
Std_ReturnType retVal = E_NOT_OK;
if( (TRUE==PduRRoutingPathEnabled(destination)) || (ARC_PDUR_COM == destination->DestModule) ) {
ret = PDUR_E_REJECTED;
switch (destination->DestModule) {
case ARC_PDUR_CANIF:
#if PDUR_CANIF_SUPPORT == STD_ON
retVal = CanIf_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_CANNM:
#if PDUR_CANNM_SUPPORT == STD_ON
retVal = CanNm_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_UDPNM:
#if PDUR_UDPNM_SUPPORT == STD_ON
retVal = UdpNm_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_LINIF:
#if PDUR_LINIF_SUPPORT == STD_ON
retVal = LinIf_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_CANTP:
#if PDUR_CANTP_SUPPORT == STD_ON
retVal = CanTp_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_SOADIF:
#if PDUR_SOAD_SUPPORT == STD_ON
retVal = SoAd_IfTransmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_SOADTP:
#if PDUR_SOAD_SUPPORT == STD_ON
retVal = SoAd_TpTransmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_DOIPIF:
#if PDUR_DOIP_SUPPORT == STD_ON
retVal = DoIP_IfTransmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_DOIPTP:
#if PDUR_DOIP_SUPPORT == STD_ON
retVal = DoIP_TpTransmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_J1939TP:
#if PDUR_J1939TP_SUPPORT == STD_ON
retVal = J1939Tp_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_IPDUM:
#if PDUR_IPDUM_SUPPORT == STD_ON
retVal = IpduM_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_FRIF:
#if PDUR_FRIF_SUPPORT == STD_ON
retVal = FrIf_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_FRNM:
#if PDUR_FRNM_SUPPORT == STD_ON
retVal = FrNm_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_FRTP:
#if PDUR_FRTP_SUPPORT == STD_ON
retVal = FrTp_Transmit(destination->DestPduId, pduInfo);
#endif
break;
case ARC_PDUR_SECOC:
#if PDUR_SECOC_SUPPORT == STD_ON
retVal = SecOC_Transmit(destination->DestPduId, pduInfo);
#endif
break;
default:
retVal = E_NOT_OK;
break;
}
if(E_OK == retVal) {
ret = PDUR_E_OK;
}
}
return ret;
}
void PduR_ARC_RouteRxIndication(const PduRDestPdu_type * destination, const PduInfoType *PduInfo) {
switch (destination->DestModule) {
case ARC_PDUR_COM:
#if PDUR_COM_SUPPORT == STD_ON
/*lint -e{929} -e{9005} attempt to cast away const -Com_RxIndication() is ASR api and cast becomes necessary to match the prototype */
Com_RxIndication(destination->DestPduId, (PduInfoType *)PduInfo);
#endif
break;
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
Dcm_TpRxIndication(destination->DestPduId, *PduInfo->SduDataPtr);
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
/*lint -e{929} -e{9005} attempt to cast away const -Com_RxIndication() is ASR api and cast becomes necessary to match the prototype */
LdCom_RxIndication(destination->DestPduId, (PduInfoType *)PduInfo);
#endif
break;
case ARC_PDUR_IPDUM:
#if PDUR_IPDUM_SUPPORT == STD_ON
/*lint -e{929} -e{9005} attempt to cast away const -Com_RxIndication() is ASR api and cast becomes necessary to match the prototype */
IpduM_RxIndication(destination->DestPduId, (PduInfoType *)PduInfo);
#endif
break;
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
/*lint -e{929} -e{9005} attempt to cast away const -Com_RxIndication() is ASR api and cast becomes necessary to match the prototype */
CddPduR_RxIndication(destination->DestPduId, (PduInfoType *)PduInfo);
break;
#endif
#if PDUR_SECOC_SUPPORT == STD_ON
case ARC_PDUR_SECOC:
SecOC_RxIndication(destination->DestPduId, PduInfo);
break;
#endif
default:
break;
}
}
void PduR_ARC_RouteTpRxIndication(const PduRDestPdu_type * destination, Std_ReturnType result ) {
/* @req PDUR207 */
/* @req PDUR429 */
switch (destination->DestModule) {
case ARC_PDUR_COM:
#if PDUR_COM_SUPPORT == STD_ON
Com_TpRxIndication(destination->DestPduId, result);
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
LdCom_TpRxIndication(destination->DestPduId, result);
#endif
break;
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
Dcm_TpRxIndication(destination->DestPduId, result );
#endif
break;
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
CddPduR_TpRxIndication(destination->DestPduId, result );
break;
#endif
default:
break;
}
}
void PduR_ARC_RouteTpTxConfirmation(const PduRRoutingPath_type *route, Std_ReturnType result) {
/* @req PDUR301 */
/* SrcModule is the initiator, ie calls PduR_<up>Transmit */
switch (route->SrcModule) {
case ARC_PDUR_COM:
#if PDUR_COM_SUPPORT == STD_ON
Com_TpTxConfirmation(route->SrcPduId, result);
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
LdCom_TpTxConfirmation(route->SrcPduId, result);
#endif
break;
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
Dcm_TpTxConfirmation(route->SrcPduId, result);
#else
(void) result; /* Remove compiler warning */
#endif
break;
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
CddPduR_TpTxConfirmation(route->SrcPduId, result);
break;
#endif
default:
break;
}
}
void PduR_ARC_RouteTxConfirmation(const PduRRoutingPath_type *route, uint8 result) {
/* @req PDUR627 */
switch (route->SrcModule) {
case ARC_PDUR_COM:
#if PDUR_COM_SUPPORT == STD_ON
Com_TxConfirmation(route->SrcPduId);
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
LdCom_TxConfirmation(route->SrcPduId);
#endif
break;
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
Dcm_TpTxConfirmation(route->SrcPduId, result);
#else
(void) result; /* Remove compiler warning */
#endif
break;
case ARC_PDUR_IPDUM:
#if PDUR_IPDUM_SUPPORT == STD_ON
IpduM_TxConfirmation(route->SrcPduId);
#endif
break;
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
CddPduR_TxConfirmation(route->SrcPduId, result);
break;
#endif
#if PDUR_SECOC_SUPPORT == STD_ON
case ARC_PDUR_SECOC:
SecOC_TxConfirmation(route->SrcPduId);
break;
#endif
default:
break;
}
}
Std_ReturnType PduR_ARC_RouteTriggerTransmit(const PduRRoutingPath_type *route, PduInfoType * pduInfo) {
/* @req PDUR430 */
Std_ReturnType retVal = E_NOT_OK;
switch (route->SrcModule) {
case ARC_PDUR_COM:
#if PDUR_COM_SUPPORT == STD_ON
retVal = Com_TriggerTransmit(route->SrcPduId, pduInfo);
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
retVal = LdCom_TriggerTransmit(route->SrcPduId, pduInfo);
#endif
break;
case ARC_PDUR_IPDUM:
#if PDUR_IPDUM_SUPPORT == STD_ON
retVal = IpduM_TriggerTransmit(route->SrcPduId, pduInfo);
#endif
break;
default:
retVal = E_NOT_OK;
break;
}
return retVal;
}
BufReq_ReturnType PduR_ARC_RouteCopyRxData(const PduRDestPdu_type * destination, PduInfoType* info, PduLengthType* bufferSizePtr) {
/* @req PDUR428 */
BufReq_ReturnType retVal = BUFREQ_NOT_OK;
switch (destination->DestModule) {
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
retVal = Dcm_CopyRxData(destination->DestPduId, info, bufferSizePtr);
#else
//lint -estring(920,pointer) /* cast to void */
(void)destination; /* Remove compiler warning */
(void)info; /* Remove compiler warning */
(void)bufferSizePtr; /* Remove compiler warning */
//lint +estring(920,pointer) /* cast to void */
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
retVal = LdCom_CopyRxData(destination->DestPduId, info, bufferSizePtr);
#endif
#if 0 // Not supported in current SecOC implementation
case ARC_PDU_SECOC:
#if PDUR_SECOC_SUPPORT == STD_ON
retVal = SecOC_CopyRxData(destination->DestPduId, info, bufferSizePtr);
#else
//lint -estring(920,pointer) /* cast to void */
(void)destination; /* Remove compiler warning */
(void)info; /* Remove compiler warning */
(void)bufferSizePtr; /* Remove compiler warning */
//lint +estring(920,pointer) /* cast to void */
#endif
break;
#endif
break;
#if defined(USE_COM)
case ARC_PDUR_COM:
retVal = Com_CopyRxData(destination->DestPduId, info, bufferSizePtr);
break;
#endif
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
retVal = CddPduR_CopyRxData(destination->DestPduId, info, bufferSizePtr);
break;
#endif
default:
break;
}
return retVal;
}
BufReq_ReturnType PduR_ARC_RouteCopyTxData(const PduRRoutingPath_type *route, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr) {
/* @req PDUR299 */
BufReq_ReturnType retVal = BUFREQ_NOT_OK;
switch (route->SrcModule) {
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
retVal = Dcm_CopyTxData(route->SrcPduId, info, retry, availableDataPtr);
#else
//lint -estring(920,pointer) /* cast to void */
(void)info; /* Remove compiler warning*/
(void)retry; /* Remove compiler warning */
(void)availableDataPtr; /* Remove compiler warning */
//lint +estring(920,pointer) /* cast to void */
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
retVal = LdCom_CopyTxData(route->SrcPduId, info, retry, availableDataPtr);
#endif
#if 0 // Not supported in current SecOC implementation
case ARC_PDU_SECOC:
#if PDUR_SECOC_SUPPORT == STD_ON
retVal = SecOC_CopyTxData(route->SrcPduId, info, retry, availableDataPtr);
#else
//lint -estring(920,pointer) /* cast to void */
(void)info; /* Remove compiler warning*/
(void)retry; /* Remove compiler warning */
(void)availableDataPtr; /* Remove compiler warning */
//lint +estring(920,pointer) /* cast to void */
#endif
break;
#endif
break;
#if defined(USE_COM)
case ARC_PDUR_COM:
retVal = Com_CopyTxData(route->SrcPduId, info, retry, availableDataPtr);
break;
#endif
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
retVal = CddPduR_CopyTxData(route->SrcPduId, info, retry, availableDataPtr);
break;
#endif
default:
break;
}
return retVal;
}
BufReq_ReturnType PduR_ARC_RouteStartOfReception(const PduRDestPdu_type * destination, PduLengthType TpSduLength, PduLengthType* bufferSizePtr) {
/* @req PDUR549 */
BufReq_ReturnType retVal = BUFREQ_NOT_OK;
#if (PDUR_LDCOM_SUPPORT == STD_ON)
uint8 temp; /* This is a temporary fix until we move all modules to 4.2.2 version. */
/* Hope the upper layer does not require pduInfo, as it is not used in 4.0.3 */
const PduInfoType pduInfo = { &temp, TpSduLength};
#endif
switch (destination->DestModule) {
case ARC_PDUR_DCM:
#if PDUR_DCM_SUPPORT == STD_ON
retVal = Dcm_StartOfReception(destination->DestPduId, TpSduLength, bufferSizePtr);
#else
//lint -estring(920,pointer) /* cast to void */
(void)TpSduLength; /* Remove compiler warning */
(void)bufferSizePtr; /* Remove compiler warning */
//lint +estring(920,pointer) /* cast to void */
#endif
break;
case ARC_PDUR_LDCOM:
#if PDUR_LDCOM_SUPPORT == STD_ON
retVal = LdCom_StartOfReception(destination->DestPduId, &pduInfo, TpSduLength, bufferSizePtr);
#endif
#if 0 // Not supported in current SecOC implementation
case ARC_PDU_SECOC:
#if PDUR_SECOC_SUPPORT == STD_ON
retVal = SecOC_StartOfReception(destination->DestPduId, NULL, TpSduLength, bufferSizePtr);
#else
//lint -estring(920,pointer) /* cast to void */
(void)TpSduLength; /* Remove compiler warning */
(void)bufferSizePtr; /* Remove compiler warning */
//lint +estring(920,pointer) /* cast to void */
#endif
break;
#endif
break;
#if defined(USE_COM)
case ARC_PDUR_COM:
retVal = Com_StartOfReception(destination->DestPduId, TpSduLength, bufferSizePtr);
break;
#endif
#if PDUR_CDDPDUR_SUPPORT == STD_ON
case ARC_PDUR_CDDPDUR:
retVal = CddPduR_StartOfReception(destination->DestPduId, NULL, TpSduLength, bufferSizePtr);
break;
#endif
default:
break;
}
return retVal;
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_Routing.c
|
C
|
unknown
| 16,208
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "PduR.h"
#if (PDUR_ZERO_COST_OPERATION == STD_OFF) && (PDUR_SECOC_SUPPORT == STD_ON)
// Autosar4 API
void PduR_SecOCRxIndication(PduIdType pduId, const PduInfoType* pduInfoPtr) {
/*lint -e{9005,929} exception due api parameters mismatch between calls*/
PduR_LoIfRxIndication(pduId, (PduInfoType *)pduInfoPtr, 0x71);
}
void PduR_SecOCTxConfirmation(PduIdType pduId) {
PduR_LoIfTxConfirmation(pduId, 0x72);
}
Std_ReturnType PduR_SecOCTransmit(PduIdType pduId, const PduInfoType* pduInfoPtr) {
return PduR_UpTransmit(pduId, pduInfoPtr, 0xc9);
}
Std_ReturnType PduR_SecOCCancelTransmit(PduIdType pduId) {
return PduR_UpCancelTransmit(pduId, 0xca);
}
#endif
|
2301_81045437/classic-platform
|
communication/PduR/src/PduR_SecOC.c
|
C
|
unknown
| 1,467
|