<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>USB IC、Ntag卡、ID、15693卡读卡器调用例程 通用插件版 V2.0</title>
<script language="javascript" >
var iswsrun = false;
var ws;
var received_msg = "";
var mytimer;
var strls = "";
var errorno = "";
var wsUri ="ws://127.0.0.1:39189"; //端口号必须与RFIDWebServer端口一致
//控制字定义,控制字指定,控制字的含义请查看本公司网站提供的动态库说明
//javascript无法自定义常量, 你可以使用变量代替
var BLOCK0_EN = 0x01;//读第一块的(16个字节)
var BLOCK1_EN = 0x02;//读第二块的(16个字节)
var BLOCK2_EN = 0x04;//读第三块的(16个字节)
var NEEDSERIAL = 0x08;//仅读指定序列号的卡
var EXTERNKEY = 0x10;//用明码认证密码,产品开发完成后,建议把密码放到设备的只写区,然后用该区的密码后台认证,这样谁都不知道密码是多少,需要这方面支持请联系
var NEEDHALT = 0x20;//读/写完卡后立即休眠该卡,相当于这张卡不在感应区。要相重新操作该卡必要拿开卡再放上去
var myctrlword = 0;
var myareano = 0;
var authmode = 0;
var mypiccserial = "";
var mypicckey = "";
var piccdata0_2 = "";
var mypicckey_old = "";//旧密码
var mypicckey_new = "";//新密码
var myblockaddr = 1;//本次读卡的开始块号
var myblocksize = 8;//读8个块
var afi="00";
function isUIntNum(val){
var testval = /^\d+$/; // 非负整数
return (testval.test(val));
}
function isHex(val){
var testval = /^(\d|[A-F]|[a-f])+$/; // 十六进制数
return (testval.test(val));
}
function ReadID()
{
CardIDShowerdev.value="";
var ReadIDComm="idr_read,";
WebSocketRun(ReadIDComm);
}
function ReadIDOne()
{
CardIDShowerdev.value="";
var ReadIDComm="idr_read_once,";
WebSocketRun(ReadIDComm);
}
function readcard()
{
myctrlword=BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY; //指定控制字,十进制
myareano = 8; //指定为本次读取第8区,十进制
authmode = 1; //指定密码模式,十进制,大于0表示用A密码认证,推荐用A密码认证
mypiccserial="00000000"; //指定本次操作的卡序列号,十六进制,未知时可指定为8个0
mypicckey = "ffffffffffff"; //指定卡片密码,十六进制,ffffffffffff为卡片厂家出厂密码
CardIDShower.value = "";
//用parseInt转为十六进制数
var ReadCardComm="piccreadex,"+myctrlword+","+mypiccserial+","+myareano+","+authmode+","+mypicckey;
WebSocketRun(ReadCardComm);
}
function writecard()
{
myctrlword=BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY; //指定控制字,十进制
myareano = 8; //指定为本次读取第8区,十进制
authmode = 1; //指定密码模式,十进制,大于0表示用A密码认证,推荐用A密码认证
mypiccserial="00000000"; //指定本次操作的卡序列号,十六进制,未知时可指定为8个0
mypicckey = "ffffffffffff"; //指定卡片密码,十六进制,ffffffffffff为卡片厂家出厂密码
//指定写卡内容,长度为48个字节,其中每个字节以两个字符表示为十六进制数
piccdata0_2 = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F";
CardIDShower.value = "";
var WriteCardComm="piccwriteex,"+myctrlword+","+mypiccserial+","+myareano+","+authmode+","+mypicckey+","+piccdata0_2;
WebSocketRun(WriteCardComm);
}
function writecarduid()
{
myctrlword = BLOCK0_EN; //指定控制字,十进制
authmode = 1; //指定密码模式,十进制,大于0表示用A密码认证,推荐用A密码认证
mypiccserial = "00000000"; //指定本次操作的卡序列号,十六进制,未知时可指定为8个0
mypicckey = "ffffffffffff"; //指定卡片密码,十六进制,ffffffffffff为卡片厂家出厂密码
piccdata0 = "12345678000102030405060708090A0B"; //指定写卡内容,长度为16个字节,其中前面四个字节是卡号,第五字节必须为卡号的异或和校验字,后面为厂家标识
CardIDShower.value = "";
var WriteCardComm="piccwriteserial,"+myctrlword+","+mypiccserial+","+authmode+","+mypicckey+","+piccdata0;
WebSocketRun(WriteCardComm);
}
function changecardkeyex()
{
myctrlword=EXTERNKEY; //指定控制字
myareano = 8; //指定为本次读取第8区
authmode = 1; //批定密码模式,大于0表示用A密码认证,推荐用A密码认证
mypiccserial="00000000"; //指定本次操作的卡序列号,未知时可指定为8个0
mypicckey_old = "ffffffffffff"; //旧密码
mypicckey_new = "ffffffffffffFF078069ffffffffffff03";//新密码,其中最前面的ffffffffffff为A密码,中间的FF078069为访问控制位,后面的ffffffffffff为B密码,03是表示同时更改A、B、密码权限访问字,为02表示密码权限访问字不更改,只改A、B密码,为00表示只改A密码
CardIDShower.value = "";
var ChangeKeyComm="piccchangesinglekeyex,"+myctrlword+","+mypiccserial+","+myareano+","+authmode+","+mypicckey_old+","+mypicckey_new;
WebSocketRun(ChangeKeyComm);
}
function getdevicenumber()
{
CardIDShowerdev.value = "";
WebSocketRun("pcdgetdevicenumber");
}
function IDgetdevicenumber()
{
CardIDShowerdev.value = "";
WebSocketRun("IDpcdgetdevicenumber");
}
function beep()
{
CardIDShowerdev.value = "";
WebSocketRun("pcdbeep,30");
}
function IDbeep()
{
CardIDShowerdev.value = "";
WebSocketRun("idr_beep,30");
}
function clears1()
{
CardIDShower.value = "";
}
function clearsntag()
{
CardIDShowerNtag.value = "";
}
function clearsdev()
{
CardIDShowerdev.value = "";
}
//Ntag21x测试
function readcard_ntag()
{
strls = ntagserial.value.trim(); //指定序列号,未知卡序列号时可指定为14个0,因为NTAG21x卡是7个字节的卡序列号
if(strls=="")
{
mypiccserial="00000000000000";
}
else
{
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "卡号输入错误\r\n";
ntagserial.focus();
ntagserial.select();
return;
}
mypiccserial = strls;
}
//指定密码,NTAG21x卡密码为4个字节,卡出厂时密码功能不启用,这样无需密码也能读写卡
if(check3.checked)
{
myctrlword=EXTERNKEY; //指定控制字,无需密码为0,当需要密码时为EXTERNKEY;
strls = ntagkey3.value.trim();
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "密码输入错误\r\n";
ntagkey3.focus();
ntagkey3.select();
return;
}
mypicckey = strls;
}
else
{
mypicckey = "00000000";
myctrlword = 0; //指定控制字,无需密码为0,当需要密码时为EXTERNKEY;
}
strls = ntagstartno.value.trim(); //起始页号
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "起始页号输入错误\r\n";
ntagstartno.focus();
ntagstartno.select();
return;
}
myblockaddr = parseInt(strls);//本次读卡的开始块号
//页数
strls = ntagpagenumber.value.trim();
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "页数输入错误\r\n";
ntagpagenumber.focus();
ntagpagenumber.select();
return;
}
myblocksize = parseInt(strls);//读4个块
var ReadNtagComm="piccreadex_ntag,"+myctrlword+","+mypiccserial+","+mypicckey+","+myblockaddr+","+myblocksize;
WebSocketRun(ReadNtagComm);
}
function writecard_ntag()
{
//指定序列号,未知卡序列号时可指定为14个0,因为NTAG21x卡是7个字节的卡序列号
strls = ntagserial.value.trim();
if(strls=="")
{
mypiccserial="00000000000000";
}
else
{
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "卡号输入错误\r\n";
ntagserial.focus();
ntagserial.select();
return;
}
mypiccserial = strls;
}
//指定密码,NTAG21x卡密码为4个字节,卡出厂时密码功能不启用,这样无需密码也能读写卡
if(check3.checked)
{
//指定控制字
myctrlword=EXTERNKEY;//无需密码为0,当需要密码时为EXTERNKEY;
strls = ntagkey3.value.trim();
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "密码输入错误\r\n";
ntagkey3.focus();
ntagkey3.select();
return;
}
mypicckey = strls;
}
else
{
mypicckey = "00000000";
myctrlword = 0; //指定控制字,无需密码为0,当需要密码时为EXTERNKEY;
}
//起始页号
strls = ntagstartno.value.trim();
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "起始页号输入错误\r\n";
ntagstartno.focus();
ntagstartno.select();
return;
}
myblockaddr = parseInt(strls);//本次读卡的开始块号
//页数
strls = ntagpagenumber.value.trim();
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "页数输入错误\r\n";
return;
}
myblocksize = parseInt(strls);
//数据
strls = ntagdata.value.trim();
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "数据输入错误\r\n";
ntagdata.focus();
ntagdata.select();
return;
}
var WriteNtagComm="piccwriteex_ntag,"+myctrlword+","+mypiccserial+","+mypicckey+","+myblockaddr+","+myblocksize+","+strls;
WebSocketRun(WriteNtagComm);
}
function piccinit_ntag()
{
//指定序列号,未知卡序列号时可指定为14个0,因为NTAG21x卡是7个字节的卡序列号
mypiccserial="00000000000000";
//指定密码,NTAG21x卡密码为4个字节,卡出厂时密码功能不启用,这样无需密码也能读写卡
if(check1.checked)
{
//指定控制字
myctrlword=EXTERNKEY;//无需密码为0,当需要密码时为EXTERNKEY;
strls = ntagkey1.value.trim();
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "密码输入错误\r\n";
ntagkey1.focus();
ntagkey1.select();
return;
}
mypicckey = strls;
}
else
{
mypicckey = "00000000";
myctrlword = 0; //指定控制字,无需密码为0,当需要密码时为EXTERNKEY;
}
//数据准备
if(select1.selectedIndex==1)
{//开启密码保护功能,写保护功能生效,但读保护需要下面的数据设定
//取新密码
strls = ntagkey2.value.trim();
if(strls.length != 8)
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "新密码长度必须为8位\r\n";
ntagkey2.focus();
ntagkey2.select();
return;
}
strls = ntagkey2.value.trim();
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "新密码输入错误\r\n";
ntagkey2.focus();
ntagkey2.select();
return;
}
strls1=protectpageno.value.trim();//起始保护页号
if(!isUIntNum(strls1))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "起始保护页号输入错误\r\n";
protectpageno.focus();
protectpageno.select();
return;
}
strls1 = "0"+parseInt(strls1).toString(16);
strls1 = strls1.substring(strls1.length-2);
mypiccdata = "000000" + strls1;
myctrlword = myctrlword + 0x01; //更新控制字
//计数器
strls1=keyerrortimes.value.trim();//允许密码错误次数
if(!isUIntNum(strls1))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "允许密码错误次数输入错误\r\n";
protectpageno.focus();
protectpageno.select();
return;
}
i = parseInt(strls1);
i = i % 8;
if(check2.checked)
{
i = i + 128;
}
strls1 = "0"+i.toString(16);
strls1 = strls1.substring(strls1.length-2);
mypiccdata = mypiccdata + strls1;
mypiccdata = mypiccdata + "000000";
mypiccdata = mypiccdata + strls;//新密码
//PACK
//PACK
//RFUI
//RFUI
mypiccdata = mypiccdata + "16160000";
myctrlword = myctrlword + 0x02; //更新控制字
}
else
{
mypiccdata = "000000FF";//MIRROR,RFUI,MIRROR_PAGE,AUTH0
myctrlword = myctrlword + 0x01; //更新控制字
mypiccdata = mypiccdata + "000000000000000000000000";
myctrlword = myctrlword + 0x02; //更新控制字
}
var WriteNtagComm="piccinit_ntag,"+myctrlword+","+mypiccserial+","+mypicckey+","+mypiccdata;
WebSocketRun(WriteNtagComm);
}
function readcard_15693()
{
myctrlword=0; //读任何卡,不需指定卡号,读完后不静止该卡,可赋值NEEDSERIAL及NEEDHALT的组合模式,或为0
afi="00"; //16进制,一般取00
mypiccserial="0000000000000000"; //指定序列号,未知卡序列号时可指定为18个0,因为15693卡是8个字节的卡序列号
strls = ntagstartno.value.trim(); //起始页号
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "起始页号输入错误\r\n";
ntagstartno.focus();
ntagstartno.select();
return;
}
myblockaddr = parseInt(strls);//本次读卡的开始块号
//页数
strls = ntagpagenumber.value.trim();
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "页数输入错误\r\n";
ntagpagenumber.focus();
ntagpagenumber.select();
return;
}
myblocksize = parseInt(strls); //最大取值12
var Read15693Comm="iso15693readex,"+myctrlword+","+afi+","+myblockaddr+","+myblocksize+","+mypiccserial;
WebSocketRun(Read15693Comm);
}
function writecard_15693()
{
myctrlword=0; //读任何卡,不需指定卡号,读完后不静止该卡,可赋值NEEDSERIAL及NEEDHALT的组合模式,或为0
afi="00"; //16进制,一般取00
mypiccserial="0000000000000000"; //指定序列号,未知卡序列号时可指定为18个0,因为15693卡是8个字节的卡序列号
//起始页号
strls = ntagstartno.value.trim();
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "起始页号输入错误\r\n";
ntagstartno.focus();
ntagstartno.select();
return;
}
myblockaddr = parseInt(strls);//本次读卡的开始块号
//页数
strls = ntagpagenumber.value.trim();
if(!isUIntNum(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "页数输入错误\r\n";
return;
}
myblocksize = parseInt(strls);
//数据
strls = ntagdata.value.trim();
if(!isHex(strls))
{
CardIDShowerNtag.value = CardIDShowerNtag.value + "数据输入错误\r\n";
ntagdata.focus();
ntagdata.select();
return;
}
var WriteNtagComm="iso15693writeex,"+myctrlword+","+afi+","+myblockaddr+","+myblocksize+","+mypiccserial+","+strls;
WebSocketRun(WriteNtagComm);
}
window.οnerrοr=function(e)
{
alert("不好意思,出错了!");
return true;//屏蔽系统事件
}
function timeoutevent()
{
ws.close();
CardIDShowerdev.value = "websockket返回超时";
}
//websockket数据处理
function WebSocketRev(evt)
{
clearTimeout(mytimer);
received_msg = evt.data;
ws.close();
//在这里解析返回数据
//CardIDShowerdev.value = received_msg;
var strlist=received_msg.split(",");
if (strlist.length>1){
var dispstr="";
switch(strlist[0]){
case "pcdbeep":
case "idr_beep":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",已执行蜂鸣响声操作!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +M1ErrInfo(strlist[1]);
}
CardIDShowerdev.value =dispstr;
break;
case "pcdgetdevicenumber":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",已读取设备编号!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +M1ErrInfo(strlist[1]);
}
if(strlist.length>2){
dispstr =dispstr +"设备编号:"+strlist[2]+"\r\n";
}
CardIDShowerdev.value =dispstr;
break;
case "idr_read":
case "idr_read_once":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",已读取卡号!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +M1ErrInfo(strlist[1]);
}
if(strlist.length>2){
dispstr =dispstr +"原始16进制卡号:"+strlist[2]+"\r\n";
}
if(strlist.length>3){
dispstr =dispstr +"转换08H10D卡号:"+strlist[3]+"\r\n";
}
CardIDShowerdev.value =dispstr;
break;
case "piccreadex":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",已读取卡内数据!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +M1ErrInfo(strlist[1]);
}
if(strlist.length>2){
dispstr =dispstr +"卡序列号:"+strlist[2]+"\r\n";
}
if(strlist.length>3){
dispstr =dispstr +"卡内数据:"+strlist[3]+"\r\n";
}
CardIDShower.value =dispstr;
break;
case "piccreadex_ntag":
case "iso15693readex":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",已读取卡内数据!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +NtagErrInfo(strlist[1]);
}
if(strlist.length>2){
dispstr =dispstr +"卡序列号:"+strlist[2]+"\r\n";
}
if(strlist.length>3){
dispstr =dispstr +"卡内数据:"+strlist[3]+"\r\n";
}
CardIDShowerNtag.value =dispstr;
break;
case "piccwriteex":
case "piccchangesinglekeyex":
case "piccwriteserial":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",写卡成功!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +M1ErrInfo(strlist[1]);
}
if(strlist.length>2){
dispstr =dispstr +"卡序列号:"+strlist[2]+"\r\n";
}
CardIDShower.value =dispstr;
break;
case "piccwriteex_ntag":
case "piccinit_ntag":
case "iso15693writeex":
dispstr ="函数名称:" +strlist[0]+"\r\n";
if(strlist[1]=="ReturnCode:000"){
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +",写卡成功!\r\n"
}else{
dispstr =dispstr +"操作结果:"+strlist[1];
dispstr =dispstr +NtagErrInfo(strlist[1]);
}
if(strlist.length>2){
dispstr =dispstr +"卡序列号:"+strlist[2]+"\r\n";
}
CardIDShowerNtag.value =dispstr;
break;
}
}
}
function M1ErrInfo(errcode){
var errstr="";
switch(errcode){
case "ReturnCode:001":
errstr=",读扇区数据失败!";
break;
case "ReturnCode:002":
errstr=",读1、2块数据失败!";
break;
case "ReturnCode:003":
errstr=",读第2块数据失败!";
break;
case "ReturnCode:008":
errstr=",未寻到卡,请将卡放到发卡器的感应区!";
break;
case "ReturnCode:009":
errstr=",有多张卡在感应区,寻卡过程中防冲突失败,读卡失败!";
break;
case "ReturnCode:010":
errstr=",该卡可能已被休眠,无法选中卡片!";
break;
case "ReturnCode:011":
errstr=",密码装载失败!";
break;
case "ReturnCode:012":
errstr=",卡密码认证失败!";
break;
case "ReturnCode:013":
errstr=",读块操作失败,原因是刷卡太快或本块所对应的区还没通过密码认证!";
break;
case "ReturnCode:014":
errstr=",写块操作失败,原因是刷卡太快或本块所对应的区还没通过密码认证!";
break;
case "ReturnCode:018":
errstr=",写块操作失败!";
break;
case "ReturnCode:021":
errstr=",没有动态库!";
break;
case "ReturnCode:022":
errstr=",动态库或驱动程序异常!";
break;
case "ReturnCode:023":
errstr=",驱动程序错误或发卡器未连接!";
break;
case "ReturnCode:024":
errstr=",操作超时,一般是动态库没有反映!";
break;
case "ReturnCode:025":
errstr=",发送字数不够!";
break;
case "ReturnCode:026":
errstr=",发送的CRC错!";
break;
case "ReturnCode:027":
errstr=",接收的字数不够!";
break;
case "ReturnCode:028":
errstr=",接收的CRC错!";
break;
case "ReturnCode:029":
errstr=",函数输入参数格式错误!";
break;
case "ReturnCode:444":
errstr=",RFIDWebServer系统文件错误!";
break;
default:
errstr=",未知的错误!";
}
return errstr;
}
function NtagErrInfo(errcode){
var errstr="";
switch(errcode){
case "ReturnCode:008":
case "ReturnCode:009":
case "ReturnCode:010":
errstr=",未寻到卡,请将卡放到发卡器的感应区!";
break;
case "ReturnCode:011":
case "ReturnCode:012":
errstr=",卡密码认证失败!";
break;
case "ReturnCode:013":
errstr=",读卡失败,可能需要验证密码!";
break;
case "ReturnCode:014":
errstr=",写卡失败,可能需要验证密码!";
break;
case "ReturnCode:021":
errstr=",没有动态库!";
break;
case "ReturnCode:022":
errstr=",动态库或驱动程序异常!";
break;
case "ReturnCode:023":
errstr=",驱动程序错误或发卡器未连接!";
break;
case "ReturnCode:024":
errstr=",操作超时,一般是动态库没有反映!";
break;
case "ReturnCode:025":
errstr=",发送字数不够!";
break;
case "ReturnCode:026":
errstr=",发送的CRC错!";
break;
case "ReturnCode:027":
errstr=",接收的字数不够!";
break;
case "ReturnCode:028":
errstr=",接收的CRC错!";
break;
case "ReturnCode:029":
errstr=",函数输入参数格式错误!";
break;
case "ReturnCode:444":
errstr=",RFIDWebServer系统文件错误!";
break;
default:
errstr=",未知的错误!";
}
return errstr;
}
function WebSocketRun(sendinfo)
{
iswsrun = false;
try
{
if ("WebSocket" in window)
{
ws = new WebSocket(wsUri);
}
else if("MozWebSocket" in window)
{
ws = new MozWebSocket(wsUri);
}
else
{
received_msg = "您的浏览器不支持WebSocket,请选用支持WebSocket的浏览器!";
return;
}
clearTimeout(mytimer);
ws.onopen = function (evt)
{
ws.send(sendinfo);
iswsrun = true;
mytimer = setTimeout("timeoutevent()", 1000);
};
ws.onmessage = WebSocketRev;
ws.onerror = function (e)
{
if(iswsrun != true){
received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";
window.open("https://www.icmcu.com/ICID15693-02V2test/RFIDWebServerSetup.exe","top");//打开新窗口
alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");
}
};
}
catch (ex)
{
if(iswsrun != true){
received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";
window.open("https://www.icmcu.com/ICID15693-02V2test/RFIDWebServerSetup.exe","top");//打开新窗口
alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");
}
}
}
</script>
<style type="text/css">
input {float: left;margin-right: 10px;margin-top: 10px;margin-bottom: 10px;padding: 5px 10px}
input[type="text"]:focus {border:2px solid #ff9800}
</style>
</head>
<body>
<div style="width:100%">
<div style=" float:left; COLOR: #FFF;BACKGROUND-COLOR: #FF9800;padding: 2px 5px;">
设备操作
</div>
<div style="width:100%; float:left;">
<div style="border-top: 2px solid #ff9800;padding: 2px 5px;color: #2196f3;">
<span>提示:</span>
<br/>
<textarea rows="4" cols="98" id="CardIDShowerdev" name="S3" style="width:100%;overflow:auto;"></textarea>
<input type="button" value="IC读写器蜂鸣器响" οnclick="beep()">
<input type="button" value="IC读写器读取读写器硬件号" οnclick="getdevicenumber()">
<input type="button" value="清空提示" οnclick="clearsdev()">
<br/>
</div>
</div>
<div style="width:100%; float:left;">
<div style="border-top: 2px solid #ff9800;padding: 2px 5px;color: #2196f3;">
<input type="button" value="ID读卡器蜂鸣器响" οnclick="IDbeep()">
<input type="button" value="ID读卡器读取读写器硬件号" οnclick="IDgetdevicenumber()">
<input type="button" value="连续读取ID卡号" οnclick="ReadID()">
<input type="button" value="需重新取放卡才能第二次读取ID卡号" οnclick="ReadIDOne()">
</div>
</div>
<div style=" float:left; COLOR: #FFF;BACKGROUND-COLOR: #FF9800;padding: 2px 5px;">
M1卡测试
</div>
<div style="width:100%; float:left;">
<div style="border-top: 2px solid #ff9800;padding: 2px 5px;color: #2196f3;">
<span>提示:</span>
<br/>
<textarea rows="4" cols="98" id="CardIDShower" name="S1" style="width: 100%;overflow:auto;"></textarea>
<br/>
<input type="button" value=" 读 卡 " οnclick="readcard()" />
<input type="button" value=" 写 卡 " οnclick="writecard()" />
<input type="button" value="更改卡密码" οnclick="changecardkeyex()" />
<input type="button" value="写卡UID号为12345678" οnclick="writecarduid()" />
<input type="button" value="清空提示" οnclick="clears1()" />
</div>
</div>
<div style=" float:left; COLOR: #FFF;BACKGROUND-COLOR: #FF9800;padding: 2px 5px;">
Ntag2x卡、15693卡测试
</div>
<div style="width:100%; float:left;">
<div style="border-top: 2px solid #ff9800;padding: 2px 5px;color: #2196f3;">
<span>提示:</span>
<br>
<textarea rows="4" cols="98" id="CardIDShowerNtag" name="S2" style="width: 100%;overflow:auto;"></textarea>
<br/>
<input type="button" value=" 设置Ntag2x卡密码及保护机制(写错卡作废,千万小心) " οnclick="piccinit_ntag()">
<input type="button" value="清空提示" οnclick="clearsntag()">
<br/>
<div style="width:100%; float:left;">
<label>
<input id="check1" type="checkbox" style="float:none;margin-right:0px;padding:0px;vertical-align:middle" />
<span style="vertical-align:middle">需要认证卡密码才能继续操作,密码:</span>
</label>
<input type="text" id="ntagkey1" value ="12345678" style="width:6em;float:none;margin-right:0px;padding:0px;vertical-align:middle"/>
<br/>
<select id="select1" style="width:12em;">
<option>取消密码保护功能</option>
<option>开启密码保护功能</option>
</select>
<br/>
<label>
<span style="vertical-align:middle">从</span>
<input type="text" id="protectpageno" value ="144" style="width:2em;float:none;margin-right:0px;padding:0px;vertical-align:middle"/>
<span style="vertical-align:middle">页开始有密码保护</span>
</label>
<label>
<input id="check2" type="checkbox" style="float:none;margin-right:0px;padding:0px;vertical-align:middle" />
<span style="vertical-align:middle">开启读操作密码保护</span>
</label>
<br/>
<span style="vertical-align:middle">新密码:</span>
<input type="text" id="ntagkey2" value ="12345678" style="width:6em;float:none;margin-right:0px;padding:0px;vertical-align:middle"/>
<span style="vertical-align:middle">允许密码错误次数(0为不限次):</span>
<input type="text" id="keyerrortimes" value ="0" style="width:2em;float:none;margin-right:0px;padding:0px;vertical-align:middle"/>
<div style="width:100%; float:left;border-top: 3px solid #eaebdc;"></div>
<br/>
<label>
<input id="check3" type="checkbox" style="float:none;margin-right:0px;padding:0px;vertical-align:middle" />
<span style="vertical-align:middle">需要认证卡密码才能继续操作,密码:</span>
</label>
<input type="text" id="ntagkey3" value ="12345678" style="width:6em;float:none;margin-right:0px;padding:0px;vertical-align:middle"/>
<table style="color:#e58800;width:100%;table-layout:fixed;">
<colgroup>
<col width="85">
<col width="50">
<col width="50">
<col width="auto">
</colgroup>
<tr>
<td style="text-align:right">
<span style="vertical-align:middle">起始页号:</span>
</td>
<td>
<input type="text" id="ntagstartno" value ="8" style="width:2em;float:none;margin-right:0px;padding:0px;vertical-align:middle"/>
</td>
<td>
<span style="vertical-align:middle">卡号:</span>
</td>
<td>
<input type="text" id="ntagserial" value="" style="max-width: 16em;width:100%;float:none;margin-right:0px;padding:0px;vertical-align:middle;overflow:auto;">
</td>
</tr>
<tr>
<td style="text-align:right">
<span style="vertical-align:middle">页数:</span>
</td>
<td>
<input type="text" id="ntagpagenumber" value ="4" style="width:2em;float:none;margin-right:0px;padding:0px;vertical-align:middle;" />
</td>
<td>
<span style="vertical-align:middle;">数据:</span>
</td>
<td>
<input type="text" id="ntagdata" value="" style="width:100%;float:none;margin-right:0px;padding:0px;vertical-align:middle;overflow:auto; ">
</td>
</tr>
</table>
<input type="button" value=" 轻松读Ntag2x卡,最多一次12页 " οnclick="readcard_ntag()">
<input type="button" value=" 轻松写Ntag2x卡,最多一次11页 " οnclick="writecard_ntag()">
<input type="button" value=" 轻松读15693卡,最多一次12页 " οnclick="readcard_15693()">
<input type="button" value=" 轻松写15693卡,最多一次12页 " οnclick="writecard_15693()">
<br/>
<div style="width:100%; float:left;border-top: 3px solid #eaebdc;"></div>
<br/>
</div>
</div>
</div>
<div style="width:100%; float:left;">
<table style="color:#e58800">
<colgroup>
<col width="20">
<col width="auto">
</colgroup>
<tr>
<td colspan="2">
说明:
</td>
</tr>
<tr>
<td valign="top">
1、
</td>
<td valign="top">
<p>
运行本例程前,需先在当前电脑下载安装我们的服务程序,并且运行该服务程序。</p>
</td>
</tr>
<tr>
<td valign="top">
2、
</td>
<td valign="top">
<p>
<p>兼容360、搜狗、QQ、UC、猎豹、IE、Microsoft Edge、Google Chrome、Firefox火狐等浏览器。</p>
</td>
</tr>
<tr>
<td valign="top">
2、
</td>
<td valign="top">
<p>
<p>兼容http及https安全浏览协议。</p>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>