/* 转义打包 标识Flag，即包头包尾加入Flag 数据中遇到Flag -> Code F1 数据中遇到Code -> Code F2  */
uint32_t TransferPack(uint8_t Flag, uint8_t Code, uint8_t F1, uint8_t F2, uint8_t *InBuf, uint32_t Len, uint8_t *OutBuf)
/* 转义打包 标识Flag，即包头包尾加入Flag 数据中遇到Flag -> Code F1 数据中遇到Code -> Code F2  */
uint32_t TransferPack(uint8_t Flag, uint8_t Code, uint8_t F1, uint8_t F2, uint8_t *InBuf, uint32_t Len, uint8_t *OutBuf)
{
    uint32_t TxLen = 0;
    uint32_t i;
    OutBuf[0] = Flag;
    TxLen = 1;
    for (i = 0; i < Len; i++)
    {
        if (InBuf[i] == Flag)
        {
            OutBuf[TxLen++] = Code;
            OutBuf[TxLen++] = F1;
        }
        else if (InBuf[i] == Code)
        {
            OutBuf[TxLen++] = Code;
            OutBuf[TxLen++] = F2;
        }
        else
        {
            OutBuf[TxLen++] = InBuf[i];
        }
    }
    OutBuf[TxLen++] = Flag;
    return TxLen;
}