Skip to content

Commit 07b4016

Browse files
committed
rebase master
1 parent d415fba commit 07b4016

File tree

10 files changed

+48
-21
lines changed

10 files changed

+48
-21
lines changed

rover-apps/arm_2021/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_executable(arm_2021)
2-
target_sources(arm_2021 PRIVATE ../common/src/main.cpp)
3-
target_include_directories(arm_2021 PUBLIC include ../common/include)
2+
target_sources(arm_2021 PRIVATE ${ROVER_APPS_DIR}/common/src/main.cpp)
3+
target_include_directories(arm_2021 PUBLIC include ${ROVER_APPS_DIR}/common/include)
44
target_link_libraries(arm_2021
55
PRIVATE
66
#Control

rover-apps/arm_2021/include/AppConfig.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
WatchdogModule arm_watchdog;
99

1010
std::vector<Module*> gModules = {
11-
// put modules here
1211
&arm_watchdog,
1312
};

rover-apps/common/include/WatchdogModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class WatchdogModule final : public Module {
1111
WatchdogModule();
1212

1313
/* Periodic function to kick the watchdog and restart its timer every 1s
14-
* */
14+
*/
1515
void periodic_1s(void) override;
1616

1717
void periodic_10s(void) override {}

rover-apps/common/src/main.cpp

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "AppConfig.h"
2+
#include "Logger.h"
23
#include "mbed.h"
34

45
Thread periodic_10s_thread(osPriorityNormal1);
@@ -12,39 +13,69 @@ void periodic_10s(void) {
1213
for (Module* module : gModules) {
1314
module->periodic_10s();
1415
}
15-
ThisThread::sleep_until(startTime + 10s);
16+
17+
auto nextStartTime = startTime + 10s;
18+
if (Kernel::Clock::now() > nextStartTime) {
19+
Utility::logger << "Reseting periodic 10s task timing as it failed to hit the deadline!\n";
20+
nextStartTime = Kernel::Clock::now() + 10s;
21+
}
22+
ThisThread::sleep_until(nextStartTime);
1623
}
1724

1825
void periodic_1s(void) {
1926
auto startTime = Kernel::Clock::now();
2027
for (Module* module : gModules) {
2128
module->periodic_1s();
2229
}
23-
ThisThread::sleep_until(startTime + 1s);
30+
31+
auto nextStartTime = startTime + 1s;
32+
if (Kernel::Clock::now() > nextStartTime) {
33+
Utility::logger << "Reseting periodic 1s task timing as it failed to hit the deadline!\n";
34+
nextStartTime = Kernel::Clock::now() + 1s;
35+
}
36+
ThisThread::sleep_until(nextStartTime);
2437
}
2538

2639
void periodic_100ms(void) {
2740
auto startTime = Kernel::Clock::now();
2841
for (Module* module : gModules) {
2942
module->periodic_100ms();
3043
}
31-
ThisThread::sleep_until(startTime + 100ms);
44+
45+
auto nextStartTime = startTime + 100ms;
46+
if (Kernel::Clock::now() > nextStartTime) {
47+
Utility::logger << "Reseting periodic 100ms task timing as it failed to hit the deadline!\n";
48+
nextStartTime = Kernel::Clock::now() + 100ms;
49+
}
50+
ThisThread::sleep_until(nextStartTime);
3251
}
3352

3453
void periodic_10ms(void) {
3554
auto startTime = Kernel::Clock::now();
3655
for (Module* module : gModules) {
3756
module->periodic_10ms();
3857
}
39-
ThisThread::sleep_until(startTime + 10ms);
58+
59+
auto nextStartTime = startTime + 10ms;
60+
if (Kernel::Clock::now() > nextStartTime) {
61+
Utility::logger << "Reseting periodic 10ms task timing as it failed to hit the deadline!\n";
62+
nextStartTime = Kernel::Clock::now() + 10ms;
63+
}
64+
ThisThread::sleep_until(nextStartTime);
4065
}
4166

4267
void periodic_1ms(void) {
4368
auto startTime = Kernel::Clock::now();
4469
for (Module* module : gModules) {
4570
module->periodic_1ms();
4671
}
47-
ThisThread::sleep_until(startTime + 1ms);
72+
73+
auto nextStartTime = startTime + 1ms;
74+
if (Kernel::Clock::now() > nextStartTime) {
75+
Utility::logger << "Reseting periodic 1ms task timing as it failed to hit the deadline!\n";
76+
nextStartTime = Kernel::Clock::now() + 1ms;
77+
}
78+
ThisThread::sleep_until(nextStartTime);
4879
}
4980

5081
int main() {
@@ -54,6 +85,6 @@ int main() {
5485
periodic_1s_thread.start(periodic_1s);
5586
periodic_10s_thread.start(periodic_10s);
5687

57-
while (true) {
58-
}
88+
while (true)
89+
;
5990
}

rover-apps/gimbal_2021/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_executable(gimbal_2021)
2-
target_sources(gimbal_2021 PRIVATE ../common/src/main.cpp)
3-
target_include_directories(gimbal_2021 PUBLIC include ../common/include)
2+
target_sources(gimbal_2021 PRIVATE ${ROVER_APPS_DIR}/common/src/main.cpp)
3+
target_include_directories(gimbal_2021 PUBLIC include ${ROVER_APPS_DIR}/common/include)
44
target_link_libraries(gimbal_2021
55
PRIVATE
66
#Control

rover-apps/gimbal_2021/include/AppConfig.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
WatchdogModule gimbal_watchdog;
99

1010
std::vector<Module*> gModules = {
11-
// put modules here
1211
&gimbal_watchdog,
1312
};

rover-apps/pdb_2021/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ add_library(PDB_Monitoring STATIC)
22
target_sources(PDB_Monitoring PRIVATE src/PDBMonitoring.cpp)
33
target_include_directories(PDB_Monitoring PUBLIC
44
include
5-
../common/include
5+
${ROVER_APPS_DIR}/common/include
66
)
77
target_link_libraries(PDB_Monitoring
88
PRIVATE
@@ -11,8 +11,8 @@ target_link_libraries(PDB_Monitoring
1111
)
1212

1313
add_executable(pdb_2021)
14-
target_sources(pdb_2021 PRIVATE ../common/src/main.cpp)
15-
target_include_directories(pdb_2021 PUBLIC include ../common/include)
14+
target_sources(pdb_2021 PRIVATE ${ROVER_APPS_DIR}/common/src/main.cpp)
15+
target_include_directories(pdb_2021 PUBLIC include ${ROVER_APPS_DIR}/common/include)
1616
target_link_libraries(pdb_2021
1717
PRIVATE
1818
CANBus

rover-apps/pdb_2021/include/AppConfig.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
PDBMonitoring PDB_monitoring;
99

1010
std::vector<Module*> gModules = {
11-
// put modules here
1211
&PDB_monitoring,
1312
};

rover-apps/science_2021/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_executable(science_2021)
2-
target_sources(science_2021 PRIVATE ../common/src/main.cpp)
3-
target_include_directories(science_2021 PUBLIC include ../common/include)
2+
target_sources(science_2021 PRIVATE ${ROVER_APPS_DIR}/common/src/main.cpp)
3+
target_include_directories(science_2021 PUBLIC include ${ROVER_APPS_DIR}/common/include)
44
target_link_libraries(science_2021
55
PRIVATE
66
#Control

rover-apps/science_2021/include/AppConfig.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
WatchdogModule science_watchdog;
99

1010
std::vector<Module*> gModules = {
11-
// put modules here
1211
&science_watchdog,
1312
};

0 commit comments

Comments
 (0)