MifareClassic.transceive读数据返回data为什么为空?
//和卡建立连接
mc.connect({
success: function(res) {
console.log("连接卡成功: " + JSON.stringify(res))
//验证密码A指令
var keyaBs = [0x60, 0x04, 0xAE, 0x38, 0x40, 0x39, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF];
//把字节数组转成ArrayBuffer
var keyaArray = new Uint8Array(keyaBs.map(function (bs) {
return bs;
}));
var keyaBuffer = keyaArray.buffer;
//验证密码A
mc.transceive({
data:keyaBuffer,
success:function(res){
console.error("验证密码A" + "成功" + res.errMsg);
var arr = [0x30, 1]
var arrayBuffer = new Int8Array(arr).buffer
var u8 = new Uint8Array(arrayBuffer)
for(var i = 0; i < u8.length; i ++) {
console.log(u8[i])
}
//发送指令
mc.transceive({
data: arrayBuffer,
success: function(res) {
console.log("transceive返回: " + JSON.stringify(res))
},
fail: function(e) {
console.log("transceive异常: " + JSON.stringify(e))
}
});
},
fail:function(res){
console.error("验证密码A" + "失败" + res.errMsg);
},
complete:function(res){
console.error("验证密码A" + "状态" + res.errMsg);
}
});
},
fail: function(e) {
console.log("和卡连接异常: " + JSON.stringify(e))
}
})
结果:transceive返回: {“errMsg”:“transceive:ok”,“data”:{}}