Skip to content

Fix #8 - Add fill byte in writeItems #9

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/s7endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,15 @@ class S7Endpoint extends EventEmitter {
new Promise((res, rej) => setTimeout(() => rej(new NodeS7Error('ERR_TIMEOUT', 'Timeout connecting to the transport')), 10000).unref())
]);

race.then(transport => {
this._transport = transport;
race.then((transport) => {
this._transport.on('error', e => this._onTransportError(e));
this._transport.on('close', () => this._onTransportClose());
this._transport.on('end', () => this._onTransportEnd());
this._createS7Connection();
this._connection.connect();
}).catch(e => this._onTransportError(e));
}

/**
* Creates an ISO-on-TCP transport with the parameters
* supplied on the constructor
Expand All @@ -203,11 +202,11 @@ class S7Endpoint extends EventEmitter {
// handler to reject the promise on connection-time errors
const handleRejection = e => reject(e);

let stream = isoOnTcp.createConnection(this._connOptsTcp, () => {
stream.off('error', handleRejection);
resolve(stream);
this._transport = isoOnTcp.createConnection(this._connOptsTcp, () => {
this._transport.off('error', handleRejection);
resolve(this._transport);
});
stream.on('error', handleRejection);
this._transport.on('error', handleRejection);
})
}

Expand Down Expand Up @@ -1114,4 +1113,4 @@ class S7Endpoint extends EventEmitter {
}
}

module.exports = S7Endpoint
module.exports = S7Endpoint
2 changes: 1 addition & 1 deletion src/s7itemGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class S7ItemGroup extends EventEmitter {
}

let buf = item.getWriteBuffer(value);
let reqItemLength = overheadPerItem + buf.length;
let reqItemLength = overheadPerItem + item.byteLengthWithFill;

// TODO - maybe we can split an item in multiple write request parts
if (reqItemLength > maxPayloadSize) {
Expand Down