Skip to content

Commit

Permalink
fix: catch error thrown in getMultipleHoldingRegisters
Browse files Browse the repository at this point in the history
  • Loading branch information
everhardt committed Jan 31, 2024
1 parent b49090b commit 1454cf0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions servers/servertcp_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,13 @@ function _handleReadMultipleRegisters(requestBuffer, vector, unitID, callback) {
}
});
} else {
const values = vector.getMultipleHoldingRegisters(address, length, unitID);
let values;
try {
values = vector.getMultipleHoldingRegisters(address, length, unitID);
} catch (error) {
callback(error);
return;
}
if (values.length === length) {
for (i = 0; i < length; i++) {
tryAndHandlePromiseOrValue(i, values);
Expand Down Expand Up @@ -434,7 +440,13 @@ function _handleReadMultipleRegistersEnron(requestBuffer, vector, unitID, enronT
}
});
} else {
const values = vector.getMultipleHoldingRegisters(address, length, unitID);
let values;
try {
values = vector.getMultipleHoldingRegisters(address, length, unitID);
} catch (error) {
callback(error);
return;
}
if (values.length === length) {
for (i = 0; i < length; i++) {
tryAndHandlePromiseOrValue(i, values);
Expand Down

0 comments on commit 1454cf0

Please sign in to comment.