From f9a1066cd81468dfa8f5ad24fc27bbd24d6181f9 Mon Sep 17 00:00:00 2001 From: RedHawk Date: Fri, 19 May 2023 01:33:04 +0300 Subject: [PATCH 1/3] Master: [#5] Shift queue and task sizes. *Relay: mitigate warning. --- source/shoh/src/threads/master/Master.cpp | 10 +++++----- source/shoh/src/threads/relay/Relay.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/shoh/src/threads/master/Master.cpp b/source/shoh/src/threads/master/Master.cpp index ea1d38f..f834b94 100644 --- a/source/shoh/src/threads/master/Master.cpp +++ b/source/shoh/src/threads/master/Master.cpp @@ -105,16 +105,16 @@ void thread_master(void* pvParams) { LOG_INFO("Master Started"); Master m(manager->qm); LOG_INFO("Master is creating queues"); - manager->qm->createQueue(100, + manager->qm->createQueue(60, sizeof(Event), ThreadCommon::QueueManager::master_event_all); - manager->qm->createQueue(20, + manager->qm->createQueue(12, sizeof(Event), ThreadCommon::QueueManager::manager_event_master); - manager->qm->createQueue(20, + manager->qm->createQueue(12, sizeof(UserInterface::InterfaceWithData), ThreadCommon::QueueManager::ui_event_manager); - manager->qm->createQueue(10, + manager->qm->createQueue(5, sizeof(Event), ThreadCommon::QueueManager::relay_event_master); LOG_INFO("Master created queues"); @@ -122,7 +122,7 @@ void thread_master(void* pvParams) { LOG_INFO("Master is creating tasks"); manager->tm->createTask(thread_manager, "manager", - configMINIMAL_STACK_SIZE * 13,tskIDLE_PRIORITY + 1UL, + configMINIMAL_STACK_SIZE * 15,tskIDLE_PRIORITY + 1UL, static_cast(manager)); manager->tm->createTask(thread_rotary, "rotary", configMINIMAL_STACK_SIZE * 8,tskIDLE_PRIORITY + 1UL, diff --git a/source/shoh/src/threads/relay/Relay.cpp b/source/shoh/src/threads/relay/Relay.cpp index d548802..310b41b 100644 --- a/source/shoh/src/threads/relay/Relay.cpp +++ b/source/shoh/src/threads/relay/Relay.cpp @@ -39,7 +39,7 @@ void inline RelayDevice::RelayOff() Relay::Relay(ThreadCommon::QueueManager* qm): - _qm(qm), ext_temp(0x7f), setpoint(0) + _qm(qm), setpoint(0), ext_temp(0x7f) { LOG_DEBUG("Creating Relay"); } From dfa34d9d162e382cf05442551ee010b0d649eb5e Mon Sep 17 00:00:00 2001 From: RedHawk Date: Sun, 28 May 2023 13:00:56 +0300 Subject: [PATCH 2/3] logging: [#54] Removed UART from ISR *No reason to remove definition, since it is still usable. For some reason, powered from my PC it works fine. Yet, it is bad to call UART from ISR anyway, our rotary queue will overflow from time to time, so it's better not to slow down processing. --- source/shoh/src/threads/logging/Log.h | 4 ++++ source/shoh/src/threads/rotary/Rotary.cpp | 12 ------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/source/shoh/src/threads/logging/Log.h b/source/shoh/src/threads/logging/Log.h index 34c0e0d..3bf6975 100644 --- a/source/shoh/src/threads/logging/Log.h +++ b/source/shoh/src/threads/logging/Log.h @@ -117,6 +117,10 @@ static void create_log_line_nots(const char * _status, #define LOG_DEBUG(fmt, ...) \ create_log_line(global_clock->getTimeFromStart(), C_DEBUG, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); +/* + * Even though it doesn't call timer, it still can cause a softlock on the UART transaction. + * Left only for short-term debugging purposes. + */ #define LOG_DEBUG_ISR(fmt, ...) \ create_log_line_nots(C_DEBUG_ISR, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); #else diff --git a/source/shoh/src/threads/rotary/Rotary.cpp b/source/shoh/src/threads/rotary/Rotary.cpp index 9c0e382..fcdce48 100644 --- a/source/shoh/src/threads/rotary/Rotary.cpp +++ b/source/shoh/src/threads/rotary/Rotary.cpp @@ -21,10 +21,6 @@ extern "C" portBASE_TYPE xHigherPriorityWoken = pdFALSE; uint8_t data = ThreadCommon::RotaryAction::Right; xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken); - if(!xHigherPriorityWoken) - { - LOG_DEBUG_ISR("[PIN_INT0_IRQn] portEND_SWITCHING_ISR called with False value"); - } portEND_SWITCHING_ISR(xHigherPriorityWoken); } @@ -35,10 +31,6 @@ extern "C" portBASE_TYPE xHigherPriorityWoken = pdFALSE; uint8_t data = ThreadCommon::RotaryAction::Left; xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken); - if(!xHigherPriorityWoken) - { - LOG_DEBUG_ISR("[PIN_INT1_IRQn] portEND_SWITCHING_ISR called with False value"); - } portEND_SWITCHING_ISR(xHigherPriorityWoken); } @@ -49,10 +41,6 @@ extern "C" portBASE_TYPE xHigherPriorityWoken = pdFALSE; uint8_t data = ThreadCommon::RotaryAction::Press; xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken); - if(!xHigherPriorityWoken) - { - LOG_DEBUG_ISR("[PIN_INT2_IRQn] portEND_SWITCHING_ISR called with False value"); - } portEND_SWITCHING_ISR(xHigherPriorityWoken); } } From c0f4911af037c1a6694daa6c5dc88396ca9f50e0 Mon Sep 17 00:00:00 2001 From: RedHawk Date: Sun, 28 May 2023 13:10:14 +0300 Subject: [PATCH 3/3] Menu: [#53] Lower bound for desired temperature * 10 is the lowest. * Shifted it on screen to take only 2 cells. --- source/shoh/src/threads/manager/Menu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/shoh/src/threads/manager/Menu.cpp b/source/shoh/src/threads/manager/Menu.cpp index 5c35086..4aabe1b 100644 --- a/source/shoh/src/threads/manager/Menu.cpp +++ b/source/shoh/src/threads/manager/Menu.cpp @@ -22,13 +22,13 @@ enum static const char * interface_messages [] = { "CURRENT %3d ", - "DESIRED %3d ", - "DESIRED[%3d] ", + "DESIRED %2d ", + "DESIRED [%2d] ", " Loading... " }; Menu::Menu(ThreadCommon::QueueManager* qm): _qm(qm), -current(&Menu::sInitView), ext_temp(-99, 99, 1), set_point(-99, 99, 1) +current(&Menu::sInitView), ext_temp(-99, 99, 1), set_point(10, 99, 1) { LOG_DEBUG("Creating Menu"); this->SetState(&Menu::sInitView);