数据包的解析程序



应用数据包的解析,最后生成Logo图片,这是中间层的解析过程。

/******************************************************************************
 * ファイル名 : xm_app_proc.cpp
 * システム名 : XMパケットデコード
 * 概要  : XMパケットデコード機能
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 :
 *    :
 ******************************************************************************/
#include "xm_def.h"
#include "xm_str.h"
#include "xm_inc.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

/******************************************************************************
 * 関数名  : xm_packdec_XAPDataProc
 * 機能  : XMパケットデコード
 * 機能概要 : XAPインサイト
 * 入力  : しない
 * 出力  : しない
 * 戻り値  : しない
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
void xm_packdec_XAPDataProc(void)
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR;                                                                                       /* The return of Value */
    u_int8 ui8Spl_ERR_Mark = XM_LOGO_OFF;                                                                                        /* The special Error */

    for(g_ui16Cur_Postion = 0; g_ui16Cur_Postion <= g_stXM_LOGO_XAPData.ui16XAP_SaveIndex && XM_LOGO_OFF == ui8Spl_ERR_Mark; ++ g_ui16Cur_Postion)
    {
        while( XM_LOGO_APP_SYNC == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] )
        {
            if(g_stXM_LOGO_XAPData.ui16XAP_SaveIndex >= g_ui16Cur_Postion + XM_LOGO_APP_START_SYNCSIZE )                         /* Analyzing data head is intact APP */
            {
                ui8ERR_Mark = xm_packdec_XAPDataValidCheck();
                switch(ui8ERR_Mark)
                {
                case XM_LOGO_APPNOERR:                                                                                           /* NOエラー、OK設定 */
                case XM_LOGO_DATASIZEERR:                                                                                        /* データサイズエラー */
                case XM_LOGO_HEADCRCERR:                                                                                         /* ヘッダCRCエラー設定 */
                case XM_LOGO_DATACRCERR:                                                                                         /* データCRCエラー設定 */
                case XM_LOGO_APPIDERR:                                                                                           /* APP_IDエラー設定 */
                case XM_LOGO_APPMTERR:                                                                                           /* APP_MTエラー設定 */
                case XM_LOGO_APPSIZEERR:                                                                                         /* APPデータサイズエラー */
                    break;
                case XM_LOGO_PLOADDATAERR:                                                                                       /* PayLoadデータ不足エラー */
                    ui8Spl_ERR_Mark = XM_LOGO_ON;
                    g_stXM_LOGO_XAPData.ui8XAP_RemainDatFlg = XM_LOGO_ON;
                    break;
                case XM_LOGO_APPSEQERR:                                                                                          /* シーケンス番号エラー */
                    xm_packdec_XAPDataChange( );
                    break;
                case XM_LOGO_OVERFLOWERR:                                                                                        /* オーバーフローエラー */
                    ui8Spl_ERR_Mark = XM_LOGO_ON;
                    g_stXM_LOGO_XAPData.ui8XAP_RemainDatFlg = XM_LOGO_ON;
                    break;
                default:
                    break;
                }
                break;
            }
            else                                                                                                                 /* APP packet header is incomplete */
            {
                ui8Spl_ERR_Mark = XM_LOGO_ON;
                g_stXM_LOGO_XAPData.ui8XAP_RemainDatFlg = XM_LOGO_ON;
                break;
            }
        }
    }

    if(XM_LOGO_OFF == g_stXM_LOGO_XAPData.ui8XAP_RemainDatFlg)
    {
        _sys_memset(&g_stXM_LOGO_XAPData.ui8APP_Data[0], '\0', g_stXM_LOGO_XAPData.ui16XAP_SaveIndex);
        g_stXM_LOGO_XAPData.ui16XAP_SaveIndex = 0;
    }
    else
    {
       g_stXM_LOGO_XAPData.ui16XAP_SaveIndex -= (g_ui16Cur_Postion - 1);
       _sys_memcpy(&g_stXM_LOGO_XAPData.ui8APP_Data[0], &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion - 1],
           g_stXM_LOGO_XAPData.ui16XAP_SaveIndex);
       _sys_memset(&g_stXM_LOGO_XAPData.ui8APP_Data[g_stXM_LOGO_XAPData.ui16XAP_SaveIndex], '\0',
           XM_LOGO_XAP_BUFF_MAX - g_stXM_LOGO_XAPData.ui16XAP_SaveIndex);
    }

}

/******************************************************************************
 * 関数名  : xm_packdec_XAPDataValidCheck
 * 機能  : XMパケットデコード
 * 機能概要 : XAPのデータ検証
 * 入力  : しない
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_XAPDataValidCheck(void)
{
    u_int8 ui8ERR_Mark  = XM_LOGO_APPNOERR;
    u_int16 ui16App_Len = 0;                                                                                                     /* APP packet Length */
    u_int16 XM_LOGO_APP_DataCRC = 0;                                                                                             /* APP pack CRC value */

    ui16App_Len = XM_LOGO_8BitTo16(g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_APPLEN],
        g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_APPLEN + 1]);

    if(ui16App_Len <= XM_LOGO_XAP_DATA_MAX)
    {
        if( (ui16App_Len + g_ui16Cur_Postion + XM_LOGO_XAP_HEAD_SIZE + XM_LOGO_APP_CRC_SIZE) <= g_stXM_LOGO_XAPData.ui16XAP_SaveIndex )
        {
            if( XM_LOGO_CRC_PASS == xm_packdec_UtilCheck8Crc(&g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], XM_LOGO_APP_CRCBUF_SIZE ,
                g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_HCRC] ) )
            {
                XM_LOGO_APP_DataCRC = XM_LOGO_8BitTo16(g_stXM_LOGO_XAPData.ui8APP_Data[ui16App_Len + g_ui16Cur_Postion + XM_LOGO_XAP_HEAD_SIZE],
                    g_stXM_LOGO_XAPData.ui8APP_Data[ui16App_Len + g_ui16Cur_Postion + XM_LOGO_XAP_HEAD_SIZE + 1]);

                if( XM_LOGO_CRC_PASS == xm_packdec_UtilCheck16Crc(&g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_XAP_HEAD_SIZE],
                    ui16App_Len , XM_LOGO_APP_DataCRC ) )
                {
                    switch(g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_APPID])
                    {
                    case XM_LOGO_APP_ID70:
                        ui8ERR_Mark = xm_packdec_APP70_DataProc(ui16App_Len);
                        g_ui16Cur_Postion += (ui16App_Len + XM_LOGO_XAP_HEAD_SIZE + XM_LOGO_APP_CRC_SIZE);
                        break;
                    case XM_LOGO_APP_ID71:
                        ui8ERR_Mark = xm_packdec_APP71_DataProc(ui16App_Len);
                        g_ui16Cur_Postion += (ui16App_Len + XM_LOGO_XAP_HEAD_SIZE + XM_LOGO_APP_CRC_SIZE);
                        break;
                    default:
                        ui8ERR_Mark = XM_LOGO_APPIDERR;
                        g_ui16Cur_Postion += (ui16App_Len + XM_LOGO_XAP_HEAD_SIZE + XM_LOGO_APP_CRC_SIZE);
                        break;
                    }
                }
                else
                {
                    ui8ERR_Mark = XM_LOGO_DATACRCERR;
                }
            }
            else
            {
                ui8ERR_Mark = XM_LOGO_HEADCRCERR;
            }

        }
        else
        {
            ui8ERR_Mark = XM_LOGO_PLOADDATAERR;
        }
    }
    else
    {
        ui8ERR_Mark = XM_LOGO_APPSIZEERR;
    }

    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_XAPDataChange
 * 機能  : XMパケットデコード
 * 機能概要 : XAP空のデータ処理
 * 入力  : しない
 * 出力  : しない
 * 戻り値  : しない
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
void xm_packdec_XAPDataChange(void )
{
    _sys_memset(&g_stXM_LOGO_APP_70.ui8APP_Data[0], '\0', g_stXM_LOGO_APP_70.ui16DataIndex);                                     /* バッファエンプティでAPP70とAPP71 */
    _sys_memset(&g_stXM_LOGO_APP_71.ui8APP_Data[0], '\0', g_stXM_LOGO_APP_71.ui16DataIndex);
    _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[0], '\0', g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize);
    _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[0], '\0', g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize);

    g_stXM_LOGO_APP_70.ui16DataIndex = 0;
    g_stXM_LOGO_APP_71.ui16DataIndex = 0;
    g_stXM_LOGO_APP_70.ui8Count = 0;
    g_stXM_LOGO_APP_71.ui8Count = 0;

    g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize = 0;                                                               /* Reset flag */
    g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize = 0;
    g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
    g_stXM_LOGO_APP_Mng.ui8APP70StoreFlg = XM_LOGO_ON;
    g_stXM_LOGO_APP_Mng.ui8APP71StoreFlg = XM_LOGO_ON;
    g_ui16App_MNG_SumLen = 0;
}

/******************************************************************************
 * 関数名  : xm_packdec_APP70_DataProc
 * 機能  : XMパケットデコード
 * 機能概要 : APP70データ処理
 * 入力  : ui16App_Len:  APP長さ
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark:   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_APP70_DataProc(u_int16 ui16App_Len)
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR ;
    u_int16 ui16Per_Temp_Len = 0;                                                                                                /* previous AppTemp postion */
    u_int16 ui16Cur_Temp_Postion = 0;                                                                                            /* current AppTemp postion */
    u_int8 ui8PreSeqNum70 = g_stXM_LOGO_XAP_Mng.ui8SeqNum70 + 1;                                                                 /* previous 70 SeqNumber */
    u_int8 XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_UNEQUAL;                                                                             /* SYNC一致しない */
    u_int16 ui16APP_Cur_Postion = g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_APPDATA;                                                /* Payload position in point APP */

    if(g_stXM_LOGO_APP_Mng.ui8BufEndFlg == XM_LOGO_OFF )
    {
        if(0 == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize)
        {
           XM_LOGO_SYNC_TYPE = xm_packdec_Xap70HeadExplore(ui16APP_Cur_Postion, ui16App_Len);

           if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_EQUAL)
           {
               ui8ERR_Mark = xm_packdec_70XAPHeadEqualProc( ui16APP_Cur_Postion, ui16App_Len);
           }
           else if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_PARTEQUAL)
           {
               _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
                   &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion) );
               g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
           }

        }

        else
        {
            if(ui8PreSeqNum70 == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_70_SEQ])
            {
                ui16Per_Temp_Len = g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize;
                _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
                   &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion], ui16App_Len );
                g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize +=  ui16App_Len;
                XM_LOGO_SYNC_TYPE = xm_packdec_Xap70HeadExploreTemp(ui16Cur_Temp_Postion);

                g_ui16Cur_Postion += (ui16Cur_Temp_Postion - ui16Per_Temp_Len);                                                   /* Resolves to the current position */

                if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_EQUAL)
                {
                    ui8ERR_Mark = xm_packdec_70XAPHeadEqualProcTemp(ui16Cur_Temp_Postion, ui16APP_Cur_Postion);
                }
                else if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_PARTEQUAL)
                {
                    g_stXM_LOGO_XAP_Mng.ui8SeqNum70 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
                        &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion) );
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
                }

            }

            else
            {
                _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX], '\0', g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize);
                g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize = 0;
                XM_LOGO_SYNC_TYPE = xm_packdec_Xap70HeadExplore(ui16APP_Cur_Postion, ui16App_Len);

                if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_EQUAL)
                {
                   ui8ERR_Mark = xm_packdec_70XAPHeadEqualProc( ui16APP_Cur_Postion, ui16App_Len);
                }
                else if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_PARTEQUAL)
                {
                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
                        &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion));
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
                }

            }

        }
    }

    else
    {
        if( ui8PreSeqNum70 == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_SEQ] )
        {
            g_stXM_LOGO_XAP_Mng.ui8SeqNum70 = g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_SEQ];

            if(g_ui16App_MNG_SumLen > ui16App_Len )
            {
                _sys_memcpy(&g_stXM_LOGO_APP_70.ui8APP_Data[g_stXM_LOGO_APP_70.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion],
                    ui16App_Len );
                g_stXM_LOGO_APP_70.ui16DataSize = ui16App_Len;
                g_stXM_LOGO_APP_70.ui16DataIndex += g_stXM_LOGO_APP_70.ui16DataSize;
                g_ui16App_MNG_SumLen -= ui16App_Len;
            }
            else
            {
                _sys_memcpy(&g_stXM_LOGO_APP_70.ui8APP_Data[g_stXM_LOGO_APP_70.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion],
                    g_ui16App_MNG_SumLen);
                g_stXM_LOGO_APP_70.ui16DataSize = g_ui16App_MNG_SumLen;
                g_stXM_LOGO_APP_70.ui16DataIndex += g_stXM_LOGO_APP_70.ui16DataSize;
                g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
                g_stXM_LOGO_APP_Mng.ui8APP70StoreFlg = XM_LOGO_OFF;
                g_stXM_LOGO_APP_70.ui8Count ++;
                u_int16 APPTemp_Len_ADD = ui16App_Len - g_ui16App_MNG_SumLen;

                _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
                    &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion + g_ui16App_MNG_SumLen], APPTemp_Len_ADD);
                g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize += APPTemp_Len_ADD;
                g_ui16App_MNG_SumLen = 0;
            }

        }
        else
        {
            ui8ERR_Mark = XM_LOGO_APPSEQERR;
        }

    }
    g_ui16Cur_Postion = ui16APP_Cur_Postion - XM_LOGO_OFFSET_XAP_APPDATA;
    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_70XAPHeadEqualProc
 * 機能  : XMパケットデコード
 * 機能概要 : 70ヘッダ平等な待遇
 * 入力  : ui16APP_Cur_Postion:   APP現在の場所  ui16App_Len:  APP長さ
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_70XAPHeadEqualProc( u_int16 ui16APP_Cur_Postion, u_int16 ui16App_Len )
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR ;
    u_int16 ui16App_MNG_Len = 0;

    if(ui16App_Len + ui16APP_Cur_Postion >= g_ui16Cur_Postion + XM_LOGO_OFFSET_70_MT)
    {
        if(0 == g_ui16App_MNG_SumLen)
        {
            ui16App_MNG_Len = XM_LOGO_8BitTo16(g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_APP_MPLEN],
                g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_APP_MPLEN + 1]);
        }

        if(ui16App_MNG_Len > 0 && ui16App_MNG_Len < 0xffff)
        {
            if( XM_LOGO_109_ORIG_MT == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_70_MT] ||
                XM_LOGO_109_ALT_MT == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_70_MT])
            {
                g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_ON;
                g_stXM_LOGO_XAP_Mng.ui8SeqNum70 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
                g_ui16App_MNG_SumLen = ui16App_MNG_Len + XM_LOGO_LOGODATA_HEADSIZE + XM_LOGO_APP_CRC_SIZE;

                if(g_ui16App_MNG_SumLen > (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion))
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_70.ui8APP_Data[g_stXM_LOGO_APP_70.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion],
                        (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion) );
                    g_stXM_LOGO_APP_70.ui16DataSize = (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion);
                    g_stXM_LOGO_APP_70.ui16DataIndex += g_stXM_LOGO_APP_70.ui16DataSize;
                    g_ui16App_MNG_SumLen -= (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion);
                }
                else
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_70.ui8APP_Data[g_stXM_LOGO_APP_70.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion],
                        g_ui16App_MNG_SumLen);
                    g_stXM_LOGO_APP_70.ui16DataSize = g_ui16App_MNG_SumLen;
                    g_stXM_LOGO_APP_70.ui16DataIndex += g_stXM_LOGO_APP_70.ui16DataSize;
                    g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_Mng.ui8APP70StoreFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_70.ui8Count ++;
                    u_int16 APPTemp_Len_ADD = (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion) - g_ui16App_MNG_SumLen;

                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
                        &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + g_ui16App_MNG_SumLen], APPTemp_Len_ADD);
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize += APPTemp_Len_ADD;
                    g_ui16App_MNG_SumLen = 0;
                }

            }
            else
            {
                ui8ERR_Mark = XM_LOGO_APPMTERR;
            }

        }
        else
        {
            ui8ERR_Mark = XM_LOGO_APPSIZEERR;
        }

    }
    else
    {
        _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
            &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion], (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion) );
        g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize += (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion);
        g_stXM_LOGO_XAP_Mng.ui8SeqNum70 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
    }

    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_70XAPHeadEqualProcTemp
 * 機能  : XMパケットデコード
 * 機能概要 :70一時的なキャッシュヘッダ平等な待遇
 * 入力  : ui16Cur_Temp_Postion:   APPTemp現在の場所  ui16APP_Cur_Postion:  APP現在の場所
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_70XAPHeadEqualProcTemp(u_int16 ui16Cur_Temp_Postion, u_int16 ui16APP_Cur_Postion)
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR ;
    u_int16 ui16App_MNG_Len = 0;

    if ( g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize > ui16Cur_Temp_Postion + XM_LOGO_OFFSET_70_MT)
    {
        if(0 == g_ui16App_MNG_SumLen)
        {
            ui16App_MNG_Len = XM_LOGO_8BitTo16(g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_APP_MPLEN],
                g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_APP_MPLEN + 1]);
        }

        if (ui16App_MNG_Len > 0 && ui16App_MNG_Len <= 0xffff)
        {
            if (XM_LOGO_109_ORIG_MT == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_70_MT] ||
                XM_LOGO_109_ALT_MT == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_70_MT] )
            {
                g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_ON;
                g_stXM_LOGO_XAP_Mng.ui8SeqNum70 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
                g_ui16App_MNG_SumLen = ui16App_MNG_Len + XM_LOGO_LOGODATA_HEADSIZE + XM_LOGO_APP_CRC_SIZE;

                if (g_ui16App_MNG_SumLen > (g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion) )
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_70.ui8APP_Data[g_stXM_LOGO_APP_70.ui16DataIndex],
                        &g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion],
                        (g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion) );
                    g_stXM_LOGO_APP_70.ui16DataSize = (g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion);
                    g_stXM_LOGO_APP_70.ui16DataIndex += g_stXM_LOGO_APP_70.ui16DataSize;
                    g_ui16App_MNG_SumLen -= (g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion);
                }
                else
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_70.ui16DataIndex],
                        &g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion],
                        g_ui16App_MNG_SumLen);
                    g_stXM_LOGO_APP_70.ui16DataSize = g_ui16App_MNG_SumLen;
                    g_stXM_LOGO_APP_70.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                    g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_Mng.ui8APP70StoreFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_70.ui8Count ++;
                    u_int16 APPTemp_Len_ADD = (g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion) - g_ui16App_MNG_SumLen;

                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[0],
                        &g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion], APPTemp_Len_ADD);
                    _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[APPTemp_Len_ADD], '\0',
                        g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - APPTemp_Len_ADD);
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize = APPTemp_Len_ADD;
                    g_ui16App_MNG_SumLen = 0;
                }

            }
            else
            {
                ui8ERR_Mark = XM_LOGO_APPMTERR;
            }

        }

        else
        {
            ui8ERR_Mark = XM_LOGO_APPSIZEERR;
        }

    }

    else
    {
        _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[0],
            &g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion],
            g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion);

        g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize -= ui16Cur_Temp_Postion;

        _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize],
            '\0', ui16Cur_Temp_Postion);
        g_stXM_LOGO_XAP_Mng.ui8SeqNum70 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
    }

    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_Xap70HeadExplore
 * 機能  : XMパケットデコード
 * 機能概要 : 70ヘッダ探査
 * 入力  : ui16APP_Cur_Postion:   APP現在の場所  ui16App_Len:  APP長さ
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_Xap70HeadExplore(u_int16 ui16APP_Cur_Postion, u_int16 ui16App_Len)
{
    u_int8 XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_UNEQUAL ;                                                                            /* SYNC一致しない */

    while( ('$' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && g_ui16Cur_Postion != ui16APP_Cur_Postion + ui16App_Len) )
    {
        ++ g_ui16Cur_Postion;
    }

    for ( ; g_ui16Cur_Postion != ui16APP_Cur_Postion + ui16App_Len; ++ g_ui16Cur_Postion)
    {
        if( strstr( (int8*)&g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (int8*)g_ui8XM_APPStartSyncWord) != NULL )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_EQUAL;                                                                              /* SYNC完全一致 */
            break;
        }
        else if( '$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            'M' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 2] && 'M' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 3] &&
            'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 4] && g_ui16Cur_Postion + 4 == (ui16APP_Cur_Postion + ui16App_Len))
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;                                                                          /* SYNC部分一致 */
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            'M' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 2] && 'M' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 3] &&
            g_ui16Cur_Postion + 3 == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            'M' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 2] && g_ui16Cur_Postion + 2 == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            g_ui16Cur_Postion + 1 == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && g_ui16Cur_Postion == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
    }
    return XM_LOGO_SYNC_TYPE;
}

/******************************************************************************
 * 関数名  : xm_packdec_Xap70HeadExploreTemp
 * 機能  : XMパケットデコード
 * 機能概要 : キャッシュヘッダが70を探索
 * 入力  : ui16Cur_Temp_Postion:   APPTemp現在の場所
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_Xap70HeadExploreTemp(u_int16 &ui16Cur_Temp_Postion )
{
    u_int8 XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_UNEQUAL ;                                                                            /* SYNC一致しない */

    while( ('$' != g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
        ui16Cur_Temp_Postion != g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize) )
    {
        ++ ui16Cur_Temp_Postion;
    }

    for ( ; ui16Cur_Temp_Postion != g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize; ++ ui16Cur_Temp_Postion)
    {
        if( strstr( (int8*)&g_stXM_LOGO_XAPData.ui8APP_Data[ui16Cur_Temp_Postion], (int8*)g_ui8XM_APPStartSyncWord) != NULL )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_EQUAL;                                                                              /* SYNC完全一致 */
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            'M' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 2] &&
            'M' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 3] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 4] &&
            ui16Cur_Temp_Postion + 4 == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;                                                                          /* SYNC部分一致 */
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            'M' != g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 2] &&
            'M' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 3] &&
            ui16Cur_Temp_Postion + 3 == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            'M' != g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 2] &&
            ui16Cur_Temp_Postion + 2 == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            ui16Cur_Temp_Postion + 1 == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            g_ui16Cur_Postion == g_stXM_LOGO_APPTemp[XM_LOGO_APP70TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
    }
    return XM_LOGO_SYNC_TYPE;
}



/******************************************************************************
 * 関数名  : xm_packdec_APP71_DataProc
 * 機能  : XMパケットデコード
 * 機能概要 : 71データ処理
 * 入力  : ui16App_Len:  APP長さ
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark:   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_APP71_DataProc(u_int16 ui16App_Len )
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR ;
    u_int16 ui16Per_Temp_Len = 0;                                                                                                /* previous AppTemp postion */
    u_int16 ui16Cur_Temp_Postion = 0;                                                                                            /* current AppTemp postion */
    u_int8 ui8PreSeqNum71 = g_stXM_LOGO_XAP_Mng.ui8SeqNum71 + 1;                                                                 /* previous 71 SeqNumber */
    u_int8 XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_UNEQUAL;                                                                             /* SYNC一致しない */
    u_int16 ui16APP_Cur_Postion = g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_APPDATA;                                                /* Payload position in point APP */

    if(g_stXM_LOGO_APP_Mng.ui8BufEndFlg == XM_LOGO_OFF )
    {
        if(0 == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize )
        {
           XM_LOGO_SYNC_TYPE = xm_packdec_Xap71HeadExplore(ui16APP_Cur_Postion, ui16App_Len);

           if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_EQUAL)
           {
               ui8ERR_Mark = xm_packdec_71XAPHeadEqualProc( ui16APP_Cur_Postion, ui16App_Len);
           }
           else if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_PARTEQUAL)
           {
               _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
                   &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion) );
               g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
           }

        }

        else
        {
            if(ui8PreSeqNum71 == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_71_SEQ])
            {
                ui16Per_Temp_Len = g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize;
                _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
                   &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion], ui16App_Len );
                g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
                XM_LOGO_SYNC_TYPE = xm_packdec_Xap71HeadExploreTemp(ui16Cur_Temp_Postion);

                g_ui16Cur_Postion += (ui16Cur_Temp_Postion - ui16Per_Temp_Len);                                                  /* Resolves to the current position */

                if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_EQUAL)
                {
                    ui8ERR_Mark = xm_packdec_71XAPHeadEqualProcTemp(ui16Cur_Temp_Postion, ui16APP_Cur_Postion);
                }
                else if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_PARTEQUAL)
                {
                    g_stXM_LOGO_XAP_Mng.ui8SeqNum71 =
                        g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - XM_LOGO_OFFSET_XAP_APPDATA + XM_LOGO_OFFSET_71_SEQ];
                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
                        &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion) );
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
                }

            }
            else
            {
                _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX], '\0', g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize);
                g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize = 0;
                XM_LOGO_SYNC_TYPE = xm_packdec_Xap71HeadExplore(ui16APP_Cur_Postion, ui16App_Len);

                if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_EQUAL)
                {
                   ui8ERR_Mark = xm_packdec_71XAPHeadEqualProc( ui16APP_Cur_Postion, ui16App_Len);
                }

                else if(XM_LOGO_SYNC_TYPE == XM_LOGO_SYNC_PARTEQUAL)
                {
                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
                        &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion));
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += (ui16APP_Cur_Postion + ui16App_Len - g_ui16Cur_Postion);
                }

            }

        }

    }

    else
    {
        if(ui8PreSeqNum71 == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_SEQ])
        {
            g_stXM_LOGO_XAP_Mng.ui8SeqNum71 = g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_XAP_SEQ];

            if(g_ui16App_MNG_SumLen > ui16App_Len )
            {
                _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_71.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion],
                    ui16App_Len );
                g_stXM_LOGO_APP_71.ui16DataSize = ui16App_Len;
                g_stXM_LOGO_APP_71.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                g_ui16App_MNG_SumLen -= ui16App_Len;
            }
            else
            {
                _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_71.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion],
                    g_ui16App_MNG_SumLen);
                g_stXM_LOGO_APP_71.ui16DataSize = g_ui16App_MNG_SumLen;
                g_stXM_LOGO_APP_71.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
                g_stXM_LOGO_APP_Mng.ui8APP71StoreFlg = XM_LOGO_OFF;
                g_stXM_LOGO_APP_71.ui8Count ++;
                u_int16 APPTemp_Len_ADD = ui16App_Len - g_ui16App_MNG_SumLen;

                _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
                    &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion + g_ui16App_MNG_SumLen], APPTemp_Len_ADD);
                g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += APPTemp_Len_ADD;
                g_ui16App_MNG_SumLen = 0;
            }
        }
        else
        {
            ui8ERR_Mark = XM_LOGO_APPSEQERR;
        }
    }
    g_ui16Cur_Postion = ui16APP_Cur_Postion - XM_LOGO_OFFSET_XAP_APPDATA;
    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_71XAPHeadEqualProc
 * 機能  : XMパケットデコード
 * 機能概要 : 71ヘッダ平等な待遇
 * 入力  : ui16APP_Cur_Postion:   APP現在の場所  ui16App_Len:  APP長さ
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_71XAPHeadEqualProc( u_int16 ui16APP_Cur_Postion, u_int16 ui16App_Len )
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR;
    u_int16 ui16App_MNG_Len = 0;

    if(ui16App_Len + ui16APP_Cur_Postion >= g_ui16Cur_Postion + XM_LOGO_OFFSET_71_MT)
    {
        if(0 == g_ui16App_MNG_SumLen)
        {
            ui16App_MNG_Len = XM_LOGO_8BitTo16(g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_APP_MPLEN],
                g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_APP_MPLEN + 1]);
        }

        if(ui16App_MNG_Len > 0 && ui16App_MNG_Len <= 0xffff)
        {
            if( XM_LOGO_102_ORIG_MT == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_71_MT] ||
                XM_LOGO_102_ALT_MT == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_71_MT]  ||
                XM_LOGO_108_ORIG_MT == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_71_MT] ||
                XM_LOGO_108_ALT_MT == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + XM_LOGO_OFFSET_71_MT] )
            {
                g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_ON;
                g_stXM_LOGO_XAP_Mng.ui8SeqNum71 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
                g_ui16App_MNG_SumLen = ui16App_MNG_Len + XM_LOGO_LOGODATA_HEADSIZE + XM_LOGO_APP_CRC_SIZE;

                if(g_ui16App_MNG_SumLen > (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion))
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_71.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion],
                        (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion) );
                    g_stXM_LOGO_APP_71.ui16DataSize = (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion);
                    g_stXM_LOGO_APP_71.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                    g_ui16App_MNG_SumLen -= (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion);
                }
                else
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_71.ui16DataIndex], &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion],
                        g_ui16App_MNG_SumLen);
                    g_stXM_LOGO_APP_71.ui16DataSize = g_ui16App_MNG_SumLen;
                    g_stXM_LOGO_APP_71.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                    g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_Mng.ui8APP71StoreFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_71.ui8Count ++;
                    u_int16 APPTemp_Len_ADD = (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion) - g_ui16App_MNG_SumLen;

                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
                        &g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + g_ui16App_MNG_SumLen], APPTemp_Len_ADD);
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += APPTemp_Len_ADD;
                    g_ui16App_MNG_SumLen = 0;
                }
            }
            else
            {
                ui8ERR_Mark = XM_LOGO_APPMTERR;
            }

        }
        else
        {
            ui8ERR_Mark = XM_LOGO_APPSIZEERR;
        }
    }
    else
    {
        _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
            &g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion], (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion) );
        g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize += (ui16App_Len + ui16APP_Cur_Postion - g_ui16Cur_Postion);
        g_stXM_LOGO_XAP_Mng.ui8SeqNum71 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
    }
    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_71XAPHeadEqualProcTemp
 * 機能  : XMパケットデコード
 * 機能概要 : 71一時的なキャッシュヘッダ平等な待遇
 * 入力  : ui16Cur_Temp_Postion:   APPTemp現在の場所  ui16APP_Cur_Postion:  APP現在の場所
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_71XAPHeadEqualProcTemp(u_int16 ui16Cur_Temp_Postion, u_int16 ui16APP_Cur_Postion)
{
    u_int8 ui8ERR_Mark = XM_LOGO_APPNOERR ;
    u_int16 ui16App_MNG_Len = 0;

    if ( g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize > ui16Cur_Temp_Postion + XM_LOGO_OFFSET_71_MT)
    {
        if(0 == g_ui16App_MNG_SumLen)
        {
            ui16App_MNG_Len = XM_LOGO_8BitTo16(g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_APP_MPLEN],
                g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_APP_MPLEN + 1]);
        }

        if (ui16App_MNG_Len > 0 && ui16App_MNG_Len <= 0xffff)
        {
            if (XM_LOGO_102_ORIG_MT == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_71_MT] ||
                XM_LOGO_102_ALT_MT == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_71_MT]  ||
                XM_LOGO_108_ORIG_MT == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_71_MT] ||
                XM_LOGO_108_ALT_MT == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + XM_LOGO_OFFSET_71_MT])
            {
                g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_ON;
                g_stXM_LOGO_XAP_Mng.ui8SeqNum71 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
                g_ui16App_MNG_SumLen = ui16App_MNG_Len + XM_LOGO_LOGODATA_HEADSIZE + XM_LOGO_APP_CRC_SIZE;

                if (g_ui16App_MNG_SumLen > (g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion) )
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_71.ui16DataIndex],
                        &g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion],
                        (g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion) );
                    g_stXM_LOGO_APP_71.ui16DataSize = (g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion);
                    g_stXM_LOGO_APP_71.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                    g_ui16App_MNG_SumLen -= (g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion);
                }
                else
                {
                    _sys_memcpy(&g_stXM_LOGO_APP_71.ui8APP_Data[g_stXM_LOGO_APP_71.ui16DataIndex],
                        &g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion],
                        g_ui16App_MNG_SumLen);
                    g_stXM_LOGO_APP_71.ui16DataSize = g_ui16App_MNG_SumLen;
                    g_stXM_LOGO_APP_71.ui16DataIndex += g_stXM_LOGO_APP_71.ui16DataSize;
                    g_stXM_LOGO_APP_Mng.ui8BufEndFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_Mng.ui8APP71StoreFlg = XM_LOGO_OFF;
                    g_stXM_LOGO_APP_71.ui8Count ++;
                    u_int16 APPTemp_Len_ADD = (g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion) - g_ui16App_MNG_SumLen;

                    _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[0], \
                        &g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion], APPTemp_Len_ADD);
                    _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[APPTemp_Len_ADD], '\0',
                        g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - APPTemp_Len_ADD);
                    g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize = APPTemp_Len_ADD;
                    g_ui16App_MNG_SumLen = 0;
                }

            }
            else
            {
                ui8ERR_Mark = XM_LOGO_APPMTERR;
            }

        }
        else
        {
            ui8ERR_Mark = XM_LOGO_APPSIZEERR;
        }
    }
    else
    {
        _sys_memcpy(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[0],
            &g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion],
            g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize - ui16Cur_Temp_Postion);

        g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize -= ui16Cur_Temp_Postion;

        _sys_memset(&g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize],
            '\0', ui16Cur_Temp_Postion);
        g_stXM_LOGO_XAP_Mng.ui8SeqNum71 = g_stXM_LOGO_XAPData.ui8APP_Data[ui16APP_Cur_Postion - 2];
    }

    return ui8ERR_Mark;
}

/******************************************************************************
 * 関数名  : xm_packdec_Xap71HeadExplore
 * 機能  : XMパケットデコード
 * 機能概要 : 71ヘッダ探査
 * 入力  : ui16APP_Cur_Postion:   APP現在の場所  ui16App_Len:  APP長さ
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_Xap71HeadExplore(u_int16 ui16APP_Cur_Postion, u_int16 ui16App_Len)
{
    u_int8 XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_UNEQUAL ;

    while( ('$' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && g_ui16Cur_Postion != ui16APP_Cur_Postion + ui16App_Len) )
    {
        ++ g_ui16Cur_Postion;
    }

    for ( ; g_ui16Cur_Postion != ui16APP_Cur_Postion + ui16App_Len; ++ g_ui16Cur_Postion)
    {
        if( strstr( (int8*)&g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion], (int8*)g_ui8XM_APPStartSyncWord) != NULL )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_EQUAL;                                                                              /* SYNC完全一致 */
            break;
        }
        else if( '$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            'M' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 2] && 'M' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 3] &&
            'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 4] && g_ui16Cur_Postion + 4 == (ui16APP_Cur_Postion + ui16App_Len))
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;                                                                          /* SYNC部分一致 */
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            'M' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 2] && 'M' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 3] &&
            g_ui16Cur_Postion + 3 == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            'M' != g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 2] && g_ui16Cur_Postion + 2 == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && 'X' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion + 1] &&
            g_ui16Cur_Postion + 1 == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_XAPData.ui8APP_Data[g_ui16Cur_Postion] && g_ui16Cur_Postion == (ui16APP_Cur_Postion + ui16App_Len) )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
    }
    return XM_LOGO_SYNC_TYPE;
}

/******************************************************************************
 * 関数名  : xm_packdec_Xap71HeadExploreTemp
 * 機能  : XMパケットデコード
 * 機能概要 : キャッシュヘッダが71を探索
 * 入力  : ui16Cur_Temp_Postion:   APPTemp現在の場所
 * 出力  : なし
 * 戻り値  : ui8ERR_Mark :   エラータイプ
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_Xap71HeadExploreTemp(u_int16 &ui16Cur_Temp_Postion )
{
    u_int8 XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_UNEQUAL ;                                                                            /* SYNC一致しない */

    while( ('$' != g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
        ui16Cur_Temp_Postion != g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize) )
    {
        ++ ui16Cur_Temp_Postion;
    }

    for ( ; ui16Cur_Temp_Postion != g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize; ++ ui16Cur_Temp_Postion)
    {
        if( strstr( (int8*)&g_stXM_LOGO_XAPData.ui8APP_Data[ui16Cur_Temp_Postion], (int8*)g_ui8XM_APPStartSyncWord) != NULL )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_EQUAL;                                                                              /* SYNC完全一致 */
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            'M' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 2] &&
            'M' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 3] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 4] &&
            ui16Cur_Temp_Postion + 4 == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;                                                                          /* SYNC部分一致 */
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            'M' != g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 2] &&
            'M' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 3] &&
            ui16Cur_Temp_Postion + 3 == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            'M' != g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 2] &&
            ui16Cur_Temp_Postion + 2 == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            'X' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion + 1] &&
            ui16Cur_Temp_Postion + 1 == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
        else if('$' == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui8TempAppData[ui16Cur_Temp_Postion] &&
            ui16Cur_Temp_Postion == g_stXM_LOGO_APPTemp[XM_LOGO_APP71TEMP_INDEX].ui16DataSize )
        {
            XM_LOGO_SYNC_TYPE = XM_LOGO_SYNC_PARTEQUAL;
            break;
        }
    }
    return XM_LOGO_SYNC_TYPE;
}

/******************************************************************************
 * 関数名  : xm_packdec_UtilCheck8Crc
 * 機能  : CRCチェックサム
 * 機能概要 : 8ビットのCRCチェックサム機能
 * 入力  : pcrc_buffer_ptr, ui16crc_buffer_size, ui8rx_crc
 * 出力  : なし
 * 戻り値  : ui8status :   NG/OK
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_UtilCheck8Crc(u_int8 *pcrc_buffer_ptr, u_int16 ui16crc_buffer_size, u_int8 ui8rx_crc)
{
    u_int8 ui8status;
    u_int16 ui16cal_crc;
    ui8status = XM_LOGO_CRC_FAIL;
    /* get the calculated CRC */
    ui16cal_crc = xm_packdec_UtilCal16Crc(pcrc_buffer_ptr, ui16crc_buffer_size);
    /* does the crc match ? */
    if(ui8rx_crc == (u_int8) ui16cal_crc)
    {
        ui8status = XM_LOGO_CRC_PASS;
    }
    return ui8status;
}

/******************************************************************************
 * 関数名  : xm_packdec_UtilCheck16Crc
 * 機能  : CRCチェックサム
 * 機能概要 : 16ビットのCRCチェックサム機能
 * 入力  : pcrc_buffer_ptr, ui16crc_buffer_size, ui16rx_crc
 * 出力  : なし
 * 戻り値  : ui8status :   NG/OK
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int8 xm_packdec_UtilCheck16Crc(u_int8 *pcrc_buffer_ptr, u_int16 ui16crc_buffer_size, u_int16 ui16rx_crc)
{
    u_int8 ui8status;
    u_int16 ui16cal_crc;
    ui8status = XM_LOGO_CRC_FAIL;
    /* get the calculated CRC */
    ui16cal_crc = xm_packdec_UtilCal16Crc(pcrc_buffer_ptr, ui16crc_buffer_size);
    if(ui16rx_crc == ui16cal_crc)
    {
        ui8status = XM_LOGO_CRC_PASS;
    }
    return ui8status;
}

/******************************************************************************
 * 関数名  : xm_packdec_UtilCal16Crc
 * 機能  : CRCチェックサム
 * 機能概要 : CRCチェックサム機能
 * 入力  : pdata_ptr, ui16data_size
 * 出力  : なし
 * 戻り値  : ui16remainder
 * 作成者  : KAC/王
 * 作成日  : 2015.10.20
 * 改版履歴 : 2015.11.5
 * 備考  :
 ******************************************************************************/
u_int16 xm_packdec_UtilCal16Crc(u_int8 *pdata_ptr, u_int16 ui16data_size)
{
    u_int8 ui8data;
    u_int16 ui16remainder;
    u_int16 ui16byte;
    ui16remainder = XM_LOGO_CRC_INITIAL_REMAINDER;
    /* Divide the message by the polynomial, a byte at a time */
    for(ui16byte = 0; ui16byte < ui16data_size; ++ui16byte)
    {
        ui8data = (*pdata_ptr) ^ (ui16remainder >> (XM_LOGO_CRC_WIDTH - 8));
        ui16remainder = g_ui16XM_Crc_table[ui8data] ^ (ui16remainder << 8);
        pdata_ptr++;
    }
    /* The final remainder is the CRC */
    ui16remainder = (ui16remainder ^ XM_LOGO_CRC_FINAL_XOR_VALUE);
    return ui16remainder;
}

你可能感兴趣的:(图片,C语言,应用)