Here is my node js code
if (protocol == '01') {
console.log('...goint to get Ack Obj...');
var o = getAckObj(hexString);
console.log('...ack obj received...');
var msg = ackMsg(o);
console.log('..going to write buffer...');
socket.write(new Buffer(msg, 'hex'));
console.log('Server sent welcome: ' + msg);
}
.....
function ackMsg(dataObj) {
var ackText = '';
dataObj.len = '05';
var e = crc16(dataObj.len + dataObj.protocol + dataObj.serial, 'hex');
dataObj.error = e.toString(16);
return dataObj.start + dataObj.len + dataObj.protocol + dataObj.serial + dataObj.error + dataObj.stop;
}
Here is the value in hexString 78780d010387113120864842000ccbe40d0a
On the console, lay out
...goint to get Ack Obj...
...ack obj received...
..going to write buffer...
buffer.js:348
ret = this.parent.hexWrite(string, this.offset + offset, length);
source
share