zoukankan      html  css  js  c++  java
  • TCP常用方法

    //格式化为16进制输出指令
    function fromateSendCode($code){
        $codeArr = getCodeWithSpace($code);
        for($i=0; $i<count($codeArr); $i++){
            $cmdHex[] = chr(hexdec($codeArr[$i]));
        }
        $cmdHex = implode($cmdHex);
        return $cmdHex;
    }
    
    //格式化收到指令
    function formateRevice($data){
        $receiveData = str_split(bin2hex($data), 2);
        $s='';
        foreach ($receiveData as $value) {
            $s.=$value;
        }
        return $s;
    }
    /**
     * 对16进制支付串进行和运算 和校验
     * @param  string $string 16进制字符串
     * @return int 16进制
     */
    function converTo16Space($codeArr){
        $s = '';
        foreach ($codeArr as $value) {
            $dec = hexdec($value);
            if($s){
                $s = $s+$dec;//&异或校验
            }else{
                $s = $dec;
            }
        }
        return substr(strtoupper(dechex($s)),-2);
    }

    另附通过韦根26协议转8位十进制方法

    //卡号转八位十六进制
    //http://www.chinadmd.com/file/zwixiuwxsxxwiatcauevazor_1.html
    function cardToHex($cardNo){
        $head = substr($cardNo, 0, 3);
        $body = substr($cardNo, -5);
        $hexHead = dechex($head);
        $hexBody = dechex($body);
        $hexBody = substr($hexBody, -2).substr($hexBody, 0, 2);
        $hex = $hexBody.$hexHead;
        $hex = strtoupper(str_pad($hex, 8, '0', STR_PAD_RIGHT ));
        return $hex;
    }
  • 相关阅读:
    flume未解之谜
    flume source,sinks类型官方翻译
    flume-event类
    flume课件(连)
    source监控端口,telnet写入此端口。sinks指定目录,文件以默认时间滚动生成
    linux命令拾遗
    nginx内置变量
    nginx.conf
    hive事物开启
    hiveHA
  • 原文地址:https://www.cnblogs.com/kkform/p/9236128.html
Copyright © 2011-2022 走看看