JavaScript IC卡(M1)卡号正码转反码(12345678转78563412)

读卡器:德卡D3

m1CardTest() {
      // 初始化设置usb口通信,生成状态码
      rd.dc_init(100, 115200);
      // 设备状态码大于0正常
      console.log("设备状态:"+rd.dc_init(100, 115200));
      // 寻卡
      var snrlen
      rd.dc_card(0,snrlen)
      rd.dc_config_card(65);
      rd.dc_card_double(0);
      // 鸣蜂
      rd.dc_beep(5);  
      // 卡号正码转反码 rd.get_bstrRBuffer_asc UID
      // 转码参考 https://blog.csdn.net/frank_fong/article/details/86483135
      let a = rd.get_bstrRBuffer_asc.split('');
      let b = [];
      a.forEach((item, index) => {
          if (!(index % 2)) {
              b.push(a[index] + a[index + 1] + '');
          }
      });
      let c = b.reverse().join('');
      console.log("反码:"+c)
      this.form.cardSn = parseInt(c,16)
      console.log("转10进制:"+parseInt(c,16))
    }

你可能感兴趣的:(JavaScript IC卡(M1)卡号正码转反码(12345678转78563412))