Example #1
0
static void do_menu_query_revenue(sp_context* ctx)
{
  int key = 0;
  uint8 init_disp_flag = 0;
  uint8 upd_flag = 1;
  while(1)
  {
    if(upd_flag)
    {
      SP_CLS_FULLSCREEN;
      SP_PRINT(1, 0, "1.当日营业额查询");
      SP_PRINT(2, 0, "2.昨日营业额查询");
      upd_flag = 0;
    }
    key = sp_get_key();
    switch(key)
    {
      case SP_KEY_1:
        init_disp_flag = 1;
        sp_disp_by_type(SP_TP_REVENUE_QUERY, ctx, NULL, &init_disp_flag);
        upd_flag = 1;
        break;
      case SP_KEY_2:
        init_disp_flag = 2;
        sp_disp_by_type(SP_TP_REVENUE_QUERY, ctx, NULL, &init_disp_flag);
        upd_flag = 1;
        break;
      case SP_KEY_CLEAR:
        return;
    }
  }
}
Example #2
0
static int do_wait_reload_card(sp_context* p_ctx, sp_card* card)
{
  sp_card this_card;
  int ret = 0;
  while(sp_request_card_poweron(&this_card))
  {
    if(SP_KEY_CLEAR == sp_get_key())
      return SP_CANCEL_CONSUME;
  }
  //寻到卡了判断下是不是同一张卡
  if(!SP_IS_SAME_CARDPHYID(this_card.cardphyid, card->cardphyid))
  {
    return SP_NOT_SAME_CARD;
  }
  ret = sp_select_card_app(p_ctx, card);
  if(ret)
  {
    sp_disp_debug("select card app error");
    return ret;
  }
  ret = sp_get_prove(p_ctx, card, ++card->paycnt);
  if(ret)
  {
    return SP_NOT_GET_PROVE;
  }
  return 0;
}
Example #3
0
static void disp_time()
{
  int ret = 0;
  SYSTIME gSysTime;
  uint8 cSendBuf[7] = {0x00, 0xA4, 0x00, 0x00, 0x00, 0x3F, 0x00};
  uint8 cRcvBuf[64], cRcvLen;
  char disp_msg[30];
  while(1)
  {
    if(SP_KEY_CLEAR == sp_get_key())
      return;
    if(ResetCard_A())
    {
      ret = CpuCard_Apdu(0x0f, 7, cSendBuf, &cRcvLen, cRcvBuf);
      sp_disp_error("CpuCard_Apdu,ret=%04x", ret);
      Beep(3);
      ret = Deselect_A();
      sp_disp_error("Deselect_A,ret=%04x", ret);
      Reset_Reader_TimeOut();
    }
    GetTime(&gSysTime);
    sprintf(disp_msg, "normal=%02d:%02d:%02d", gSysTime.chHour, gSysTime.chMinute, gSysTime.chSecond);
    SP_PRINT(1, 0, disp_msg);
    sp_sleep(1000);
  }
}
Example #4
0
static int check_number_key(uint8* t)
{
  int key;
  key = sp_get_key();
  if(key == SP_KEY_FUNC)
    return SP_RETURN_FUNC;
  //sp_disp_debug("key=%02x,0=%02x,9=%02x", key, SP_KEY_0, SP_KEY_9);
  //if(sp_is_number_key(key, &t))
  if(sp_is_number_key(key, t))
    return SP_NO_NUMBER_KEY_PRESSED;
  else
    return 0;
}
Example #5
0
static void do_menu_cancel(sp_context* p_ctx)
{
  int key = 0;
  int ret = 0;
  //char phyid_hex[33] = {0};
  sp_card this_card;
  sp_disp_by_type(SP_TP_REQUEST_CARD, p_ctx, &this_card, NULL);
  while(1)
  {
    key = sp_get_key();
    if(SP_KEY_CLEAR == key)
      return;
    ret = sp_request_card(this_card.cardphyid);
    if(ret == 0)
      break;
  }
  //重新寻卡
  ret = sp_request_card_poweron(&this_card);
  if(ret)
  {
    sp_disp_error("sp_request_card_purchase,ret=%04x", ret);
    return;
  }
  ret = sp_read_card(p_ctx, &this_card, SP_READ_FILE10 | SP_READ_FILE15 | SP_READ_FILE16 | SP_READ_CARDBAL);
  if(ret)
  {
    sp_disp_error("sp_read_card,ret=%04x", ret);
    return;
  }
  sp_disp_by_type(SP_TP_CANCEL_CONSUME, p_ctx, &this_card, NULL);
  while(1)
  {
    key = sp_get_key();
    if(SP_KEY_CLEAR == key)
      return;
    if(SP_KEY_CONFIRM == key)
      do_cancel_last_trans(&this_card);
  }
}
Example #6
0
static void do_menu_sign(sp_context* p_ctx)
{
  int32 ret = 0, key = 0;
  sp_tcp_trans_unit m_unt;
  memset(&m_unt, 0, sizeof(sp_tcp_trans_unit));
  memcpy(m_unt.header.guide_code, "\x00\x00\x01", 3);
  m_unt.header.cmd_code = 0x01;
  m_unt.header.data_len = 300;
  memcpy(m_unt.header.machine_addr, "\x99\x88", 2);
  memcpy(m_unt.data, "\x55\x66\x55\x66\x55", 5);
  m_unt.check_sum = 0x77;
  sp_disp_msg(2, "进入签到,等待按键");
  while(1)
  {
    ret = 0;
    key = sp_get_key();
    switch(key)
    {
      case SP_KEY_CLEAR:
        sp_disp_msg(2, "签到下按键CLAER");
        return;
      case SP_KEY_0:
        sp_disp_msg(2, "签到下按键0");
        break;
      case SP_KEY_1:
        sp_disp_msg(2, "签到下按键1");
        m_unt.header.data_len = 100;
        ret = sp_send_struct(&m_unt);
        break;
      case SP_KEY_2:
        sp_disp_msg(2, "签到下按键2");
        m_unt.header.data_len = 200;
        ret = sp_send_struct(&m_unt);
        break;
      case SP_KEY_3:
        sp_disp_msg(2, "签到下按键3");
        m_unt.header.data_len = 300;
        ret = sp_send_struct(&m_unt);
        break;
    }

    if(ret == 0)
    {
      //sp_disp_msg(2, "发送成功");
    }
    else
    {
      sp_disp_msg(2, "发送失败");
    }
  }
}
Example #7
0
static void do_consume_normal(sp_context * ctx)
{
  int ret = 0;
  int32 key = 0;
  ctx->disp_type = 0;
  SP_CLS_FULLSCREEN;
  while(1)
  {
    //sp_sleep(10);
    key = sp_get_key();
    if(SP_KEY_FUNC == key)
      return;
    //检查是否有存储空间
    ret = sp_pre_check(ctx);
    if(ret)
    {
      sp_disp_msg(10, "存储空间不足");
      continue;
    }
    ret = sp_check_date_change(ctx);
    if(ret)
    {
      sp_disp_error("致命错误, ret=%04x,[%02x%02x%02x%02x]->[%02x%02x%02x%02x%02x%02x%02x]", ret,
                    ctx->syspara.today_date[0], ctx->syspara.today_date[1], ctx->syspara.today_date[2], ctx->syspara.today_date[3],
                    ctx->today[0], ctx->today[1], ctx->today[2], ctx->today[3], ctx->current_datetime[4], ctx->current_datetime[5], ctx->current_datetime[6]);
      //sp_sleep(99999);
      sp_select_card_app(ctx, &ctx->card);
    }
    ret = sp_consume_loop(ctx);
    if(SP_RETURN_FUNC == ret)
    {
      return;
    }
    if(ret)
    {
      if((ret != SP_NO_NUMBER_KEY_PRESSED) && (SP_CANCEL_CONSUME != ret))
      {
        sp_disp_error("消费错误, 错误码=%04x", ret);
        ctx->disp_type = 0;
      }
    }

    Reset_Reader_TimeOut();
    //500ms或1S刷新一次 从Flash读取点阵需要时间可放定时器回调函数处理
    //喂狗定义防止溢出程序复位
    //  KillWatchDog();
  }
}
Example #8
0
//////////////////////菜单相关//////////////////////
static void do_menu_set(sp_context* p_ctx)
{
  int32 key = 0;
  sp_disp_msg(2, "设置");
  while(1)
  {
    key = sp_get_key();
    switch(key)
    {
      case SP_KEY_CLEAR:
        return;
      case SP_KEY_0:
        sp_disp_msg(2, "设置0");
        break;
    }
  }

}
Example #9
0
static int check_and_input_money(sp_context* ctx, uint32* money, sp_card* p_card)
{
  int32 key = 0;
  char value[20] = {0};
  char temp[20];
  uint8 req_card_phyid[4];
  uint8 t;
  while(1)
  {
    // 寻不到卡也要return
    if(sp_request_card(req_card_phyid))
    {
      //sp_disp_error("寻不到卡,退出");
      return SP_CARD_NOT_FOUND;
    }
    // 判断是不是同一张卡
    if(!SP_IS_SAME_CARDPHYID(req_card_phyid, p_card->cardphyid))
    {
      sp_disp_msg(10, "不是同一张卡");
      return SP_NOT_SAME_CARD;
    }
    key = sp_get_key();
    if(!sp_is_number_key(key, &t))
    {
      if(t == SP_KEY_DOT)
      {
        memcpy(value, "0.", 2);
      }
      else
      {
        strcpy(temp, value);
        sprintf(value, "%s%d", temp, t);
      }
      break;
    }
  }
  //输入金额
  return do_input_money(ctx, money, p_card->cardphyid, value);
}
Example #10
0
static int do_prepare_pay_without_card(sp_context* ctx, sp_card* the_card)
{
  int ret = 0;
  uint8 t;
  uint32 amount = 0;
  ret = check_number_key(&t);
  if(ret)
    return ret;
  //输入金额
  if(do_input_money_without_card(ctx, &amount, t))
    return SP_CANCEL_CONSUME;
  the_card->amount = amount;
  sp_disp_by_type(SP_TP_REQUEST_CONSUME_CARD, ctx, the_card, NULL);
  //除非按撤销键,否则一直寻卡
  while(sp_request_card_poweron(the_card))
  {
    if(SP_KEY_CLEAR == sp_get_key())
      return SP_CANCEL_CONSUME;
  }
  ret = sp_read_card(ctx, the_card, SP_READ_FILE10 | SP_READ_FILE12 | SP_READ_FILE15 | SP_READ_CARDBAL);
  if(ret)
  {
    sp_halt(ctx, the_card);
    return ret;
  }
  // TODO : 判断黑卡前移到读卡,假如是黑卡马上记一笔黑卡消费的流水并返回
  if(do_check_blkcard(ctx, the_card))
  {
    ret = do_transdtl_blackcard(ctx, the_card);
    if(ret)
    {
      // TODO: 处理
    }
    return SP_RETURN_BLACKCARD_CONSUME;
  }
  //sp_request_card(the_card->cardphyid);
  return 0;
}
Example #11
0
static int do_input_money_without_card(sp_context* ctx, uint32* money, uint8 t)
{
  uint8 upd = 1;
  uint32 key;
  char temp[20];
  char value[20] = {0};
  //uint8 t;
  //输入金额
  if(t == SP_KEY_DOT)//输入的是.就变成0.
  {
    memcpy(value, "0.", 2);
  }
  else
  {
    strcpy(temp, value);
    sprintf(value, "%s%d", temp, t);
  }
  while(1)
  {
    if(upd)
    {
      //更新一下金额
      sp_disp_by_type(SP_TP_DISP_MONEY, ctx, NULL, value);
      upd = 0;
    }

    key = sp_get_key();

    if(!sp_is_number_key(key, &t))
    {
      if(strlen(value) >= 6)
        continue;
      strcpy(temp, value);
      if(t == SP_KEY_DOT)
      {
        //第一个不可以是点
        if(strlen(value) == 0)
        {
          memcpy(value, "0.", 2);
        }
        else
        {
          //假如已经存在点了就不覆盖
          if(strchr(temp, '.') != NULL)
            continue;
          sprintf(value, "%s%c", temp, '.');
        }
      }
      else
      {
        sprintf(value, "%s%d", temp, t);
      }
      upd = 1;
    }
    else if(key == SP_KEY_CONFIRM)
    {
      //*money = atoi(value) * 100;
      *money = sp_atof_mul100(value);
      return 0;
    }
    else if(key == SP_KEY_CLEAR)
    {
      uint8 vl = strlen(value);
      if(vl == 0)
        return 1;
      if(vl > 0)
        value[vl - 1] = 0;
      upd = 1;
    }
  }
}
Example #12
0
static int do_input_money(sp_context* ctx, uint32* money, const uint8* cardphyid, char* value)
{
  uint8 upd = 1;
  uint32 key;
  int32 ret;
  uint8 req_card_phyid[4];
  char temp[20];
  uint8 t;
  char show_msg[100];
  int i = 0;
  while(1)
  {
    if(upd)
    {
      //更新一下金额
      sp_disp_by_type(SP_TP_DISP_MONEY, ctx, NULL, value);
      upd = 0;
    }
    ret = sp_request_card(req_card_phyid);
    if(ret)
    {
      //sp_disp_error(3, "==寻卡失败==");
      return SP_CARD_NOT_FOUND;
    }

    if(memcmp(req_card_phyid, cardphyid, 4) != 0)
    {
      memset(show_msg, 0 , 100);
      memcpy(show_msg, "phyid=", 6);
      for(i = 0; i < 4; i++)
      {
        sprintf(show_msg + 6 + 3 * i, "%02x,", req_card_phyid[i]);
      }
      sp_disp_debug(show_msg);
      return SP_NOT_SAME_CARD;
    }

    key = sp_get_key();
    if(!sp_is_number_key(key, &t))
    {
      if(strlen(value) >= 6)
        continue;
      strcpy(temp, value);
      if(t == SP_KEY_DOT)
      {
        //第一个不可以是点
        if(strlen(value) == 0)
        {
          memcpy(value, "0.", 2);
        }
        else
        {
          //假如已经存在点了就不覆盖
          if(strchr(temp, '.') != NULL)
            continue;
          sprintf(value, "%s%c", temp, '.');
        }
      }
      else
      {
        sprintf(value, "%s%d", temp, t);
      }
      upd = 1;
    }
    /*
    else if(key == SP_KEY_MODE)
    {
      return -1;
    }
    */
    else if(key == SP_KEY_CONFIRM)
    {
      //*money = atoi(value) * 100;
      *money = sp_atof_mul100(value);
      return 0;
    }
    else if(key == SP_KEY_CLEAR)
    {
      uint8 vl = strlen(value);
      if(vl == 0)
        return 1;
      if(vl > 0)
        value[vl - 1] = 0;
      upd = 1;
    }
  }
}
Example #13
0
static int do_input_and_check_card_passwd(sp_context* p_ctx, sp_card* card)
{
  char show_password[MAX_SCREEN_ROWS];
  char real_password[MAX_SCREEN_ROWS];
  char temp[MAX_SCREEN_ROWS];
  int start_pos = 0;
  int key = 0;
  uint8 tmp_len = 0;
  uint8 t;
  bool upd_flag = false;
  memset(show_password, 0, MAX_SCREEN_ROWS);
  memset(real_password, 0, MAX_SCREEN_ROWS);
  SP_CLS_FULLSCREEN;
  SP_PRINT(0, 0, "请输入卡密码:");
  SP_PRINT(2, 0, "输入完毕请按确认");
  SP_PRINT(3, 0, "输入错误请按清除");
  while(1)
  {
    if(upd_flag == true)
    {
      memset(show_password, 0, MAX_SCREEN_ROWS);
      memset(show_password, '*', tmp_len);
      start_pos = (MAX_SCREEN_ROWS - tmp_len) / 2 - 1;
      SP_CLS(1);
      SP_PRINT(1, start_pos, show_password);
    }
    upd_flag = false;
    key = sp_get_key();
    if(SP_KEY_CLEAR == key)
    {
      if(tmp_len == 0)
        return SP_CARD_PASSWD_CANCEL;
      tmp_len--;
      upd_flag = true;
      continue;
    }
    if(SP_KEY_CONFIRM == key)
    {
      //比较密码是否正确
      //sp_disp_error("real[%02x%02x%02x%02x],card[%02x%02x%02x%02x]", real_password[0], real_password[1],
      //            real_password[2], real_password[3], card->passwd[0], card->passwd[1], card->passwd[2], card->passwd[3]);
      if(tmp_len != strlen(card->passwd))//密码长度错误
        return SP_CARD_PASSWD_ERROR;
      if(memcmp(real_password, card->passwd, strlen(card->passwd)) != 0)
      {
        return SP_CARD_PASSWD_ERROR;
      }
      break;
    }
    if(!sp_is_number_key(key, &t))
    {
      if(t < 10)
      {
        if(tmp_len >= 6)
          continue;
        tmp_len++;
        strcpy(temp, real_password);
        sprintf(real_password, "%s%d", temp, t);
        upd_flag = true;
      }
    }
  }
  return 0;
}
Example #14
0
int main (int argc, const char *argv [])
{
	unsigned char *cert_file = NULL, *key_file = NULL;
	unsigned char *cert;
	unsigned char *key;
	size_t cert_len = 0, key_len = 0;
	X509 *cert_ptr = NULL;
	STACK_OF(X509) *chain;
	EVP_PKEY *pkey = NULL;
	FILE *fp;
	DDS_Credentials credential;
	
	/* Test DDS_Credentials in DDS_SSL_BASED format */

	fp = fopen (argv [1], "rb");

	chain = sk_X509_new_null ();

	while ((cert_ptr = PEM_read_X509(fp, NULL, NULL, NULL)) != NULL) 
		sk_X509_push (chain, cert_ptr);

	fp = fopen (argv [2], "rb");

	pkey = PEM_read_PrivateKey(fp ,NULL, NULL, NULL);

	credential.credentialKind = DDS_SSL_BASED;
	credential.info.sslData.certificate_list = chain;
	credential.info.sslData.private_key = pkey;

	sp_extract_pem (&credential,
			&cert, &cert_len,
			&key, &key_len);

	readFile (argv [1], &cert_file);
	readFile (argv [2], &key_file);

	if (!compare (cert_file, strlen (cert_file),
		      cert, cert_len)) {
		printf ("compare problem \r\n");
		exit (1);
	}
	if (!compare (key_file, strlen (key_file),
		      key, key_len)) {
		printf ("compare problem \r\n");
		exit (1);
	}

	free (cert);
	free (key);

	/* Test DDS_Credentials in DDS_DATA_BASED PEM format */

	credential.credentialKind = DDS_DATA_BASED;
	credential.info.data.private_key.format = DDS_FORMAT_PEM;
	credential.info.data.private_key.data = key_file;
	credential.info.data.private_key.length = strlen (key_file);
	credential.info.data.num_certificates = 1;
	credential.info.data.certificates [0].format = DDS_FORMAT_PEM;
	credential.info.data.certificates [0].data = cert_file;
	credential.info.data.certificates [0].length = strlen (cert_file);
	
	cert_len = 0;
	key_len = 0;

	sp_extract_pem (&credential,
			&cert, &cert_len,
			&key, &key_len);

	if (!compare (cert_file, strlen (cert_file),
		      cert, cert_len)) {
		printf ("compare problem \r\n");
		exit (1);
	}
	if (!compare (key_file, strlen (key_file),
		      key, key_len)) {
		printf ("compare problem \r\n");
		exit (1);
	}

	if (sp_add_credential (1, "fake_name", cert, cert_len,
			       key, key_len))
		exit (1);

	if (!sp_get_name (1))
		exit (1);

	if (!sp_get_cert (1, &cert_len))
		exit (1);

	if (!sp_get_key (1, &key_len))
		exit (1);

	if (sp_remove_credential (1))
		exit (1);

	free (cert_file);
	free (key_file);
	free (cert);
	free (key);

	sk_X509_free (chain);

	printf ("Test succeeded\r\n");
}
Example #15
0
static void do_show_menu(const menu_info_t* menu_info, int menu_count, void* arg)
{
  int32 index = 0;
  int32 page_index = 0;
  int32 page_cnt = 0;
  int32 key = 0;
  int32 start = 0;
  bool need_upd = true;//是否需要刷新
  int32 i = 0, cnt = 0, last = 0;
  bool no_key_pressed = false;
  bool is_quit = false;
  page_cnt = menu_count / MAX_MENU_SCREEN_CNT + 1;
  while(1)
  {
    if(need_upd)
    {
      SP_CLS_FULLSCREEN;
      start = page_index * MAX_MENU_SCREEN_CNT;
      cnt = 0;
      last = start + MAX_MENU_SCREEN_CNT;
      if(last > menu_count)
        last = menu_count;
      for(i = start; i < last; i++)
      {
        SP_PRINT(cnt++, 0, (char*)menu_info[i].menu_desc);
      }
      SP_PRINT(3, 2, "按+/ - 上下翻页");
      need_upd = false;
    }
    is_quit = false;
    no_key_pressed = true;
    key = sp_get_key();
    switch(key)
    {
      case SP_KEY_CLEAR:
        no_key_pressed = false;
        is_quit = true;
        return;
        // break;
      case SP_KEY_ADD:
        if(page_index < page_cnt - 1)
        {
          page_index ++;
          need_upd = true;
        }
        break;
      case SP_KEY_MINUS:
        if(page_index > 0)
        {
          page_index--;
          need_upd = true;
        }
        break;
      case SP_KEY_1:
        no_key_pressed = false;
        index = 1;
        break;
      case SP_KEY_2:
        no_key_pressed = false;
        index = 2;
        break;
      case SP_KEY_3:
        no_key_pressed = false;
        index = 3;
        break;
      case SP_KEY_4:
        no_key_pressed = false;
        index = 4;
        break;
      case SP_KEY_5:
        no_key_pressed = false;
        index = 5;
        break;
      case SP_KEY_6:
        no_key_pressed = false;
        index = 6;
        break;
      case SP_KEY_7:
        no_key_pressed = false;
        index = 7;
        break;
      case SP_KEY_8:
        no_key_pressed = false;
        index = 8;
        break;
      case SP_KEY_9:
        no_key_pressed = false;
        index = 9;
        break;
      case SP_KEY_0:
        no_key_pressed = false;
        index = 10;
        break;
      default:
        break;
    }
    if(no_key_pressed == false)
    {
      if((index > 0) && (index <= menu_count))
      {
        menu_info[index - 1].menu_func(arg);
        need_upd = true;
      }
      if(is_quit)
        break;
    }
  }
}
Example #16
0
static void test_get_time(sp_context* p_ctx)
{
  SYSTIME tm;
  int32 key = 0;
  int ret = 0;
  char disp_msg[30];
  //  char phyid_hex[33] = {0};
  // uint8 cSendBuf[7] = {0x00, 0xA4, 0x00, 0x00, 0x00, 0x3F, 0x00};
  //  uint8 cSendBuf[7] = {0x00, 0xA4, 0x00, 0x00, 0x00, 0xDF, 0x03};
  // uint8 cRcvBuf[64], cRcvLen;
  sp_disp_error("in test_get_time");
  GetTime(&tm);
  while(1)
  {
    key = sp_get_key();
    if(SP_KEY_CLEAR == key)
      return;
    else if(SP_KEY_FUNC == key)
    {
      //  ret  = do_request_card(p_ctx, &p_ctx->card, phyid_hex);
      ret = sp_request_card(p_ctx->card.cardphyid);
      sp_disp_error("寻卡,ret=%d,%04x", ret, ret);
    }
    else if(SP_KEY_CONFIRM == key)
    {
      ret = sp_read_card(p_ctx, &p_ctx->card, SP_READ_FILE10 | SP_READ_FILE12 | SP_READ_FILE15 | SP_READ_FILE16);
      sp_disp_error("读卡,ret=%04x", ret);
    }
    else if(SP_KEY_0 == key)
    {
      ret  = sp_cpu_reset_card();
      sp_disp_error("key0--reset card,ret=%04x", ret);
    }
    else if(SP_KEY_1 == key)
    {
      ret =  sp_cpu_select_df03();//CpuCard_Apdu(0x0f, 7, cSendBuf, &cRcvLen, cRcvBuf);
      sp_disp_error("key2--sel df03,ret=%04x", ret);
      /*
        ret = ResetCard_A();
        if(ret)
        {
          ret = CpuCard_Apdu(0x0f, 7, cSendBuf, &cRcvLen, cRcvBuf);
          sp_disp_error("CpuCard_Apdu,ret=%04x", ret);
          Beep(3);
          ret = Deselect_A();
          sp_disp_error("Deselect_A,ret=%04x", ret);
          //Reset_Reader_TimeOut();
        }
        else
        {
          sp_disp_error("重设卡 error,ret=%04x", ret);
          ret = CpuCard_Apdu(0x0f, 7, cSendBuf, &cRcvLen, cRcvBuf);
          sp_disp_error("选df03,ret=%04x", ret);
          ret = Deselect_A();
          sp_disp_error( "取消选择,ret=%04x", ret);
          //Reset_Reader_TimeOut();
        }
        */
    }
    else if(SP_KEY_2 == key)
    {
      ret  = sp_cpu_deselect_card();
      // Reset_Reader_TimeOut();
      sp_disp_error("key1--deselect,ret=%04x", ret);
    }
    else if(SP_KEY_3 == key)
    {
      ret = sp_cpu_reset_time(p_ctx);
      sp_disp_error("reset_time,ret=%04x", ret);
    }

    GetTime(&tm);
    memset(disp_msg, 0, 30);
    sprintf(disp_msg, "%02d:%02d:%02d", tm.chHour, tm.chMinute, tm.chSecond);
    SP_PRINT(2, 0, disp_msg);

    sp_sleep(1000);
  }
}