Skip to content

Commit 1074697

Browse files
remove send_carstate_msg() from statemachine thread
1 parent 65e34a5 commit 1074697

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

Core/Inc/u_threads.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void vEFuses(ULONG thread_input);
3030
void vMux(ULONG thread_input);
3131
void vPeripherals(ULONG thread_input);
3232
void vTest(ULONG thread_input);
33-
void vRTDS(ULONG thread_input);
33+
void vTelemetry(ULONG thread_input);
3434

3535

3636
#endif /* u_threads.h */

Core/Src/u_threads.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define PRIO_vShutdown 2
4242
#define PRIO_vEFuses 3
4343
#define PRIO_vMux 3
44-
#define PRIO_vRTDS 3
44+
#define PRIO_vTelemetry 3
4545
#define PRIO_vTest 3
4646
#define PRIO_vPeripherals 3
4747

@@ -273,16 +273,12 @@ static thread_t statemachine_thread = {
273273
};
274274
void vStatemachine(ULONG thread_input) {
275275

276-
const uint32_t telem_timeout = 50;
277-
278276
while(1) {
279277
state_req_t new_state_req;
280-
while(queue_receive(&state_transition_queue, &new_state_req, telem_timeout) == U_SUCCESS) {
278+
while(queue_receive(&state_transition_queue, &new_state_req, TX_WAIT_FOREVER) == U_SUCCESS) {
281279
statemachine_process(new_state_req);
282280
}
283281

284-
send_carstate_msg();
285-
286282
/* No sleep. Thread timing is controlled completely by the queue timeout. */
287283
}
288284
}
@@ -879,24 +875,23 @@ void vPeripherals(ULONG thread_input) {
879875
}
880876
}
881877

882-
/* RTDS Telemetry Thread.
883-
This thread is for RTDS telemetry. The actual state of the RTDS is managed by the statemachine. */
884-
static thread_t rtds_telemetry_thread = {
885-
.name = "RTDS Telemetry Thread", /* Name */
878+
/* Misc. Telemetry Thread.
879+
This thread periodically reports the RTDS and statemachine state data. The actual states of these things are managed by the statemachine thread. This is specifically for telemetry. */
880+
static thread_t misc_telemetry_thread = {
881+
.name = "Misc Telemetry Thread", /* Name */
886882
.size = 2048, /* Stack Size (in bytes) */
887-
.priority = PRIO_vRTDS, /* Priority */
883+
.priority = PRIO_vTelemetry, /* Priority */
888884
.threshold = 0, /* Preemption Threshold */
889885
.time_slice = TX_NO_TIME_SLICE, /* Time Slice */
890886
.auto_start = TX_AUTO_START, /* Auto Start */
891887
.sleep = 100, /* Sleep (in ticks) */
892-
.function = vRTDS /* Thread Function */
888+
.function = vTelemetry /* Thread Function */
893889
};
894-
void vRTDS(ULONG thread_input) {
890+
void vTelemetry(ULONG thread_input) {
895891

896892
while(1) {
897893

898-
PRINTLN_INFO("thread ran");
899-
894+
/* Send RTDS State Telemetry. */
900895
bool rtds_pin_state = rtds_readRTDS();
901896
bool rtds_sounding_state = false;
902897
bool rtds_reverse_state = false;
@@ -914,8 +909,11 @@ void vRTDS(ULONG thread_input) {
914909

915910
send_rtds_state_message(rtds_pin_state, rtds_sounding_state, rtds_reverse_state, error_state);
916911

912+
/* Send Carstate message. */
913+
send_carstate_msg();
914+
917915
/* Sleep Thread for specified number of ticks. */
918-
tx_thread_sleep(rtds_telemetry_thread.sleep);
916+
tx_thread_sleep(misc_telemetry_thread.sleep);
919917
}
920918
}
921919

0 commit comments

Comments
 (0)