1
+ #include " FreeRTOS.h"
1
2
#include " GroundStationComms.hpp"
2
3
#include " MavlinkTranslator.hpp"
3
4
#include " TimerInterrupt.hpp"
4
- #include " FreeRTOS.h"
5
5
#include " task.h"
6
6
7
7
TelemetryManager::TelemetryManager () {
8
8
this ->MT = MavlinkTranslator ();
9
9
this ->GSC = GroundStationComms ();
10
10
}
11
11
12
+ TelemetryManager::~TelemetryManager () {
13
+ // Destructor
14
+ }
15
+
12
16
/* *
13
17
* @brief Initialize TM threads and timer interrupts.
14
18
*
15
19
*/
16
20
void TelemetryManager::init () {
17
21
// initialize the timer interrupts
18
- createTimerInterrupts ();
22
+ initTimerInterrupts ();
23
+
24
+ // Init TM tasks
25
+ initTasks ();
26
+
27
+ // Start the scheduler
28
+ vTaskStartScheduler (); // should this be in system manager instead?
29
+ }
30
+
31
+ void TelemetryManager::initTimerInterrupts () {
32
+ /* *
33
+ * @brief This interrupt service routine is called every 1000ms. It is responsible for
34
+ * sending the highest priority drone "state" data to the ground station. Data such as
35
+ * heartbeat message, altitude, attitude, latitude, longitude... And anything else deemed
36
+ * important enough to be transmitted at a regular interval. This is the highest priority
37
+ * data in the GSC.highPriorityTransmitBuffer.
38
+ *
39
+ */
40
+ TimerInterrupt dispatchHighPriorityInterrupt1000Ms (
41
+ " dispatchHighPriority1000Ms" , configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY, 500 , *this ,
42
+ [](TelemetryManager& tm) -> void {
43
+ auto GSC = tm.GSC ;
44
+
45
+ // START: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
19
46
47
+ // END: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
48
+
49
+ // transmit the data via GSC.sendToGroundStation(); function
50
+ GSC.sendToGroundStation (GSC.highPriorityTransmitBuffer );
51
+ });
52
+ }
53
+
54
+ void TelemetryManager::initTasks () {
20
55
// Initialize translateToMavlinkThread as a FreeRTOS task
21
56
xTaskCreate (TelemetryManager::translateToMavlinkThreadStatic, // Task function
22
57
" translateToMavlinkThread" , // Task name
@@ -34,9 +69,6 @@ void TelemetryManager::init() {
34
69
tskIDLE_PRIORITY + 1 , // Task priority
35
70
NULL // Task handle
36
71
);
37
-
38
- // Start the scheduler
39
- vTaskStartScheduler (); // should this be in system manager instead?
40
72
}
41
73
42
74
/* *
@@ -76,26 +108,3 @@ void TelemetryManager::sendLowPriorityData() {
76
108
// transmit low priority the data via GSC.sendToGroundStation(); function
77
109
GSC.sendToGroundStation (GSC.lowPriorityTransmitBuffer );
78
110
}
79
-
80
- void TelemetryManager::createTimerInterrupts () {
81
- /* *
82
- * @brief This interrupt service routine is called every 1000ms. It is responsible for
83
- * sending the highest priority drone "state" data to the ground station. Data such as
84
- * heartbeat message, altitude, attitude, latitude, longitude... And anything else deemed
85
- * important enough to be transmitted at a regular interval. This is the highest priority
86
- * data in the GSC.highPriorityTransmitBuffer.
87
- *
88
- */
89
- TimerInterrupt dispatchHighPriorityInterrupt1000Ms (
90
- " dispatchHighPriority1000Ms" , configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY, 500 , *this ,
91
- [](TelemetryManager& tm) -> void {
92
- auto GSC = tm.GSC ;
93
-
94
- // START: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
95
-
96
- // END: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
97
-
98
- // transmit the data via GSC.sendToGroundStation(); function
99
- GSC.sendToGroundStation (GSC.highPriorityTransmitBuffer );
100
- });
101
- }
0 commit comments