JavaScript读写15693 ICod2 卡源码

本示例使用设备 :

https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-21818769070.11.23eb789efg450Y&id=615391857885

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>15693卡读写DEMO</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端口一致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 beep() {				     //驱动发卡器响声令textarea.value = "";		WebSocketRun("pcdbeep,30");					}function getdevicenumber() {         //读取发卡器唯一出厂序号,可以当加密狗使用			textarea.value = "";		serialnumber.value="";WebSocketRun("pcdgetdevicenumber");			}			function readcard_15693() {textarea.value = "";carduid.value="";RWdata.value= "";			myctrlword = 0;                        //读任何卡,不需指定卡号,读完后不静止该卡,可赋值NEEDSERIAL及NEEDHALT的组合模式,或为0            mypiccserial = "0000000000000000";     //指定序列号,未知卡序列号时可指定为16个0,因为15693卡是8个字节的卡序列号afi= textafi.value.trim(); ;           //16进制,一般取00if (!isHex(afi) || afi.length!=2) {alert( "应用标识AFI输入错误,请输入2位16进制应用标识AFI!");textafi.focus();textafi.select();return;}			myblockaddr = startno.value.trim();    //本次写卡的开始块号if (!isUIntNum(myblockaddr)) {alert("读写起始页输入错误!");startno.focus();startno.select();return;}            myblocksize = pagenumber.value.trim();  //本次读写页数if (!isUIntNum(myblocksize) || myblocksize<1 || myblocksize>12) {alert("读写页数输入错误,读写页数需大于等于1,小于等于12!");pagenumber.focus();pagenumber.select();return;}					var Read15693Comm = "iso15693readex," + myctrlword + "," + afi + "," + myblockaddr + "," + myblocksize + "," + mypiccserial;WebSocketRun(Read15693Comm);}		function writecard_15693() {textarea.value = "";carduid.value="";myctrlword = 0;                        //写任何卡,不需指定卡号,读完后不静止该卡,可赋值NEEDSERIAL及NEEDHALT的组合模式,或为0            mypiccserial = "0000000000000000";     //指定序列号,未知卡序列号时可指定为16个0,因为15693卡是8个字节的卡序列号afi= textafi.value.trim(); ;           //16进制,一般取00if (!isHex(afi) || afi.length!=2) {alert( "应用标识AFI输入错误,请输入2位16进制应用标识AFI!");textafi.focus();textafi.select();return;}			myblockaddr = startno.value.trim();    //本次写卡的开始块号if (!isUIntNum(myblockaddr)) {alert("读写起始页输入错误!");startno.focus();startno.select();return;}            myblocksize = pagenumber.value.trim();  //本次读写页数if (!isUIntNum(myblocksize) || myblocksize<1 || myblocksize>12) {alert("读写页数输入错误,读写页数需大于等于1,小于等于12!");pagenumber.focus();pagenumber.select();return;}					//数据strls = RWdata.value.trim();if (!isHex(strls)  || strls.length<myblocksize*8) {alert( "读写数据输入错误,请输入"+(myblocksize*8).toString()+"位16进制写卡数据!");RWdata.focus();RWdata.select();return;}var WriteNtagComm = "iso15693writeex," + myctrlword + "," + afi + "," + myblockaddr + "," + myblocksize + "," + mypiccserial + "," + strls;WebSocketRun(WriteNtagComm);}		function Searchcards(){			//搜寻感应区内的多张15693卡textarea.value = "";finduid.value="";clearlist();textflag.value="16";flag= "16" ;                            //16进制,固定的操作码16afi= textafi.value.trim(); ;           //16进制,一般取00if (!isHex(afi) || afi.length!=2) {alert( "应用标识AFI输入错误,请输入2位16进制应用标识AFI!");textafi.focus();textafi.select();return;}			MaskLen = textmasklen.value.trim();     //掩码长度if (!isUIntNum(MaskLen)) {alert("掩码长度输入错误,请输入正确的掩码长度!");textmasklen.focus();textmasklen.select();return;}	WebSocketRun("iso15693inventory16," + flag + "," + afi + "," + MaskLen );			}function read15693block(){textarea.value = "";textarea2.value="";textflag.value="22";flag= "22" ;                              //16进制,固定的操作码22myblockaddr = startblock.value.trim();    //本次写卡的开始块号if (!isUIntNum(myblockaddr)) {alert("读写起始页输入错误!");startblock.focus();startblock.select();return;}            myblocksize = rwblocks.value.trim();  //本次读写页数if (!isUIntNum(myblocksize)) {alert("读写页数输入错误!");rwblocks.focus();rwblocks.select();return;}mypiccserial= finduid.value.trim(); ;           //指定要读写卡的UIDif (!isHex(mypiccserial) || mypiccserial.length!=16) {alert( "卡片UID输入错误,请输入16位16进制UID!");finduid.focus();finduid.select();return;}			WebSocketRun("iso15693readblock," + flag + "," + myblockaddr + "," + myblocksize + "," + mypiccserial);			}				function write15693block(){textarea.value = "";textflag.value="22";flag= "22" ;                              //16进制,固定的操作码22myblockaddr = startblock.value.trim();    //本次写卡的开始块号if (!isUIntNum(myblockaddr)) {alert("读写起始页输入错误!");startblock.focus();startblock.select();return;}            myblocksize = rwblocks.value.trim();  //本次读写页数if (!isUIntNum(myblocksize)) {alert("读写页数输入错误!");rwblocks.focus();rwblocks.select();return;}//数据strls = textarea2.value.trim();if (!isHex(strls)  || strls.length<myblocksize*8) {alert( "读写数据输入错误,请输入"+(myblocksize*8).toString()+"位16进制写卡数据!");textarea2.focus();textarea2.select();return;}			mypiccserial= finduid.value.trim(); ;           //指定要读写卡的UIDif (!isHex(mypiccserial) || mypiccserial.length!=16) {alert( "卡片UID输入错误,请输入16位16进制UID!");finduid.focus();finduid.select();return;}			WebSocketRun("iso15693writeblock," + flag + "," + myblockaddr + "," + myblocksize + "," + mypiccserial+ "," + strls);			}	function write15693uid(){textarea.value = "";afi= textafi.value.trim(); ;           //16进制,一般取00if (!isHex(afi) || afi.length!=2) {alert( "应用标识AFI输入错误,请输入2位16进制应用标识AFI!");textafi.focus();textafi.select();return;}	newuid= textnewuid.value.trim(); ;           //16进制UIDif (!isHex(newuid) || newuid.length!=16) {alert( "新UID输入错误,请输入16位16进制新UID!");textnewuid.focus();textnewuid.select();return;}	WebSocketRun("iso15693writeuid,"+afi+","+newuid)}function DispErrInfo(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:040":errstr = ",使卡进入静止(Quiet)状态失败!";break;case "ReturnCode:041":errstr = ",选中卡操作失败!";break;case "ReturnCode:042":errstr = ",让卡从静止中重起准备失败!";break;	case "ReturnCode:044":errstr = ",一次写块不能超过12块!";break;	case "ReturnCode:045":errstr = ",每块字节数选错!";break;		case "ReturnCode:046":errstr = ",本次读取的块数超过卡片允许的一次读取最多块数!";break;											case "ReturnCode:444":errstr = ",RFIDWebServer系统文件错误!";break;default:errstr = ",未知的错误!";}return errstr;}			window.onerror = function (e) {alert("不好意思,出错了!");return true;//屏蔽系统事件}function timeoutevent() {ws.close();textarea.value = "websockket返回超时";}//websockket数据处理function WebSocketRev(evt) {clearTimeout(mytimer);received_msg = evt.data;ws.close();//在这里解析返回数据var strlist = received_msg.split(",");if (strlist.length > 1) {var dispstr = "";switch (strlist[0]) {case "pcdbeep":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 + DispErrInfo(strlist[1]);}textarea.value = dispstr;break;case "pcdgetdevicenumber":dispstr = "函数名称:" + strlist[0] + "\r\n";if (strlist[1] == "ReturnCode:000") {dispstr = dispstr + "操作结果:" + strlist[1];dispstr = dispstr + ",已读取设备编号!\r\n";serialnumber.value =  strlist[2] ;} else {dispstr = dispstr + "操作结果:" + strlist[1];dispstr = dispstr + DispErrInfo(strlist[1]);}textarea.value = dispstr;break;	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 + DispErrInfo(strlist[1]);}if (strlist.length > 2) {carduid.value=strlist[2];finduid.value=strlist[2];textnewuid.value=strlist[2];							}if (strlist.length > 3) {RWdata.value= strlist[3];}textarea.value = dispstr;break;	case "iso15693writeuid":	    //写uidcase "iso15693writeblock":  //写指定卡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 + DispErrInfo(strlist[1]);}if (strlist.length > 2) {carduid.value=strlist[2];finduid.value=strlist[2];textnewuid.value=strlist[2];							}textarea.value = dispstr;break;		case "iso15693inventory16":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 + DispErrInfo(strlist[1]);}textarea.value = dispstr;						if (strlist.length > 2) {carduid.value=strlist[2];finduid.value=strlist[2];textnewuid.value=strlist[2];}										if (strlist.length > 3) {addlist(strlist[3]);	}if (strlist.length > 4) {addlist(strlist[4]);	}						break;		case "iso15693readblock":dispstr = "函数名称:" + strlist[0] + "\r\n";if (strlist[1] == "ReturnCode:000") {dispstr = dispstr + "操作结果:" + strlist[1];dispstr = dispstr + ",已读取卡内数据!\r\n"textarea2.value= strlist[2];} else {dispstr = dispstr + "操作结果:" + strlist[1];dispstr = dispstr + DispErrInfo(strlist[1]);}																					textarea.value = dispstr;break;																									}}}		function addlist(itemstr){const select = document.querySelector("#sel_finduid");const option = document.createElement("option");option.value = "value";								option.text = itemstr;	select.add(option);			}function clearlist(){obj = document.getElementById("sel_finduid"); ///drp是select控件的ID值for(i=obj.options.length-1 ; i>= 0 ; i--)obj.options[i] = null;}function seleotheruit(){var myselect=document.getElementById("sel_finduid");var index=myselect.selectedIndex ; myselect.options[index].value;seleudistr=myselect.options[index].text;			 finduid.value=seleudistr.substr(seleudistr.length - 16, 16);}		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()", 3000);    //如果一次读、写页数比较大,可适当延长通讯超时时间。};ws.onmessage = WebSocketRev;ws.onerror = function (e) {if (iswsrun != true) {received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";window.open("http://www.icmcu.com/ICID15693-02V2test/RFIDWebServerSetup.exe", "top");//打开新窗口alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");}};}catch (ex) {if (iswsrun != true) {received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";window.open("http://www.icmcu.com/ICID15693-02V2test/RFIDWebServerSetup.exe", "top");//打开新窗口alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");}}}</script><style>th {background-color:#F5F5F5;	color: blue;font-family:楷体;}td {background-color:#F5F5F5;		font-family:楷体;}#carduid ,#finduid,#textnewuid{text-align: center;color: red;}   </style>    </head><body>
<table width="866" height="526" border="1" align="center"><tr><th width="124" height="45" scope="row"><input name="butt_beep" type="submit" id="butt_beep" onclick="beep()" value="驱动发卡器响声" /></th><td width="716"><input name="butt_getdevnum" type="submit" id="butt_getdevnum" onclick="getdevicenumber()" value="读取发卡器唯一出厂序列号" />设备编号:<input style="color:red;text-align:center;" name="serialnumber" type="text" id="serialnumber" size="8" maxlength="8" /></td></tr><tr><th height="45" scope="row">&nbsp;</th><td>应用标识AFI:<input style="color:blue;text-align:center;" name="textafi" type="text" id="textafi" value="00" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9a-fA-F]/g,'')"/>,操作标志FLAG:<input style="color:blue;text-align:center;" name="textflag" type="text" id="textflag" value="00" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9a-fA-F]/g,'')"/>,数据存储格式标识DSFID:<input style="color:blue;text-align:center;" name="textdsfid" type="text" id="textdsfid" value="00" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9a-fA-F]/g,'')"/></td></tr><tr><th  height="103" scope="row"><p><input name="butt_readcard_15693" type="submit" id="butt_readcard_15693" onclick="readcard_15693()" value="轻松读15693卡" /></p><p>&nbsp;</p><p><input name="butt_writecard_15693" type="submit" id="butt_writecard_15693" onclick="writecard_15693()" value="轻松写15693卡" /></p></th><td><p>读写起始页:<input style="color:blue;blue-align:center;" name="startno" type="text" id="startno" value="0" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/\D/g,'')"/>,读写页数:<input style="color:blue;text-align:center;" name="pagenumber" type="text" id="pagenumber" value="12" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/\D/g,'')"/>,感应区内只能一张卡,每次最多读、写12页。</p><p>返回UID号:<input name="carduid" type="text" id="carduid" size="16" maxlength="16" /></p><p><textarea style="color:red;" name="RWdata" id="RWdata" cols="100" rows="3" ></textarea></p></td>  </tr>  <tr><th height="175" scope="row"><p><input name="butt_iso15693inventory16" type="submit" id="butt_iso15693inventory16" onclick="Searchcards()" value="寻找感应区内多张卡" /></p><p>&nbsp; </p><p><input name="butt_readblock" type="submit" id="butt_readblock" onclick="read15693block()" value="读取指定UID卡数据" /></p><p><input name="butt_writeblock" type="submit" id="butt_writeblock" onclick="write15693block()" value="写数据到指定UID卡" /></p></th><td><p>掩码长度:<input style="color:blue;text-align:center;" name="textmasklen" type="text" id="textmasklen" value="0" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/\D/g,'')"/>,寻找到的卡片UID列表:<select style="color:red;" name="sel_finduid" id="sel_finduid" onchange="seleotheruit()"></select><input name="finduid" type="text" id="finduid" size="16" maxlength="16" /></p><p>读写起始页:<input style="color:blue;text-align:center;" name="startblock" type="text" id="startblock" value="0" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/\D/g,'')"/>,读写页数:<input style="color:blue;text-align:center;" name="rwblocks" type="text" id="rwblocks" value="28" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/\D/g,'')"/>,感应区内可以有多张卡,读写前必须指定卡片的UID。</p><p><textarea style="color:red;" name="textarea2" id="textarea2" cols="100" rows="5" ></textarea></p></td></tr><tr><th height="45" scope="row"><p><input name="butt_writeuid" type="submit" id="butt_writeuid" onclick="write15693uid()" value="1830卡写入新UID" /></p></th><td>新UID:<input name="textnewuid" type="text" id="textnewuid" size="16" maxlength="16" /></td></tr>  <tr><th height="78" scope="row"><p>操作提示</p></th><td><textarea style="color:blue;" name="textarea"  id="textarea" cols="100" rows="5" ></textarea></td></tr>
</table>
</body>
</html>

 USB免驱动15693读写器 15693-02 支持Windows、Android、Linux_广州荣士电子公司

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/292795.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

无头 SEO:技术实施的 8 个基本步骤

确保您的内容在无头 CMS 环境中大放异彩。按照我们的 8 个步骤进行一流的无头 SEO。 无头内容管理系统 &#xff08;CMS&#xff09; 正在兴起&#xff0c;迅速被宜家、耐克和国家地理等大品牌采用。 那里有很多选择&#xff0c;而且更有可能的是&#xff0c;作为 SEO 专业人士…

宝塔+Let‘s Encrypt给网站安装免费SSL证书

文件验证老是不通过&#xff0c;遂选择DNS验证&#xff1a; DNS验证也不过&#xff0c;发现腾讯云DNS解析的时候填写不能填宝塔页面给的完整的“解析域名”内容&#xff0c;只需填前面一部分就行了&#xff1a; ref: https://cloud.tencent.com/document/product/302/54454

非隔离恒压ACDC稳压智能电源模块芯片推荐:SM7015

非隔离恒压ACDC稳压智能电源模块芯片是一种用于将交流&#xff08;AC&#xff09;电源转换为直流&#xff08;DC&#xff09;电源的集成电路。这种芯片具有恒压输出功能&#xff0c;能够保持输出电压的稳定&#xff0c;适用于各种需要直流电源的应用场景。 非隔离电源模块通常…

SQL 多字段条件查询

SQL 多字段条件查询 一个数据库表&#xff0c;几十个字段&#xff0c;查找任意字段里包含北京的记录&#xff0c;在 mysql 里这句 sql 应该是这样&#xff1a; SELECT * FROM table WHERE concat(field1,field2,field3……fieldn) like ‘% 北京 %’ 反正是少不了将几十个字…

Angular 进阶之五: Signals到底用不用?

Angular 在V16的时候推出了Signals&#xff0c;在17正式作为主打功能之一强烈推荐&#xff0c;看过了各种博主的各种科普文章也没说明白&#xff0c;到底这东西值不值得用&#xff1f;毕竟项目大了&#xff0c;重构代码也不是闹着玩儿的。各种科普文章主要在说两点&#xff1a;…

Docker可视化界面【Portainer】安装

Portainer是一个可视化的容器镜像的图形管理工具&#xff0c;利用Portainer可以轻松构建&#xff0c;管理和维护Docker环境。 而且完全免费&#xff0c;基于容器化的安装方式&#xff0c;方便高效部署。 一、拉取镜像 docker pull portainer/portainer 二、运行portainer容…

如何将采购时间从几天缩短为几小时?

从事采购工作时&#xff0c;采购需要多长时间是面临的常见挑战之一。 采购是供应链中的一个环节&#xff0c;大家都不想看到整个流程被拖慢&#xff0c;但很多时候&#xff0c;事情往往向超出控制范围的方向发展。不过&#xff0c;企业可以通过多种方式简化采购和管理整个采购…

Redis实现日榜|直播间榜单|排行榜|Redis实现日榜01

前言 直播间贡献榜是一种常见的直播平台功能&#xff0c;用于展示观众在直播过程中的贡献情况。它可以根据观众的互动行为和贡献值进行排名&#xff0c;并实时更新&#xff0c;以鼓励观众积极参与直播活动。 在直播间贡献榜中&#xff0c;每个观众都有一个对应的贡献值&#…

华为鸿蒙4.0来袭:带你从0开始上手鸿蒙开发!

今天我们来聊一聊鸿蒙。 鸿蒙是什么呢&#xff1f;它是华为自家打造的一个操作系统。就好比苹果有iOS&#xff0c;谷歌有Android&#xff0c;华为也想有一个属于自己的系统&#xff0c;这就是鸿蒙。 那鸿蒙有什么特色呢&#xff1f;首先&#xff0c;它采用了微内核设计。微内…

软件测试:最强面试题整理出炉附答案,一点点小总结,建议收藏

一、Web自动化测试 1.Selenium中hidden或者是display &#xff1d; none的元素是否可以定位到&#xff1f; 不能,可以写JavaScript将标签中的hidden先改为0&#xff0c;再定位元素 2.Selenium中如何保证操作元素的成功率&#xff1f;也就是说如何保证我点击的元素一定是可以点…

云渲染Blender怎么用 Blender云渲染设置教程

作为一个免费且开源的三维创作套件&#xff0c;Blender为独立艺术家和小规模的创意团队提供了一个功能丰富的平台&#xff0c;涵盖了从建模、雕刻到动力学模拟、动画和高级渲染的全套工作流程。随着其支持的特效和视觉质量的不断提升&#xff0c;Blender项目的渲染耗时也显著增…

抖店入驻资质是什么?

我是电商珠珠 抖店的热度很高&#xff0c;很多新手想要入驻&#xff0c;但是不知道需要准备什么资料&#xff0c;入驻需要什么资质。 今天&#xff0c;我就来给大家具体的讲一讲。 一、营业执照 营业执照有两种&#xff0c;一种为个体的&#xff0c;一种是企业的。二者之间…