📄 fvmi05common.c
字号:
#define ACCESS_RIGHTS_INTERNAL_FVMI#define FVMI05COMMON_C#include "fVmi.h"#undef FILE_NUMBER#define FILE_NUMBER 05#ifdef FSS_FTR/******************************************************************************** This procedure is used to send message to FVM and wait answer from FVM.*******************************************************************************/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 1void fVmi05_01SendMsgAndWaitAnswer(t_SendInfo * pp_SendInfo, t_AnswerInfo * pp_AnswerInfo){ t_GenericType * pl_Msg = (t_GenericType *) pp_SendInfo->p_MsgAddress; /* Get the current task number from kernel */ u8 vl_CurrentTaskNo = MC_RTK_CURRENT_TASK; /* Point the task info table */ t_TaskInfo * pl_TaskInfo = &a_TaskInfo[vl_CurrentTaskNo]; /* Place command ID in request message */ pl_Msg->v_CmdId = vl_CurrentTaskNo; /* Send message to FVM (ex-FMM) */ MC_RTK_SEND_MSG_TO_PROCESS(PROCESS_FVMI, 0, PROCESS_FMM, 0, pp_SendInfo->v_OpType, pp_SendInfo->p_MsgAddress); /* Put task in suspended state */ MC_RTK_WAIT_EVENTS(1<<FVMI_ANSWER_MESSAGE_EVENT); MC_RTK_CLEAR_EVENTS(1<<FVMI_ANSWER_MESSAGE_EVENT); /* Load message address in table */ pl_Msg = (t_GenericType *) pl_TaskInfo->p_MsgAddress; pp_AnswerInfo->p_MsgAddress = (t_MsgHeader *) pl_Msg; /* Answer message treatment */ switch (MC_PCC_GET_TYPE(pl_Msg->s_MsgHeader.v_OperationType)) { case PCC_T_CNF : /* Sent message is ok: set status to OK */ pp_AnswerInfo->v_Status = FS_OK; break; case PCC_T_ERR : /* Sent message is ko: update status or generate an exception */ pp_AnswerInfo->v_Status = fVmi12_02ErrorTranslation(pl_Msg->v_ErrorCode); break; default : /* Answer message abnormal: generate an exception */ FVMI_EXCPTHANDLER(FVMI_BLOCKED, FVMI_EXCPT_BAD_ANSWER_MSG); }}#endif /* FSS_FTR *//******************************************************************************** This procedure corresponds to C function process. It is called from the* process runner at every message received by the FVMI process.*******************************************************************************/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 2u32 fVmi05_02FssFvmInterfaceProcess(t_RtkObject * pp_Object){#ifdef FSS_FTR t_MsgHeader * pl_Msg; u16 vl_CommandID; /* Verify if received object is a message */ if (pp_Object->v_TypeOfObj != RTK_OBJ_MESSAGE) { FVMI_EXCPTHANDLER(FVMI_BLOCKED, FVMI_EXCPT_OBJECT_IS_NOT_MSG); } /* Load message address */ pl_Msg = pp_Object->u_ReceivedObj.p_MessageAddress; /* Verify that emitter is FVM (ex-FMM) */ if (pl_Msg->s_Transmitter != PROCESS_FMM) { FVMI_EXCPTHANDLER(FVMI_BLOCKED, FVMI_EXCPT_BAD_MSG_SENDER); } /* Load command ID in message */ vl_CommandID = ((t_GenericType *) pl_Msg)->v_CmdId; /* Verify that command ID is less than max number of tasks in application */ if (vl_CommandID >= RTK_INIT_TASK_NB) { FVMI_EXCPTHANDLER(FVMI_BLOCKED, FVMI_EXCPT_BAD_TASK_NB); } /* Place address of received message in task table */ a_TaskInfo[vl_CommandID].p_MsgAddress = pl_Msg; /* Link memory block of the received message */ MC_RTK_LINK_MEMORY(pl_Msg); /* Resume suspended task which is waiting answer */ MC_RTK_SET_EVENT(vl_CommandID, FVMI_ANSWER_MESSAGE_EVENT);#endif /* FSS_FTR */ return (NIL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -