ADD cpu logger
This commit is contained in:
parent
4c174ce444
commit
c66c8a0963
@ -22,3 +22,7 @@ Test sensor libraries :
|
||||
```terminal
|
||||
mbed test -m DISCO_H747I -t GCC_ARM -n advdembsof_library-tests-sensors-hdc1000 --compile --run
|
||||
```
|
||||
|
||||
# Some questions
|
||||
## If you print CPU statistics at the end of every major cycle (in the super-loop), what CPU usage do you observe? How can you explain the observed CPU uptime?
|
||||
We observe a 100% usage because on each CPU cycle it compare if time is done.
|
@ -14,6 +14,7 @@
|
||||
"platform.stdio-baud-rate": 115200,
|
||||
"platform.default-serial-baud-rate": 115200,
|
||||
"platform.stdio-buffered-serial": true,
|
||||
"platform.all-stats-enabled": true,
|
||||
"target.printf_lib":"minimal-printf",
|
||||
"platform.minimal-printf-enable-floating-point": true,
|
||||
"platform.minimal-printf-set-floating-point-max-decimals": 2
|
||||
|
@ -54,13 +54,13 @@ static constexpr std::chrono::milliseconds kDisplayTask2Period = 1600ms;
|
||||
static constexpr std::chrono::milliseconds kDisplayTask2Delay = 1200ms;
|
||||
static constexpr std::chrono::milliseconds kDisplayTask2ComputationTime = 100ms;
|
||||
|
||||
// TODO: implement the constructor
|
||||
|
||||
BikeSystem::BikeSystem() :
|
||||
_gearDevice(_timer),
|
||||
_pedalDevice(_timer),
|
||||
_resetDevice(_timer),
|
||||
_speedometer(_timer)
|
||||
_speedometer(_timer),
|
||||
_cpuLogger(_timer)
|
||||
{
|
||||
|
||||
}
|
||||
@ -70,14 +70,10 @@ void BikeSystem::start() {
|
||||
|
||||
init();
|
||||
|
||||
// TODO: implement the super-loop based for implementing the appropriate schedule
|
||||
// Done
|
||||
while (true) {
|
||||
auto startTime = _timer.elapsed_time();
|
||||
|
||||
// TODO: implement calls to different tasks based on computed schedule
|
||||
// Done
|
||||
gearTask(); // 100ms : 0ms -> 100ms
|
||||
gearTask(); // 100ms : 0ms -> 100ms
|
||||
speedDistanceTask(); // 200ms : 100ms -> 300ms
|
||||
displayTask1(); // 200ms : 300ms -> 500ms
|
||||
speedDistanceTask(); // 200ms : 500ms -> 700ms
|
||||
@ -106,6 +102,10 @@ void BikeSystem::start() {
|
||||
break;
|
||||
}
|
||||
|
||||
#if !defined(MBED_TEST_MODE)
|
||||
_cpuLogger.printStats();
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,8 @@ void BikeSystem::gearTask() {
|
||||
_currentGearSize = _gearDevice.getCurrentGearSize();
|
||||
|
||||
_taskLogger.logPeriodAndExecutionTime(
|
||||
_timer, advembsof::TaskLogger::kGearTaskIndex, taskStartTime);
|
||||
_timer, advembsof::TaskLogger::kGearTaskIndex, taskStartTime
|
||||
);
|
||||
}
|
||||
|
||||
void BikeSystem::speedDistanceTask() {
|
||||
@ -159,7 +160,8 @@ void BikeSystem::speedDistanceTask() {
|
||||
_traveledDistance = _speedometer.getDistance();
|
||||
|
||||
_taskLogger.logPeriodAndExecutionTime(
|
||||
_timer, advembsof::TaskLogger::kSpeedTaskIndex, taskStartTime);
|
||||
_timer, advembsof::TaskLogger::kSpeedTaskIndex, taskStartTime
|
||||
);
|
||||
}
|
||||
|
||||
void BikeSystem::temperatureTask() {
|
||||
|
@ -27,6 +27,7 @@
|
||||
// from advembsof
|
||||
#include "display_device.hpp"
|
||||
#include "task_logger.hpp"
|
||||
#include "cpu_logger.hpp"
|
||||
|
||||
// from common
|
||||
#include "sensor_device.hpp"
|
||||
@ -93,6 +94,9 @@ class BikeSystem {
|
||||
|
||||
// used for logging task info
|
||||
advembsof::TaskLogger _taskLogger;
|
||||
|
||||
// cpu logger to measure cpu usage
|
||||
advembsof::CPULogger _cpuLogger;
|
||||
};
|
||||
|
||||
} // namespace static_scheduling
|
Loading…
x
Reference in New Issue
Block a user