Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTU over socket (second PR) #514

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
28 changes: 27 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,10 @@ class ModbusRTU extends EventEmitter {

// write buffer to serial port
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}

/**
Expand Down Expand Up @@ -903,7 +907,9 @@ class ModbusRTU extends EventEmitter {
// write buffer to serial port
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

this._port._transactionIdWrite += 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be removed

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}

/**
Expand Down Expand Up @@ -1080,6 +1086,10 @@ class ModbusRTU extends EventEmitter {

// write buffer to serial port
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}

/**
Expand Down Expand Up @@ -1142,6 +1152,10 @@ class ModbusRTU extends EventEmitter {

// write buffer to serial port
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}

/**
Expand Down Expand Up @@ -1178,6 +1192,10 @@ class ModbusRTU extends EventEmitter {

// write buffer to serial port
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}


Expand Down Expand Up @@ -1218,6 +1236,10 @@ class ModbusRTU extends EventEmitter {
buf.writeUInt8(chunck, 9);
buf.writeUInt16LE(crc16(buf.slice(0, -2)), codeLength);
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}

/**
Expand Down Expand Up @@ -1255,6 +1277,10 @@ class ModbusRTU extends EventEmitter {
buf.writeUInt16LE(crc16(buf.slice(0, -2)), codeLength);
// write buffer to serial port
_writeBufferToPort.call(this, buf, this._port._transactionIdWrite);

if (this._encapsulatedRTU) {
this._port._transactionIdWrite += 1;
}
}
}

Expand Down