Skip to content

Commit

Permalink
Consider UDS time delta also after scan operations
Browse files Browse the repository at this point in the history
  • Loading branch information
MyHomeMyData committed Aug 18, 2024
1 parent 8ae3c60 commit 1133d7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/udsScan.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class udsScan {
for (const baseAddr of Object(this.udsScanAddrRange).values()) {
for (const addr of Object(range(Number(this.udsScanAddrSpan), Number(baseAddr))).values()) {
await this.startupScanUdsDevice(ctx, addr);
await this.sleep(ctx, 50);
await this.sleep(ctx, ctx.udsTimeDelta);
}
}
const tsAbort = new Date().getTime() + this.udsMaxTrialsDevScan*this.udsTimeoutDevScan+250;
Expand All @@ -231,6 +231,7 @@ class udsScan {
// Restart all previously running workers:
for (const worker of Object.values(ctx.E3UdsWorkers)) {
await worker.startup(ctx,'normal');
await this.sleep(ctx, ctx.udsTimeDelta);
}

if (this.cntUdsScansActive < 0) await ctx.log.warn('UDS scan finished. Number of retries / active UDS scans (should be 0): '+String(this.udsScanDidsCntRetries)+' / '+String(this.cntUdsScansActive));
Expand Down Expand Up @@ -342,6 +343,7 @@ class udsScan {
// Restart all previously running workers:
for (const worker of Object.values(ctx.E3UdsWorkers)) {
await worker.startup(ctx,'normal');
await this.sleep(ctx, ctx.udsTimeDelta);
}
}

Expand Down
4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class E3oncan extends utils.Adapter {
this.udsWorkers = {};
this.udsTimeout = 7500; // Timeout (ms) for normal UDS communication
this.udsDevices = []; // Confirmed & edited UDS devices
this.udsTimeDelta = 50; // Time delta (ms) between UDS schedules
this.udsTimeoutHandles = [];

this.didsVersionTC = '20240309'; // Change of type of numerical dids to Number at this version
Expand Down Expand Up @@ -416,13 +417,12 @@ class E3oncan extends utils.Adapter {
}
}
let timeOffset = 0;
let timeDelta = 50; // Time delta (ms) between UDS schedules
for (const worker of Object.values(this.E3UdsWorkers)) {
const toh = this.setTimeout(async function(ctx, worker) {
await worker.startup(ctx, 'normal');
await ctx.subscribeStates(ctx.namespace+'.'+worker.config.stateBase+'.*',ctx.onStateChange);
}, timeOffset, this, worker);
timeOffset += timeDelta;
timeOffset += this.udsTimeDelta;
this.udsTimeoutHandles.push(toh);
}
}
Expand Down

0 comments on commit 1133d7a

Please sign in to comment.