IGD3000系列(一体屏)网关的app和文件系统的打包目录
lgq
2025-07-19 a7e0c81a31f5cbafaeaf97dab7f08caadadd1257
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var layer;
var form;
$(function () {
    layui.use(["layer", "form"],function () {
        layer = layui.layer;
        form = layui.form;
 
        form.render();
    });
});
 
function orderSend(id) {
    // var data = $("#"+id).val().replaceAll(" ", "");
    var data = $("#"+id).val();
    while (true){
        if(data.indexOf(" ") == -1){
            break;
        }
        data = data.replace(" ", "");
    }
    if(!data){
        // console.log("发送的数据不能是空!");
        window.parent.notify("发送的数据不能是空!");
        return false;
    }
    var param = {
        port: $("#device-port").val(),
        data: data
    };
    console.log('---------发送的数据-----' + data);
    console.log(param);
 
    //渲染发送的数据
    renderData($("#"+id).val(),"send");
    $.post("./cgi-bin/sys-com/send", JSON.stringify(param), function (data, status) {
        if ("success" == status) {
            console.log('---------接收到的数据--------' + data);
            $("#device-port").val(data.port);
            //渲染接收的数据
            renderData(data.data,"receive");
        } else {
            window.parent.parent.notify("接收数据时出错,请重新操作!");
        }
    }, "json");
};
 
function renderData(result, status) {
    var data;
    var time = new Date();
    time = time.getFullYear()
        + "-" + ((time.getMonth()+1) < 10 ? ("0" + (time.getMonth() + 1)) : (time.getMonth() + 1))
        + "-" + (time.getDate() < 10 ? ("0" + time.getDate()) : time.getDate())
        + " " + (time.getHours() < 10 ? ("0" + time.getHours()) : time.getHours())
        + ":" + (time.getMinutes() < 10 ? ("0" + time.getMinutes()) : time.getMinutes())
        + ":" + (time.getSeconds() < 10 ? ("0" + time.getSeconds()) : time.getSeconds());
 
    if(status == "send"){
        data = "<p class='send'>[" + time + "][发送]:" + result + "</p>";
    }else{
        data = "<p class='receive'>[" + time + "][接收]:" + hexCharCodeToStr(result) + "</p>";
    }
    $(".log-box").append(data);
    //设置滚动条始终位于最底端
    $(".log-box").scrollTop($(".log-box")[0].scrollHeight);
}
 
//判断数据接收格式并进行转译
function hexCharCodeToStr(result) {
    var data = "";
    if(form.val('form-port').code == "ASCII"){
        while (true){
            if(result.indexOf(" ") == -1){
                break;
            }
            result = result.replace(" ", "");
        }
        //去除字符串中的空格
        // result = result.replaceAll(" ", "");
        var len = result.length;
        if(len % 2 !== 0){
            window.parent.parent.notify("接收的数据中存在非法字符!该条数据将不进行转译!");
            return result;
        }
        var curCharCode;
        var resultStr = [];
        for (var i = 0; i < len; i = i + 2) {
            curCharCode = parseInt(result.substr(i, 2), 16);
            resultStr.push(String.fromCharCode(curCharCode));
        }
        data = resultStr.join("");
    }else{
        data = result;
    }
    return data;
}