我正在使用BW08设备跟踪并将数据发送到自己的服务器和用node 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);