/*
*========================================================================
*
*   SYSTEM   : AZN_PLAZA_LANE BACKGROUND
*   FILE     : tagbl_packet_chng.c
*   Progrmer : JBY (baarong@neighbor21.co.kr)
*   Date     : 2018.07.13
*   Modified :
*   Remark   : Back Ground Big Data Send
*
*========================================================================
*/

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <termio.h>
#include <strings.h>
#include <sys/msg.h>
#include <sys/ipc.h>

#include "snd_rcv_knd.h"
#include "lo_ctrl.h"
#include "lo_packet_format.h"
#include "hi_packet_format.h"
#include "file_lb.h"
#include "func_list.h"
#include "lo_typ_chg_def.h"
#include "lb_func_list.h"

/*
 *========================================================================
 *
 *   Function : tcrdbl_hd_packet_chng()
 *   Progrmer : JBY (baarong@neighbor21.co.kr)
 *   Date     : 2019.06.18
 *   Modified :
 *   Remark   : TABLE DATA(Plaza -> Lane) 교통카드 B/L
 *
 *========================================================================
*/
int tcrdbl_hd_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_bl_tbl_h   *hbth;     /* TAG B/L-H    */
    struct    bl_tbl_h      *lbth;
    
    hbth = (struct hi_bl_tbl_h *)h_buf;
    lbth = (struct bl_tbl_h    *)l_buf;

    sscanf((const char *)hbth->seq_no  , "%2hhx", &lbth->seq_no[0]);
    sscanf((const char *)hbth->seq_no+2, "%2hhx", &lbth->seq_no[1]);
    sscanf((const char *)hbth->seq_no+4, "%2hhx", &lbth->seq_no[2]);
    sscanf((const char *)hbth->seq_no+6, "%2hhx", &lbth->seq_no[3]);

    sscanf((const char *)hbth->kind, "%2hhx", &lbth->kind);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->tbl_typ,  (char *)&lbth->tbl_typ, 2, 0);

    sscanf((const char *)hbth->frame_no  , "%2hhx", &lbth->frame_no[0]);
    sscanf((const char *)hbth->frame_no+2, "%2hhx", &lbth->frame_no[1]);
    sscanf((const char *)hbth->frame_no+4, "%2hhx", &lbth->frame_no[2]);
    sscanf((const char *)hbth->frame_no+6, "%2hhx", &lbth->frame_no[3]);

    sscanf((const char *)hbth->frame_cnt  , "%2hhx", &lbth->frame_cnt[0]);
    sscanf((const char *)hbth->frame_cnt+2, "%2hhx", &lbth->frame_cnt[1]);
    sscanf((const char *)hbth->frame_cnt+4, "%2hhx", &lbth->frame_cnt[2]);
    sscanf((const char *)hbth->frame_cnt+6, "%2hhx", &lbth->frame_cnt[3]);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->rvs_no, (char *)&lbth->rvs_no, 2, 0);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->div   , (char *)&lbth->div   , 2, 0);
	
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_aply_year , (char *)&lbth->bl_aply_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_aply_month, (char *)&lbth->bl_aply_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_aply_day  , (char *)&lbth->bl_aply_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_aply_hour , (char *)&lbth->bl_aply_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_aply_min  , (char *)&lbth->bl_aply_min  , 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_modf_year , (char *)&lbth->bl_modf_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_modf_month, (char *)&lbth->bl_modf_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_modf_day  , (char *)&lbth->bl_modf_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_modf_hour , (char *)&lbth->bl_modf_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->bl_modf_min  , (char *)&lbth->bl_modf_min  , 2, 0);
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(교통카드 B/L 테이블 헤더부) (0x%02x)\n", lbth->kind);
    printf("--------------------------------------------------------------------------------------\n");
    printf("    TYPE/FRAME NO./FRAME 수/개정번호 : %.2s / %.8s / %.8s / %.2s\n", hbth->tbl_typ, hbth->frame_no, hbth->frame_cnt, hbth->rvs_no);
    printf("    구분                             : %.2s\n", hbth->div);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

int tcrdbl_fr_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_bl_tbl_f   *hbtf;     /* TAG B/L-F    */
    struct    bl_tbl_f      *lbtf;
    int i;
    char tmp[25]; memset(tmp, 0x00, sizeof(tmp));
    
    hbtf = (struct hi_bl_tbl_f *)h_buf;
    lbtf = (struct bl_tbl_f *)l_buf;

    sscanf((const char *)hbtf->seq_no  , "%2hhx", &lbtf->seq_no[0]);
    sscanf((const char *)hbtf->seq_no+2, "%2hhx", &lbtf->seq_no[1]);
    sscanf((const char *)hbtf->seq_no+4, "%2hhx", &lbtf->seq_no[2]);
    sscanf((const char *)hbtf->seq_no+6, "%2hhx", &lbtf->seq_no[3]);

    sscanf((const char *)hbtf->kind, "%2hhx", &lbtf->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->tbl_typ,  (char *)&lbtf->tbl_typ, 2, 0);

    sscanf((const char *)hbtf->frame_no  , "%2hhx", &lbtf->frame_no[0]);
    sscanf((const char *)hbtf->frame_no+2, "%2hhx", &lbtf->frame_no[1]);
    sscanf((const char *)hbtf->frame_no+4, "%2hhx", &lbtf->frame_no[2]);
    sscanf((const char *)hbtf->frame_no+6, "%2hhx", &lbtf->frame_no[3]);

    sscanf((const char *)hbtf->last_data_seq_no  , "%2hhx", &lbtf->last_data_seq_no[0]);
    sscanf((const char *)hbtf->last_data_seq_no+2, "%2hhx", &lbtf->last_data_seq_no[1]);
    sscanf((const char *)hbtf->last_data_seq_no+4, "%2hhx", &lbtf->last_data_seq_no[2]);
    sscanf((const char *)hbtf->last_data_seq_no+6, "%2hhx", &lbtf->last_data_seq_no[3]);
    
    sscanf((const char *)hbtf->item_cnt, "%2hhx", &lbtf->item_cnt);

    for (i=0; i<111; i++)
    {
        smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->bl_data[i].div, (char *)&lbtf->bl_data[i].div , 2, 0);

        sscanf((const char *)hbtf->bl_data[i].crd_no   , "%2hhx", &lbtf->bl_data[i].crd_no[0]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+2 , "%2hhx", &lbtf->bl_data[i].crd_no[1]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+4 , "%2hhx", &lbtf->bl_data[i].crd_no[2]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+6 , "%2hhx", &lbtf->bl_data[i].crd_no[3]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+8 , "%2hhx", &lbtf->bl_data[i].crd_no[4]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+10, "%2hhx", &lbtf->bl_data[i].crd_no[5]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+12, "%2hhx", &lbtf->bl_data[i].crd_no[6]);
        sscanf((const char *)hbtf->bl_data[i].crd_no+14, "%2hhx", &lbtf->bl_data[i].crd_no[7]);
    }
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(교통카드 B/L 테이블 프레임부 %02x%02x%02x%02x) (0x%02x)\n",
              lbtf->frame_no[0], lbtf->frame_no[1], lbtf->frame_no[2], lbtf->frame_no[3], lbtf->kind);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

/*
 *========================================================================
 *
 *   Function : tcrdpl_hd_packet_chng()
 *   Progrmer : JBY (baarong@neighbor21.co.kr)
 *   Date     : 2018.07.13
 *   Modified :
 *   Remark   : TABLE DATA(Plaza -> Lane) Period Tag P/L
 *
 *========================================================================
*/
int tcrdpl_hd_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct hi_pl_tbl_h *hpth;
    struct pl_tbl_h    *lpth;
    int ii = 0;

    hpth = (struct hi_pl_tbl_h *)h_buf;
    lpth = (struct pl_tbl_h *)l_buf;

    sscanf((const char *)hpth->seq_no  , "%2hhx", &lpth->seq_no[0]);
    sscanf((const char *)hpth->seq_no+2, "%2hhx", &lpth->seq_no[1]);
    sscanf((const char *)hpth->seq_no+4, "%2hhx", &lpth->seq_no[2]);
    sscanf((const char *)hpth->seq_no+6, "%2hhx", &lpth->seq_no[3]);

    sscanf((const char *)hpth->kind, "%2hhx", &lpth->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hpth->tbl_typ,  (char *)&lpth->tbl_typ, 2, 0);

    sscanf((const char *)hpth->frame_no  , "%2hhx", &lpth->frame_no[0]);
    sscanf((const char *)hpth->frame_no+2, "%2hhx", &lpth->frame_no[1]);
    sscanf((const char *)hpth->frame_no+4, "%2hhx", &lpth->frame_no[2]);
    sscanf((const char *)hpth->frame_no+6, "%2hhx", &lpth->frame_no[3]);

    sscanf((const char *)hpth->frame_cnt  , "%2hhx", &lpth->frame_cnt[0]);
    sscanf((const char *)hpth->frame_cnt+2, "%2hhx", &lpth->frame_cnt[1]);
    sscanf((const char *)hpth->frame_cnt+4, "%2hhx", &lpth->frame_cnt[2]);
    sscanf((const char *)hpth->frame_cnt+6, "%2hhx", &lpth->frame_cnt[3]);

    smemcpy(D_TO_A, H_TO_L, (char *)&hpth->rvs_no ,   (char *)&lpth->rvs_no , 2, 0);
    smemcpy(D_TO_A, H_TO_L, (char *)&hpth->div,       (char *)&lpth->div, 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_aply_year , (char *)&lpth->pl_aply_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_aply_month, (char *)&lpth->pl_aply_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_aply_day  , (char *)&lpth->pl_aply_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_aply_hour , (char *)&lpth->pl_aply_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_aply_min  , (char *)&lpth->pl_aply_min  , 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_modf_year , (char *)&lpth->pl_modf_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_modf_month, (char *)&lpth->pl_modf_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_modf_day  , (char *)&lpth->pl_modf_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_modf_hour , (char *)&lpth->pl_modf_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hpth->pl_modf_min  , (char *)&lpth->pl_modf_min  , 2, 0);

    for(ii=0; ii<17; ii++)
    {
        sscanf((const char *)hpth->pl_block[ii].block_st_no  , "%2hhx", &lpth->pl_block[ii].block_st_no[0]);
        sscanf((const char *)hpth->pl_block[ii].block_st_no+2, "%2hhx", &lpth->pl_block[ii].block_st_no[1]);
        sscanf((const char *)hpth->pl_block[ii].block_st_no+4, "%2hhx", &lpth->pl_block[ii].block_st_no[2]);
        sscanf((const char *)hpth->pl_block[ii].block_st_no+6, "%2hhx", &lpth->pl_block[ii].block_st_no[3]);

        sscanf((const char *)hpth->pl_block[ii].block_cnt  , "%2hhx", &lpth->pl_block[ii].block_cnt[0]);
        sscanf((const char *)hpth->pl_block[ii].block_cnt+2, "%2hhx", &lpth->pl_block[ii].block_cnt[1]);
        sscanf((const char *)hpth->pl_block[ii].block_cnt+4, "%2hhx", &lpth->pl_block[ii].block_cnt[2]);
        sscanf((const char *)hpth->pl_block[ii].block_cnt+6, "%2hhx", &lpth->pl_block[ii].block_cnt[3]);
    }

#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(교통카드 P/L 테이블 헤더부) (0x%02x)\n", lpth->kind);
    printf("--------------------------------------------------------------------------------------\n");
    printf("    TYPE/FRAME NO./FRAME 수/개정번호 : %.2s / %.8s / %.8s / %.2s\n", hpth->tbl_typ, hpth->frame_no, hpth->frame_cnt, hpth->rvs_no);
    printf("    구분                             : %.2s\n", hpth->div);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

int tcrdpl_fr_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_pl_tbl_f   *hbtf;
    struct    pl_tbl_f      *lbtf;
	char tmp[2+1];
    int i;
    
    hbtf = (struct hi_pl_tbl_f *)h_buf;
    lbtf = (struct pl_tbl_f *)l_buf;

    sscanf((const char *)hbtf->seq_no  , "%2hhx", &lbtf->seq_no[0]);
    sscanf((const char *)hbtf->seq_no+2, "%2hhx", &lbtf->seq_no[1]);
    sscanf((const char *)hbtf->seq_no+4, "%2hhx", &lbtf->seq_no[2]);
    sscanf((const char *)hbtf->seq_no+6, "%2hhx", &lbtf->seq_no[3]);

    sscanf((const char *)hbtf->kind, "%2hhx", &lbtf->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->tbl_typ,  (char *)&lbtf->tbl_typ, 2, 0);

    sscanf((const char *)hbtf->frame_no  , "%2hhx", &lbtf->frame_no[0]);
    sscanf((const char *)hbtf->frame_no+2, "%2hhx", &lbtf->frame_no[1]);
    sscanf((const char *)hbtf->frame_no+4, "%2hhx", &lbtf->frame_no[2]);
    sscanf((const char *)hbtf->frame_no+6, "%2hhx", &lbtf->frame_no[3]);
//printf("chk 1\n");
#if 0
    sscanf((const char *)hbtf->item_cnt+2, "%2hhx", &lbtf->item_cnt[0]);
    sscanf((const char *)hbtf->item_cnt  , "%2hhx", &lbtf->item_cnt[1]);
#else
	sprintf((char *)tmp, "%c%c%c", hbtf->item_cnt[2], hbtf->item_cnt[3], '\0');
    lbtf->item_cnt[0] = strtoul(tmp, NULL, 16);
	sprintf((char *)tmp, "%c%c%c", hbtf->item_cnt[0], hbtf->item_cnt[1], '\0');
	lbtf->item_cnt[1] = strtoul(tmp, NULL, 16);
#endif
//printf("chk 2\n");
    for (i=0; i<1003; i++)
    {
		smemcpy(B_TO_B, H_TO_L, (char *)&hbtf->div[i],  (char *)&lbtf->div[i], 1, 0);
        //lbtf->div[i] = hbtf->div[i];
    }
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(교통카드 P/L 테이블 프레임부 %02x%02x%02x%02x) (0x%02x)\n",
              lbtf->frame_no[0], lbtf->frame_no[1], lbtf->frame_no[2], lbtf->frame_no[3], lbtf->kind);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

/*
 *========================================================================
 *
 *   Function : carno_hd_packet_chng()
 *   Progrmer : JBY (baarong@neighbor21.co.kr)
 *   Date     : 2019.06.18
 *   Modified :
 *   Remark   : TABLE DATA(Plaza -> Lane) 차량번호면제
 *
 *========================================================================
*/
int carno_hd_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_imm_carno_tbl_h   *hbth;     /* TAG B/L-H    */
    struct    imm_carno_tbl_h      *lbth;
    
    hbth = (struct hi_imm_carno_tbl_h *)h_buf;
    lbth = (struct imm_carno_tbl_h    *)l_buf;

    sscanf((const char *)hbth->seq_no  , "%2hhx", &lbth->seq_no[0]);
    sscanf((const char *)hbth->seq_no+2, "%2hhx", &lbth->seq_no[1]);
    sscanf((const char *)hbth->seq_no+4, "%2hhx", &lbth->seq_no[2]);
    sscanf((const char *)hbth->seq_no+6, "%2hhx", &lbth->seq_no[3]);

    sscanf((const char *)hbth->kind, "%2hhx", &lbth->kind);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->tbl_typ,  (char *)&lbth->tbl_typ, 2, 0);

    sscanf((const char *)hbth->frame_no  , "%2hhx", &lbth->frame_no[0]);
    sscanf((const char *)hbth->frame_no+2, "%2hhx", &lbth->frame_no[1]);
    sscanf((const char *)hbth->frame_no+4, "%2hhx", &lbth->frame_no[2]);
    sscanf((const char *)hbth->frame_no+6, "%2hhx", &lbth->frame_no[3]);

    sscanf((const char *)hbth->frame_cnt  , "%2hhx", &lbth->frame_cnt[0]);
    sscanf((const char *)hbth->frame_cnt+2, "%2hhx", &lbth->frame_cnt[1]);
    sscanf((const char *)hbth->frame_cnt+4, "%2hhx", &lbth->frame_cnt[2]);
    sscanf((const char *)hbth->frame_cnt+6, "%2hhx", &lbth->frame_cnt[3]);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->rvs_no, (char *)&lbth->rvs_no, 2, 0);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->div   , (char *)&lbth->div   , 2, 0);
	
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_year , (char *)&lbth->imm_aply_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_month, (char *)&lbth->imm_aply_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_day  , (char *)&lbth->imm_aply_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_hour , (char *)&lbth->imm_aply_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_min  , (char *)&lbth->imm_aply_min  , 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_year , (char *)&lbth->imm_modf_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_month, (char *)&lbth->imm_modf_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_day  , (char *)&lbth->imm_modf_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_hour , (char *)&lbth->imm_modf_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_min  , (char *)&lbth->imm_modf_min  , 2, 0);
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(차량번호면제 테이블 헤더부) (0x%02x)\n", lbth->kind);
    printf("--------------------------------------------------------------------------------------\n");
    printf("    TYPE/FRAME NO./FRAME 수/개정번호 : %.2s / %.8s / %.8s / %.2s\n", hbth->tbl_typ, hbth->frame_no, hbth->frame_cnt, hbth->rvs_no);
    printf("    구분                             : %.2s\n", hbth->div);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

int carno_fr_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_imm_carno_tbl_f   *hbtf;
    struct    imm_carno_tbl_f      *lbtf;
    int i;
    char tmp[25]; memset(tmp, 0x00, sizeof(tmp));
    
    hbtf = (struct hi_imm_carno_tbl_f *)h_buf;
    lbtf = (struct imm_carno_tbl_f *)l_buf;

    sscanf((const char *)hbtf->seq_no  , "%2hhx", &lbtf->seq_no[0]);
    sscanf((const char *)hbtf->seq_no+2, "%2hhx", &lbtf->seq_no[1]);
    sscanf((const char *)hbtf->seq_no+4, "%2hhx", &lbtf->seq_no[2]);
    sscanf((const char *)hbtf->seq_no+6, "%2hhx", &lbtf->seq_no[3]);

    sscanf((const char *)hbtf->kind, "%2hhx", &lbtf->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->tbl_typ,  (char *)&lbtf->tbl_typ, 2, 0);

    sscanf((const char *)hbtf->frame_no  , "%2hhx", &lbtf->frame_no[0]);
    sscanf((const char *)hbtf->frame_no+2, "%2hhx", &lbtf->frame_no[1]);
    sscanf((const char *)hbtf->frame_no+4, "%2hhx", &lbtf->frame_no[2]);
    sscanf((const char *)hbtf->frame_no+6, "%2hhx", &lbtf->frame_no[3]);

    sscanf((const char *)hbtf->last_data_seq_no  , "%2hhx", &lbtf->last_data_seq_no[0]);
    sscanf((const char *)hbtf->last_data_seq_no+2, "%2hhx", &lbtf->last_data_seq_no[1]);
    sscanf((const char *)hbtf->last_data_seq_no+4, "%2hhx", &lbtf->last_data_seq_no[2]);
    sscanf((const char *)hbtf->last_data_seq_no+6, "%2hhx", &lbtf->last_data_seq_no[3]);
    
    sscanf((const char *)hbtf->item_cnt, "%2hhx", &lbtf->item_cnt);

    for (i=0; i<142; i++)
    {
        smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->imm_info[i].rgst_div, (char *)&lbtf->imm_info[i].rgst_div , 2, 0);
		smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->imm_info[i].imm_div, (char *)&lbtf->imm_info[i].imm_div , 2, 0);

        sscanf((const char *)hbtf->imm_info[i].car_no   , "%2hhx", &lbtf->imm_info[i].car_no[0]);
        sscanf((const char *)hbtf->imm_info[i].car_no+2 , "%2hhx", &lbtf->imm_info[i].car_no[1]);
        sscanf((const char *)hbtf->imm_info[i].car_no+4 , "%2hhx", &lbtf->imm_info[i].car_no[2]);
        sscanf((const char *)hbtf->imm_info[i].car_no+6 , "%2hhx", &lbtf->imm_info[i].car_no[3]);
        sscanf((const char *)hbtf->imm_info[i].car_no+8 , "%2hhx", &lbtf->imm_info[i].car_no[4]);
    }
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(차량번호면제 테이블 프레임부 %02x%02x%02x%02x) (0x%02x)\n",
              lbtf->frame_no[0], lbtf->frame_no[1], lbtf->frame_no[2], lbtf->frame_no[3], lbtf->kind);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

/*
 *========================================================================
 *
 *   Function : rfid_hd_packet_chng()
 *   Progrmer : JBY (baarong@neighbor21.co.kr)
 *   Date     : 2019.06.18
 *   Modified :
 *   Remark   : TABLE DATA(Plaza -> Lane) 저공해/요일제
 *
 *========================================================================
*/
int rfid_hd_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct hi_imm_crdno_tbl_h *hbth;
    struct imm_crdno_tbl_h    *lbth;
    
    hbth = (struct hi_imm_crdno_tbl_h *)h_buf;
    lbth = (struct imm_crdno_tbl_h    *)l_buf;

    sscanf((const char *)hbth->seq_no  , "%2hhx", &lbth->seq_no[0]);
    sscanf((const char *)hbth->seq_no+2, "%2hhx", &lbth->seq_no[1]);
    sscanf((const char *)hbth->seq_no+4, "%2hhx", &lbth->seq_no[2]);
    sscanf((const char *)hbth->seq_no+6, "%2hhx", &lbth->seq_no[3]);

    sscanf((const char *)hbth->kind, "%2hhx", &lbth->kind);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->tbl_typ,  (char *)&lbth->tbl_typ, 2, 0);

    sscanf((const char *)hbth->frame_no  , "%2hhx", &lbth->frame_no[0]);
    sscanf((const char *)hbth->frame_no+2, "%2hhx", &lbth->frame_no[1]);
    sscanf((const char *)hbth->frame_no+4, "%2hhx", &lbth->frame_no[2]);
    sscanf((const char *)hbth->frame_no+6, "%2hhx", &lbth->frame_no[3]);

    sscanf((const char *)hbth->frame_cnt  , "%2hhx", &lbth->frame_cnt[0]);
    sscanf((const char *)hbth->frame_cnt+2, "%2hhx", &lbth->frame_cnt[1]);
    sscanf((const char *)hbth->frame_cnt+4, "%2hhx", &lbth->frame_cnt[2]);
    sscanf((const char *)hbth->frame_cnt+6, "%2hhx", &lbth->frame_cnt[3]);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->rvs_no, (char *)&lbth->rvs_no, 2, 0);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->div   , (char *)&lbth->div   , 2, 0);
	
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_year , (char *)&lbth->imm_aply_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_month, (char *)&lbth->imm_aply_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_day  , (char *)&lbth->imm_aply_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_hour , (char *)&lbth->imm_aply_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_aply_min  , (char *)&lbth->imm_aply_min  , 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_year , (char *)&lbth->imm_modf_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_month, (char *)&lbth->imm_modf_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_day  , (char *)&lbth->imm_modf_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_hour , (char *)&lbth->imm_modf_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->imm_modf_min  , (char *)&lbth->imm_modf_min  , 2, 0);
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(저공해/요일제 테이블 헤더부) (0x%02x)\n", lbth->kind);
    printf("--------------------------------------------------------------------------------------\n");
    printf("    TYPE/FRAME NO./FRAME 수/개정번호 : %.2s / %.8s / %.8s / %.2s\n", hbth->tbl_typ, hbth->frame_no, hbth->frame_cnt, hbth->rvs_no);
    printf("    구분                             : %.2s\n", hbth->div);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

int rfid_fr_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_imm_crdno_tbl_f   *hbtf;
    struct    imm_crdno_tbl_f      *lbtf;
    int i;
    char tmp[25]; memset(tmp, 0x00, sizeof(tmp));
    
    hbtf = (struct hi_imm_crdno_tbl_f *)h_buf;
    lbtf = (struct imm_crdno_tbl_f *)l_buf;

    sscanf((const char *)hbtf->seq_no  , "%2hhx", &lbtf->seq_no[0]);
    sscanf((const char *)hbtf->seq_no+2, "%2hhx", &lbtf->seq_no[1]);
    sscanf((const char *)hbtf->seq_no+4, "%2hhx", &lbtf->seq_no[2]);
    sscanf((const char *)hbtf->seq_no+6, "%2hhx", &lbtf->seq_no[3]);

    sscanf((const char *)hbtf->kind, "%2hhx", &lbtf->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->tbl_typ,  (char *)&lbtf->tbl_typ, 2, 0);

    sscanf((const char *)hbtf->frame_no  , "%2hhx", &lbtf->frame_no[0]);
    sscanf((const char *)hbtf->frame_no+2, "%2hhx", &lbtf->frame_no[1]);
    sscanf((const char *)hbtf->frame_no+4, "%2hhx", &lbtf->frame_no[2]);
    sscanf((const char *)hbtf->frame_no+6, "%2hhx", &lbtf->frame_no[3]);

    sscanf((const char *)hbtf->last_data_seq_no  , "%2hhx", &lbtf->last_data_seq_no[0]);
    sscanf((const char *)hbtf->last_data_seq_no+2, "%2hhx", &lbtf->last_data_seq_no[1]);
    sscanf((const char *)hbtf->last_data_seq_no+4, "%2hhx", &lbtf->last_data_seq_no[2]);
    sscanf((const char *)hbtf->last_data_seq_no+6, "%2hhx", &lbtf->last_data_seq_no[3]);
    
    sscanf((const char *)hbtf->item_cnt, "%2hhx", &lbtf->item_cnt);

    for (i=0; i<49; i++)
    {
        smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->imm_info[i].rgst_div, (char *)&lbtf->imm_info[i].rgst_div , 2, 0);
		sprintf((char *)tmp, "0%c%c", hbtf->imm_info[i].car_div, '\0');
		//lbtf->imm_info[i].car_div = hbtf->imm_info[i].car_div - '0';
		sscanf((const char *)tmp  , "%2hhx", &lbtf->imm_info[i].car_div);
//printf("저공해[%02x]\n", lbtf->imm_info[i].car_div);
        sscanf((const char *)hbtf->imm_info[i].crd_no   , "%2hhx", &lbtf->imm_info[i].crd_no[0]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+2 , "%2hhx", &lbtf->imm_info[i].crd_no[1]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+4 , "%2hhx", &lbtf->imm_info[i].crd_no[2]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+6 , "%2hhx", &lbtf->imm_info[i].crd_no[3]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+8 , "%2hhx", &lbtf->imm_info[i].crd_no[4]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+10 , "%2hhx", &lbtf->imm_info[i].crd_no[5]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+12 , "%2hhx", &lbtf->imm_info[i].crd_no[6]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+14 , "%2hhx", &lbtf->imm_info[i].crd_no[7]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+16 , "%2hhx", &lbtf->imm_info[i].crd_no[8]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+18 , "%2hhx", &lbtf->imm_info[i].crd_no[9]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+20 , "%2hhx", &lbtf->imm_info[i].crd_no[10]);
        sscanf((const char *)hbtf->imm_info[i].crd_no+22 , "%2hhx", &lbtf->imm_info[i].crd_no[11]);
		
        sscanf((const char *)hbtf->imm_info[i].car_no   , "%2hhx", &lbtf->imm_info[i].car_no[0]);
        sscanf((const char *)hbtf->imm_info[i].car_no+2 , "%2hhx", &lbtf->imm_info[i].car_no[1]);
        sscanf((const char *)hbtf->imm_info[i].car_no+4 , "%2hhx", &lbtf->imm_info[i].car_no[2]);
        sscanf((const char *)hbtf->imm_info[i].car_no+6 , "%2hhx", &lbtf->imm_info[i].car_no[3]);
        sscanf((const char *)hbtf->imm_info[i].car_no+8 , "%2hhx", &lbtf->imm_info[i].car_no[4]);
		
		sprintf(tmp, "%c%c%c", hbtf->imm_info[i].unap_div, hbtf->imm_info[i].vio_div, '\0');
		smemcpy(D_TO_A, H_TO_L, (char *)&tmp, (char *)&lbtf->imm_info[i].unap_vio_div , 2, 0);
    }
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(저공해/요일제 테이블 프레임부 %02x%02x%02x%02x) (0x%02x)\n",
              lbtf->frame_no[0], lbtf->frame_no[1], lbtf->frame_no[2], lbtf->frame_no[3], lbtf->kind);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

/*
 *========================================================================
 *
 *   Function : adv_hd_packet_chng()
 *   Progrmer : JBY (baarong@neighbor21.co.kr)
 *   Date     : 2019.06.15
 *   Modified :
 *   Remark   : TABLE DATA(Plaza -> Lane) 사전등록
 *
 *========================================================================
*/
int adv_hd_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct hi_adv_payment_tbl_h *hbth;
    struct adv_payment_tbl_h    *lbth;
    
    hbth = (struct hi_adv_payment_tbl_h *)h_buf;
    lbth = (struct adv_payment_tbl_h    *)l_buf;

    sscanf((const char *)hbth->seq_no  , "%2hhx", &lbth->seq_no[0]);
    sscanf((const char *)hbth->seq_no+2, "%2hhx", &lbth->seq_no[1]);
    sscanf((const char *)hbth->seq_no+4, "%2hhx", &lbth->seq_no[2]);
    sscanf((const char *)hbth->seq_no+6, "%2hhx", &lbth->seq_no[3]);

    sscanf((const char *)hbth->kind, "%2hhx", &lbth->kind);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->tbl_typ,  (char *)&lbth->tbl_typ, 2, 0);

    sscanf((const char *)hbth->frame_no  , "%2hhx", &lbth->frame_no[0]);
    sscanf((const char *)hbth->frame_no+2, "%2hhx", &lbth->frame_no[1]);
    sscanf((const char *)hbth->frame_no+4, "%2hhx", &lbth->frame_no[2]);
    sscanf((const char *)hbth->frame_no+6, "%2hhx", &lbth->frame_no[3]);

    sscanf((const char *)hbth->frame_cnt  , "%2hhx", &lbth->frame_cnt[0]);
    sscanf((const char *)hbth->frame_cnt+2, "%2hhx", &lbth->frame_cnt[1]);
    sscanf((const char *)hbth->frame_cnt+4, "%2hhx", &lbth->frame_cnt[2]);
    sscanf((const char *)hbth->frame_cnt+6, "%2hhx", &lbth->frame_cnt[3]);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->rvs_no, (char *)&lbth->rvs_no, 2, 0);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->div   , (char *)&lbth->div   , 2, 0);
	
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_aply_year , (char *)&lbth->adv_aply_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_aply_month, (char *)&lbth->adv_aply_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_aply_day  , (char *)&lbth->adv_aply_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_aply_hour , (char *)&lbth->adv_aply_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_aply_min  , (char *)&lbth->adv_aply_min  , 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_modf_year , (char *)&lbth->adv_modf_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_modf_month, (char *)&lbth->adv_modf_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_modf_day  , (char *)&lbth->adv_modf_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_modf_hour , (char *)&lbth->adv_modf_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->adv_modf_min  , (char *)&lbth->adv_modf_min  , 2, 0);
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(사전등록 테이블 헤더부) (0x%02x)\n", lbth->kind);
    printf("--------------------------------------------------------------------------------------\n");
    printf("    TYPE/FRAME NO./FRAME 수/개정번호 : %.2s / %.8s / %.8s / %.2s\n", hbth->tbl_typ, hbth->frame_no, hbth->frame_cnt, hbth->rvs_no);
    printf("    구분                             : %.2s\n", hbth->div);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

int adv_fr_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_adv_payment_tbl_f *hbtf;
    struct    adv_payment_tbl_f    *lbtf;
    int i;
    char tmp[25]; memset(tmp, 0x00, sizeof(tmp));
    
    hbtf = (struct hi_adv_payment_tbl_f *)h_buf;
    lbtf = (struct adv_payment_tbl_f *)l_buf;

    sscanf((const char *)hbtf->seq_no  , "%2hhx", &lbtf->seq_no[0]);
    sscanf((const char *)hbtf->seq_no+2, "%2hhx", &lbtf->seq_no[1]);
    sscanf((const char *)hbtf->seq_no+4, "%2hhx", &lbtf->seq_no[2]);
    sscanf((const char *)hbtf->seq_no+6, "%2hhx", &lbtf->seq_no[3]);

    sscanf((const char *)hbtf->kind, "%2hhx", &lbtf->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->tbl_typ,  (char *)&lbtf->tbl_typ, 2, 0);

    sscanf((const char *)hbtf->frame_no  , "%2hhx", &lbtf->frame_no[0]);
    sscanf((const char *)hbtf->frame_no+2, "%2hhx", &lbtf->frame_no[1]);
    sscanf((const char *)hbtf->frame_no+4, "%2hhx", &lbtf->frame_no[2]);
    sscanf((const char *)hbtf->frame_no+6, "%2hhx", &lbtf->frame_no[3]);

    sscanf((const char *)hbtf->last_data_seq_no  , "%2hhx", &lbtf->last_data_seq_no[0]);
    sscanf((const char *)hbtf->last_data_seq_no+2, "%2hhx", &lbtf->last_data_seq_no[1]);
    sscanf((const char *)hbtf->last_data_seq_no+4, "%2hhx", &lbtf->last_data_seq_no[2]);
    sscanf((const char *)hbtf->last_data_seq_no+6, "%2hhx", &lbtf->last_data_seq_no[3]);

    sscanf((const char *)hbtf->item_cnt, "%2hhx", &lbtf->item_cnt);

    for (i=0; i<142; i++)
    {
        smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->adv_info[i].rgst_div, (char *)&lbtf->adv_info[i].rgst_div , 2, 0);
/* 2019.06.18 신규 추가 */
		smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->adv_info[i].div, (char *)&lbtf->adv_info[i].div , 2, 0);

        sscanf((const char *)hbtf->adv_info[i].car_no   , "%2hhx", &lbtf->adv_info[i].car_no[0]);
        sscanf((const char *)hbtf->adv_info[i].car_no+2 , "%2hhx", &lbtf->adv_info[i].car_no[1]);
        sscanf((const char *)hbtf->adv_info[i].car_no+4 , "%2hhx", &lbtf->adv_info[i].car_no[2]);
        sscanf((const char *)hbtf->adv_info[i].car_no+6 , "%2hhx", &lbtf->adv_info[i].car_no[3]);
        sscanf((const char *)hbtf->adv_info[i].car_no+8 , "%2hhx", &lbtf->adv_info[i].car_no[4]);
    }
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(사전등록 테이블 프레임부 %02x%02x%02x%02x) (0x%02x)\n",
              lbtf->frame_no[0], lbtf->frame_no[1], lbtf->frame_no[2], lbtf->frame_no[3], lbtf->kind);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

/*
 *========================================================================
 *
 *   Function : red_hd_packet_chng()
 *   Progrmer : JBY (baarong@neighbor21.co.kr)
 *   Date     : 2019.06.15
 *   Modified :
 *   Remark   : TABLE DATA(Plaza -> Lane) 차량번호감면
 *
 *========================================================================
*/
int red_hd_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct hi_reduce_tbl_h *hbth;
    struct reduce_tbl_h    *lbth;
    
    hbth = (struct hi_reduce_tbl_h *)h_buf;
    lbth = (struct reduce_tbl_h    *)l_buf;

    sscanf((const char *)hbth->seq_no  , "%2hhx", &lbth->seq_no[0]);
    sscanf((const char *)hbth->seq_no+2, "%2hhx", &lbth->seq_no[1]);
    sscanf((const char *)hbth->seq_no+4, "%2hhx", &lbth->seq_no[2]);
    sscanf((const char *)hbth->seq_no+6, "%2hhx", &lbth->seq_no[3]);

    sscanf((const char *)hbth->kind, "%2hhx", &lbth->kind);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->tbl_typ,  (char *)&lbth->tbl_typ, 2, 0);

    sscanf((const char *)hbth->frame_no  , "%2hhx", &lbth->frame_no[0]);
    sscanf((const char *)hbth->frame_no+2, "%2hhx", &lbth->frame_no[1]);
    sscanf((const char *)hbth->frame_no+4, "%2hhx", &lbth->frame_no[2]);
    sscanf((const char *)hbth->frame_no+6, "%2hhx", &lbth->frame_no[3]);

    sscanf((const char *)hbth->frame_cnt  , "%2hhx", &lbth->frame_cnt[0]);
    sscanf((const char *)hbth->frame_cnt+2, "%2hhx", &lbth->frame_cnt[1]);
    sscanf((const char *)hbth->frame_cnt+4, "%2hhx", &lbth->frame_cnt[2]);
    sscanf((const char *)hbth->frame_cnt+6, "%2hhx", &lbth->frame_cnt[3]);

    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->rvs_no, (char *)&lbth->rvs_no, 2, 0);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbth->div   , (char *)&lbth->div   , 2, 0);
	
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_aply_year , (char *)&lbth->red_aply_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_aply_month, (char *)&lbth->red_aply_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_aply_day  , (char *)&lbth->red_aply_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_aply_hour , (char *)&lbth->red_aply_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_aply_min  , (char *)&lbth->red_aply_min  , 2, 0);

	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_modf_year , (char *)&lbth->red_modf_year , 4, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_modf_month, (char *)&lbth->red_modf_month, 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_modf_day  , (char *)&lbth->red_modf_day  , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_modf_hour , (char *)&lbth->red_modf_hour , 2, 0);
	smemcpy(D_TO_A, H_TO_L, (char *)&hbth->red_modf_min  , (char *)&lbth->red_modf_min  , 2, 0);
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(차량번호감면 테이블 헤더부) (0x%02x)\n", lbth->kind);
    printf("--------------------------------------------------------------------------------------\n");
    printf("    TYPE/FRAME NO./FRAME 수/개정번호 : %.2s / %.8s / %.8s / %.2s\n", hbth->tbl_typ, hbth->frame_no, hbth->frame_cnt, hbth->rvs_no);
    printf("    구분                             : %.2s\n", hbth->div);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}

int red_fr_packet_chng(uchar *h_buf, uchar *l_buf)
{
    struct    hi_reduce_tbl_f *hbtf;
    struct    reduce_tbl_f    *lbtf;
    int i;
    char tmp[25]; memset(tmp, 0x00, sizeof(tmp));
    
    hbtf = (struct hi_reduce_tbl_f *)h_buf;
    lbtf = (struct reduce_tbl_f *)l_buf;

    sscanf((const char *)hbtf->seq_no  , "%2hhx", &lbtf->seq_no[0]);
    sscanf((const char *)hbtf->seq_no+2, "%2hhx", &lbtf->seq_no[1]);
    sscanf((const char *)hbtf->seq_no+4, "%2hhx", &lbtf->seq_no[2]);
    sscanf((const char *)hbtf->seq_no+6, "%2hhx", &lbtf->seq_no[3]);

    sscanf((const char *)hbtf->kind, "%2hhx", &lbtf->kind);
    smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->tbl_typ,  (char *)&lbtf->tbl_typ, 2, 0);

    sscanf((const char *)hbtf->frame_no  , "%2hhx", &lbtf->frame_no[0]);
    sscanf((const char *)hbtf->frame_no+2, "%2hhx", &lbtf->frame_no[1]);
    sscanf((const char *)hbtf->frame_no+4, "%2hhx", &lbtf->frame_no[2]);
    sscanf((const char *)hbtf->frame_no+6, "%2hhx", &lbtf->frame_no[3]);

    sscanf((const char *)hbtf->last_data_seq_no  , "%2hhx", &lbtf->last_data_seq_no[0]);
    sscanf((const char *)hbtf->last_data_seq_no+2, "%2hhx", &lbtf->last_data_seq_no[1]);
    sscanf((const char *)hbtf->last_data_seq_no+4, "%2hhx", &lbtf->last_data_seq_no[2]);
    sscanf((const char *)hbtf->last_data_seq_no+6, "%2hhx", &lbtf->last_data_seq_no[3]);
    
    sscanf((const char *)hbtf->item_cnt, "%2hhx", &lbtf->item_cnt);

    for (i=0; i<142; i++)
    {
        smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->red_data[i].rgst_div, (char *)&lbtf->red_data[i].rgst_div , 2, 0);
		smemcpy(D_TO_A, H_TO_L, (char *)&hbtf->red_data[i].div, (char *)&lbtf->red_data[i].div , 2, 0);

        sscanf((const char *)hbtf->red_data[i].car_no   , "%2hhx", &lbtf->red_data[i].car_no[0]);
        sscanf((const char *)hbtf->red_data[i].car_no+2 , "%2hhx", &lbtf->red_data[i].car_no[1]);
        sscanf((const char *)hbtf->red_data[i].car_no+4 , "%2hhx", &lbtf->red_data[i].car_no[2]);
        sscanf((const char *)hbtf->red_data[i].car_no+6 , "%2hhx", &lbtf->red_data[i].car_no[3]);
        sscanf((const char *)hbtf->red_data[i].car_no+8 , "%2hhx", &lbtf->red_data[i].car_no[4]);
    }
#if 0
    printf("--------------------------------------------------------------------------------------\n");
    printf("    테이블 데이터(차량번호감면 테이블 프레임부 %02x%02x%02x%02x) (0x%02x)\n",
              lbtf->frame_no[0], lbtf->frame_no[1], lbtf->frame_no[2], lbtf->frame_no[3], lbtf->kind);
    printf("--------------------------------------------------------------------------------------\n");
#endif
    return 0;
}
