diff --git a/lib/Server/ReadStream.js b/lib/Server/ReadStream.js index dbc0126..3c6ce77 100644 --- a/lib/Server/ReadStream.js +++ b/lib/Server/ReadStream.js @@ -29,11 +29,10 @@ ReadStream.prototype._transform = function (chunk, encoding, next) { this.pending = Buffer.concat([ this.pending, chunk ]); } - while (this.pending.length >= 12) { + while (this.pending.length >= 6) { var pkg_len = this.pending.readUInt16BE(4) + 6; if (this.pending.length < pkg_len) return next(); - if (pkg_len < 12) return next(); // every function code needs at least 4 additional bytes for "from" and "to". TODO: for WRITE_MULTIPLE_*, we could even check in more detail var data = this.pending.slice(8, pkg_len); var pkg = { diff --git a/package.json b/package.json index d78d806..bdc6370 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "modbus-tcp", - "version" : "0.4.6", + "version" : "0.4.7", "description" : "Modbus TCP/IP", "main" : "lib/Modbus.js", "repository" : "http://github.com/dresende/node-modbus-tcp.git",