Skip to content

Commit

Permalink
fix: catch error thrown in getMultipleHoldingRegisters (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
everhardt authored Jan 31, 2024
1 parent b49090b commit 6be368c
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 6be368c

Please sign in to comment.