Skip to content

Commit

Permalink
deps and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed May 25, 2024
1 parent 95c1a12 commit 0a6f5f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ There are some programs in folder `test` to test the TCP communication:
### **WORK IN PROGRESS**
-->
## Changelog

### __WORK IN PROGRESS__
* (Q7Jensen) Fixed error at aligning addresses to word
* (Apollon77) Added device id to some errors

### 6.2.2 (2024-04-26)
* (Apollon77) Downgrade gulp to 4.0.2 to fix build

Expand Down
18 changes: 9 additions & 9 deletions lib/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function Master(options, adapter) {
scaleFactors[regs.deviceId][regs.config[n]._address] = val;
showDebug && adapter.log.debug(`[${prefixAddr}] Scale factor value stored from this address = ${val}`);
} catch (err) {
adapter.log.error(`Can not set value: ${err.message}`);
adapter.log.error(`Can not set value for [${regs.deviceId}]: ${err.message}`);
}
}
}
Expand Down Expand Up @@ -438,11 +438,11 @@ function Master(options, adapter) {
});
}

function pollResult(startTime, err, cb) {
function pollResult(startTime, deviceId, err, cb) {
if (err) {
errorCount++;

adapter.log.warn(`Poll error count: ${errorCount} code: ${JSON.stringify(err)}`);
adapter.log.warn(`[${deviceId}] Poll error count: ${errorCount} code: ${JSON.stringify(err)}`);
adapter.setState('info.connection', false, true);

if (errorCount > 12 * deviceIds.length) { // 2 reconnects did not help, restart adapter
Expand Down Expand Up @@ -481,7 +481,7 @@ function Master(options, adapter) {
let requestTimer = adapter.setTimeout(() => {
requestTimer = null;
if (connected && !isStop) {
pollResult(startTime, 'App Timeout', callback);
pollResult(startTime, device.coils.deviceId, `App Timeout`, callback);
}
}, options.config.timeout + 200);

Expand All @@ -492,7 +492,7 @@ function Master(options, adapter) {
clearTimeout(requestTimer);
requestTimer = null;
if (connected && !isStop) {
pollResult(startTime, err, callback);
pollResult(startTime, device.coils.deviceId, err, callback);
}
}
} else {
Expand All @@ -502,7 +502,7 @@ function Master(options, adapter) {
clearTimeout(requestTimer);
requestTimer = null;
if (connected && !isStop) {
pollResult(startTime, err, callback);
pollResult(startTime, device.coils.deviceId, err, callback);
}
}
} else {
Expand All @@ -512,7 +512,7 @@ function Master(options, adapter) {
clearTimeout(requestTimer);
requestTimer = null;
if (connected && !isStop) {
pollResult(startTime, err, callback);
pollResult(startTime, device.coils.deviceId, err, callback);
}
}
} else {
Expand All @@ -521,7 +521,7 @@ function Master(options, adapter) {
clearTimeout(requestTimer);
requestTimer = null;
if (connected && !isStop) {
pollResult(startTime, err, callback);
pollResult(startTime, device.coils.deviceId, err, callback);
}
}
});
Expand Down Expand Up @@ -891,4 +891,4 @@ function Master(options, adapter) {
return this;
}

module.exports = Master;
module.exports = Master;

0 comments on commit 0a6f5f2

Please sign in to comment.