/**
* @file SFM_package.h
* @brief Safe Function Module:分帧协议实现
* @details
* 2x2上电初始化：初始化、上电同步、比较
* 输入阶段和输出阶段的双机热备处理
* @author GT-BU
* @date 2021.02.20
* @version V1.0
* @copyright TCT
* @par 修改日志
* <table>
* <tr><th>Date        <th>Version  <th>Author     <th>Description
* <tr><td>2021.02.01  <td>V1.0     <td>GT-BU      <td>创建初始版本
* </table>
*/
#ifndef SFM_PACKAGE_H
#define SFM_PACKAGE_H
#include "CM_Types.h"
#include "SFM_Prtcl.h"

/** 分帧接收控制 */
typedef struct
{
    CM_UINT8 type;        /**< 帧类型 */
    CM_UINT16 FrameNum;   /**< 帧数目 */
    CM_UINT16 FramIndex;  /**< 帧序号 */
    CM_INT32 RxLen;       /**< 接收总长度 */
    CM_UINT16 err_cut;    /** 丢包次数*/
    CM_UINT32 err_cyc;		/** 丢包周期号*/
}STRU_FrameCtrl_T;

extern CM_UINT8 g_2x2oo2_Frame_TempBuf[SFM_OUTNETSAFE_BUFF_SIZE];
/* 分帧接收 */
ENUM_CM_RETURN SFM_FrameSave(INOUT STRU_FrameCtrl_T *pCtrl, IN CM_UINT8 type,
    IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen,
    INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize);
/* 2x分帧接收 */
ENUM_CM_RETURN SFM_2X_FrameSave(INOUT STRU_FrameCtrl_T *pCtrl, IN CM_UINT8 type,
    IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen,
    INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize);
/* 应用分帧接收 */
ENUM_CM_RETURN SFM_FrameSave_App(INOUT STRU_FrameCtrl_T *pCtrl, 
    IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, 
    INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize);

#endif
