首页 > 解决方案 > Gps 设备数据不可编辑

问题描述

我正在使用 BW08 设备跟踪并将数据发送到自己的服务器和用节点 js 编写的服务器。但是设备在我的服务器上发送数据为

    *
    aD 'T�8

    aD 'T�8

    *
    aD 'T�8.79.48.102: xx

    *
    xx   �
                �C��8���n�

    xx   �
                �C��8���n�

如何读取数据?我的NodeJS服务器代码在这里:============================================ =================================

var net = require('net');
var HOST = 'xxx.xxx.x.xxx';
var PORT = 17000;

// Create a server instance, and chain the listen function to it
// The function passed to net.createServer() becomes the event handler for the 'connection' event
// The sock object the callback function receives UNIQUE for each connection
net.createServer(function(sock) {
    sock.setEncoding('utf8');
    // We have a connection - a socket object is assigned to the connection automatically
    console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.remotePort);

    // Add a 'data' event handler to this instance of socket
    sock.on('data', function(data) {
        console.log('*');
        console.log(data.toString('ascii'))
        console.log(data.toString());
        console.log('*');
        console.log('DATA ' + sock.remoteAddress + ': ' + data);
        // Write the data back to the socket, the client will receive it as data from the server
        sock.write('You said "' + data + '"');
    });

    // Add a 'close' event handler to this instance of socket
    sock.on('close', function(data) {
        console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort);
    });
}).listen(PORT, HOST);

console.log('Server listening on ' + HOST +':'+ PORT);

标签: node.jsgps

解决方案


推荐阅读