modbus-serial
Advanced tools
Comparing version 5.2.13 to 5.2.14
22
index.js
@@ -138,3 +138,3 @@ "use strict"; | ||
function _writeBufferToPort(buffer) { | ||
var transaction = this._transactions[this._port.transactionsCounter]; | ||
var transaction = this._transactions[this._port._transactionIdWrite]; | ||
@@ -212,4 +212,4 @@ this._port.write(buffer); | ||
/* init ports transaction id and counter */ | ||
modbus._port._transactionId = 1; | ||
modbus._port.transactionsCounter = 1; | ||
modbus._port._transactionIdRead = 1; | ||
modbus._port._transactionIdWrite = 1; | ||
@@ -221,5 +221,5 @@ /* On serial port success | ||
// set locale helpers variables | ||
var transaction = modbus._transactions[modbus._port._transactionId]; | ||
var transaction = modbus._transactions[modbus._port._transactionIdRead]; | ||
// the _transactionId can be missing, ignore wrong transaction it's | ||
// the _transactionIdRead can be missing, ignore wrong transaction it's | ||
if (!transaction) { | ||
@@ -387,3 +387,3 @@ return; | ||
// set state variables | ||
this._transactions[this._port.transactionsCounter] = { | ||
this._transactions[this._port._transactionIdWrite] = { | ||
nextAddress: address, | ||
@@ -441,3 +441,3 @@ nextCode: code, | ||
// set state variables | ||
this._transactions[this._port.transactionsCounter] = { | ||
this._transactions[this._port._transactionIdWrite] = { | ||
nextAddress: address, | ||
@@ -482,3 +482,3 @@ nextCode: code, | ||
// set state variables | ||
this._transactions[this._port.transactionsCounter] = { | ||
this._transactions[this._port._transactionIdWrite] = { | ||
nextAddress: address, | ||
@@ -528,3 +528,3 @@ nextCode: code, | ||
// set state variables | ||
this._transactions[this._port.transactionsCounter] = { | ||
this._transactions[this._port._transactionIdWrite] = { | ||
nextAddress: address, | ||
@@ -571,3 +571,3 @@ nextCode: code, | ||
// set state variables | ||
this._transactions[this._port.transactionsCounter] = { | ||
this._transactions[this._port._transactionIdWrite] = { | ||
nextAddress: address, | ||
@@ -627,3 +627,3 @@ nextCode: code, | ||
// set state variables | ||
this._transactions[this._port.transactionsCounter] = { | ||
this._transactions[this._port._transactionIdWrite] = { | ||
nextAddress: address, | ||
@@ -630,0 +630,0 @@ nextCode: code, |
{ | ||
"name": "modbus-serial", | ||
"version": "5.2.13", | ||
"version": "5.2.14", | ||
"description": "A pure JavaScript implemetation of MODBUS-RTU (Serial and TCP) for NodeJS.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,3 @@ "use strict"; | ||
this.callback = null; | ||
this.transactionsCounter = 1; | ||
this._transactionIdWrite = 1; | ||
@@ -57,3 +57,3 @@ // options | ||
// update transaction id | ||
modbus._transactionId = data.readUInt16BE(0); | ||
modbus._transactionIdRead = data.readUInt16BE(0); | ||
@@ -123,3 +123,3 @@ modbusSerialDebug({ action: "receive tcp port", data: data, buffer: buffer }); | ||
var buffer = new Buffer(data.length + MIN_MBAP_LENGTH - CRC_LENGTH); | ||
buffer.writeUInt16BE(this.transactionsCounter, 0); | ||
buffer.writeUInt16BE(this._transactionIdWrite, 0); | ||
buffer.writeUInt16BE(0, 2); | ||
@@ -130,3 +130,3 @@ buffer.writeUInt16BE(data.length - CRC_LENGTH, 4); | ||
// set next transaction id | ||
this.transactionsCounter = (this.transactionsCounter + 1) % MAX_TRANSACTIONS; | ||
this._transactionIdWrite = (this._transactionIdWrite + 1) % MAX_TRANSACTIONS; | ||
@@ -133,0 +133,0 @@ // send buffer to slave |
@@ -31,2 +31,3 @@ "use strict"; | ||
this.callback = null; | ||
this._transactionIdWrite = 1; | ||
@@ -132,3 +133,3 @@ // options | ||
// update transaction id | ||
this._transactionId = data.readUInt16BE(0); | ||
this._transactionIdRead = data.readUInt16BE(0); | ||
@@ -216,8 +217,5 @@ if (data.length > 0) { | ||
// get next transaction id | ||
var transactionsId = (this._transactionId + 1) % MAX_TRANSACTIONS; | ||
// remove crc and add mbap | ||
var buffer = new Buffer(data.length + MIN_MBAP_LENGTH - CRC_LENGTH); | ||
buffer.writeUInt16BE(transactionsId, 0); | ||
buffer.writeUInt16BE(this._transactionIdWrite, 0); | ||
buffer.writeUInt16BE(0, 2); | ||
@@ -227,2 +225,5 @@ buffer.writeUInt16BE(data.length - CRC_LENGTH, 4); | ||
// get next transaction id | ||
this._transactionIdWrite = (this._transactionIdWrite + 1) % MAX_TRANSACTIONS; | ||
// send buffer to slave | ||
@@ -229,0 +230,0 @@ this._client.write(buffer); |
@@ -175,5 +175,5 @@ "use strict"; | ||
port.write(new Buffer("0103000500045408", "hex")); | ||
expect(port._client._data.toString("hex")).to.equal("000400000006010300050004"); | ||
expect(port._client._data.toString("hex")).to.equal("000700000006010300050004"); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
177031
4478