@@ -268,18 +268,20 @@ static thread_t statemachine_thread = {
268268 .threshold = 0 , /* Preemption Threshold */
269269 .time_slice = TX_NO_TIME_SLICE , /* Time Slice */
270270 .auto_start = TX_AUTO_START , /* Auto Start */
271- .sleep = 0 , /* Sleep (in ticks) */
271+ .sleep = 200 , /* Sleep (in ticks) */
272272 .function = vStatemachine /* Thread Function */
273273 };
274274void vStatemachine (ULONG thread_input ) {
275275
276276 while (1 ) {
277277 state_req_t new_state_req ;
278- while (queue_receive (& state_transition_queue , & new_state_req , TX_WAIT_FOREVER ) == U_SUCCESS ) {
279- statemachine_process (new_state_req );
280- }
281-
282- /* No sleep. Thread timing is controlled completely by the queue timeout. */
278+
279+ // check if there is a transition in the queue, if not skip processing
280+ UINT status = queue_receive (& state_transition_queue , & new_state_req , statemachine_thread .sleep );
281+ if (status == U_SUCCESS ) statemachine_process (new_state_req );
282+
283+ // send state periodically whether receiving a transition or not
284+ send_carstate_msg ();
283285 }
284286}
285287
@@ -934,8 +936,6 @@ uint8_t threads_init(TX_BYTE_POOL *byte_pool) {
934936 CATCH_ERROR (create_thread (byte_pool , & efuses_thread ), U_SUCCESS ); // Create eFuses thread.
935937 CATCH_ERROR (create_thread (byte_pool , & mux_thread ), U_SUCCESS ); // Create Mux thread.
936938 CATCH_ERROR (create_thread (byte_pool , & peripherals_thread ), U_SUCCESS ); // Create Peripherals thread.
937- // CATCH_ERROR(create_thread(byte_pool, &test_thread), U_SUCCESS); // Create Test thread.
938- CATCH_ERROR (create_thread (byte_pool , & misc_telemetry_thread ), U_SUCCESS ); // Create RTDS Telemetry thread.
939939
940940 // add more threads here if need
941941
0 commit comments