First commit

This commit is contained in:
2025-10-02 10:33:06 +08:00
parent 198b8bf2a6
commit c38eed4a22
5512 changed files with 958855 additions and 0 deletions

61
app/im/controller/test.php Executable file
View File

@@ -0,0 +1,61 @@
<?php
//include 'crc.php';
include 'net.php';
//打印十六进制(可以不用)
function println($bytes) {
for($i=0;$i<count($bytes);$i++)
{
printf("%02X ", $bytes[$i]);
}
printf(".");
}
//这里开始
$net = new net();
$net->listen('192.168.1.55', 50000);
while(true) {
$cs = $net->accept();
while($cs) {
try{
$ret = $net->recv_bytes($cs, 1024);
abc($ret);
//println($ret);
}
catch (Exception $e)
{
//printf('cs close');
break;
}
}
}
$net->close();
//abc处理读取到的卡4字节
function abc($ret)
{
$len = $ret[4];
if($len < 14)
{
//printf('无效数据');
return ;
}
//
$count = $ret[9];
$count = ($count - 3) / 4;
//
for($i=0; $i<$count; $i++)
{
$idx = 10 + ($i * 4);
$card = sprintf("%02X%02X%02X%02X", $ret[$idx+0], $ret[$idx+1], $ret[$idx+2], $ret[$idx+3]);//这是获取到的卡数据(按文档意思可能会读到多张卡,处理这个$card就可以了
printf('card['.$i.']>>'.$card.' | ');
}
}
?>