Skip to content

Commit 0866241

Browse files
authored
runtime % support for FreeRTOS V11 (#57)
* runtime % support for FreeRTOS V11 In V11, FreeRTOS changed ulTotalRunTime from an integer to an array of integers. On SMP, the array has one entry per CPU, but it's still a one-element array even without SMP support compiled in. Try finding the length of the array with sizeof(a)/sizeof(a[0]). If that succeeds, sum all CPU runtimes to get the total runtime. If it fails, assume V10 or earlier and fall back to the previous technique. * correct FreeRTOS V11 runtime stats detection in help text generation * simplify implementation of FreeRTOS V11 runtime % support Convert `updateTotalRuntime()` to an async function. Use `RTOSVarHelper.getVarChildren()` to check for the presence of children and to get their values.
1 parent dc5d9c7 commit 0866241

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/rtos/rtos-freertos.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -345,22 +345,21 @@ export class RTOSFreeRTOS extends RTOSCommon.RTOSBase {
345345
});
346346
}
347347

348-
private updateTotalRuntime(frameId: number): Promise<void> {
349-
return new Promise<void>((resolve, reject) => {
350-
if (!this.ulTotalRunTime) {
351-
resolve();
352-
return;
348+
private async updateTotalRuntime(frameId: number): Promise<void> {
349+
if (!this.ulTotalRunTime) {
350+
return;
351+
}
352+
try {
353+
let total = 0;
354+
const children = await this.ulTotalRunTime.getVarChildren(frameId);
355+
for (const child of children) {
356+
total += parseInt(child.value || '');
353357
}
354-
this.ulTotalRunTime.getValue(frameId).then(
355-
(ret) => {
356-
this.ulTotalRunTimeVal = parseInt(ret || '');
357-
resolve();
358-
},
359-
(e) => {
360-
reject(e);
361-
}
362-
);
363-
});
358+
this.ulTotalRunTimeVal = total;
359+
} catch (e) {
360+
const ret = await this.ulTotalRunTime.getValue(frameId);
361+
this.ulTotalRunTimeVal = parseInt(ret || '');
362+
}
364363
}
365364

366365
public refresh(frameId: number): Promise<void> {

0 commit comments

Comments
 (0)