fix: start only enabled links and move config buffers off stack
This commit is contained in:
+8
-8
@@ -23,6 +23,8 @@ static device_config_t g_config;
|
|||||||
static volatile bool g_reset_requested;
|
static volatile bool g_reset_requested;
|
||||||
static volatile bool g_uart1_tx_busy;
|
static volatile bool g_uart1_tx_busy;
|
||||||
static uint8_t g_uart1_rx_buffer[CONFIG_RX_BUFFER_SIZE];
|
static uint8_t g_uart1_rx_buffer[CONFIG_RX_BUFFER_SIZE];
|
||||||
|
static char g_config_cmd_buffer[CONFIG_CMD_MAX_LEN];
|
||||||
|
static char g_config_response_buffer[CONFIG_TX_BUFFER_SIZE];
|
||||||
|
|
||||||
static uint32_t config_calc_crc(const device_config_t *cfg)
|
static uint32_t config_calc_crc(const device_config_t *cfg)
|
||||||
{
|
{
|
||||||
@@ -632,8 +634,6 @@ static void config_respond_to_uart(route_msg_t *msg, const char *response)
|
|||||||
void ConfigTask(void *argument)
|
void ConfigTask(void *argument)
|
||||||
{
|
{
|
||||||
route_msg_t *msg;
|
route_msg_t *msg;
|
||||||
char cmd[CONFIG_CMD_MAX_LEN];
|
|
||||||
char response[CONFIG_TX_BUFFER_SIZE];
|
|
||||||
at_result_t result;
|
at_result_t result;
|
||||||
|
|
||||||
(void)argument;
|
(void)argument;
|
||||||
@@ -646,14 +646,14 @@ void ConfigTask(void *argument)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->len >= sizeof(cmd)) {
|
if (msg->len >= sizeof(g_config_cmd_buffer)) {
|
||||||
msg->len = sizeof(cmd) - 1u;
|
msg->len = sizeof(g_config_cmd_buffer) - 1u;
|
||||||
}
|
}
|
||||||
memcpy(cmd, msg->data, msg->len);
|
memcpy(g_config_cmd_buffer, msg->data, msg->len);
|
||||||
cmd[msg->len] = '\0';
|
g_config_cmd_buffer[msg->len] = '\0';
|
||||||
|
|
||||||
result = config_process_at_cmd(cmd, response, sizeof(response));
|
result = config_process_at_cmd(g_config_cmd_buffer, g_config_response_buffer, sizeof(g_config_response_buffer));
|
||||||
config_respond_to_uart(msg, response);
|
config_respond_to_uart(msg, g_config_response_buffer);
|
||||||
if (result == AT_NEED_REBOOT) {
|
if (result == AT_NEED_REBOOT) {
|
||||||
config_respond_to_uart(msg, "Note: Use AT+SAVE then AT+RESET to apply changes\r\n");
|
config_respond_to_uart(msg, "Note: Use AT+SAVE then AT+RESET to apply changes\r\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ static void uart_send_tcp_msg_to_uarts(route_msg_t *msg)
|
|||||||
|
|
||||||
static void uart_route_mux_frame(uart_channel_t source_channel, const uart_mux_frame_t *frame)
|
static void uart_route_mux_frame(uart_channel_t source_channel, const uart_mux_frame_t *frame)
|
||||||
{
|
{
|
||||||
|
const device_config_t *cfg = config_get();
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint8_t source_conn = (source_channel == UART_CHANNEL_U1) ? ROUTE_CONN_UART3 : ROUTE_CONN_UART2;
|
uint8_t source_conn = (source_channel == UART_CHANNEL_U1) ? ROUTE_CONN_UART3 : ROUTE_CONN_UART2;
|
||||||
uint8_t out_frame[ROUTE_MSG_MAX_PAYLOAD + 6u];
|
uint8_t out_frame[ROUTE_MSG_MAX_PAYLOAD + 6u];
|
||||||
@@ -209,6 +210,9 @@ static void uart_route_mux_frame(uart_channel_t source_channel, const uart_mux_f
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
for (i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
||||||
|
if (cfg->links[i].enabled == 0u) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
uint8_t endpoint = config_link_index_to_endpoint((uint8_t)i);
|
uint8_t endpoint = config_link_index_to_endpoint((uint8_t)i);
|
||||||
if ((frame->dst_mask & endpoint) != 0u) {
|
if ((frame->dst_mask & endpoint) != 0u) {
|
||||||
(void)route_send(xLinkTxQueues[i], frame->src_id, endpoint, source_conn, frame->payload, frame->payload_len, pdMS_TO_TICKS(10));
|
(void)route_send(xLinkTxQueues[i], frame->src_id, endpoint, source_conn, frame->payload, frame->payload_len, pdMS_TO_TICKS(10));
|
||||||
|
|||||||
+23
-22
@@ -36,48 +36,70 @@ static TaskHandle_t xTcpSrvTaskS2Handle = NULL;
|
|||||||
static TaskHandle_t xTcpCliTaskC1Handle = NULL;
|
static TaskHandle_t xTcpCliTaskC1Handle = NULL;
|
||||||
static TaskHandle_t xTcpCliTaskC2Handle = NULL;
|
static TaskHandle_t xTcpCliTaskC2Handle = NULL;
|
||||||
static TaskHandle_t xDefaultTaskHandle = NULL;
|
static TaskHandle_t xDefaultTaskHandle = NULL;
|
||||||
|
static BaseType_t xNetworkTasksStarted = pdFALSE;
|
||||||
|
|
||||||
void app_start_network_tasks(void)
|
void app_start_network_tasks(void)
|
||||||
{
|
{
|
||||||
#if !DIAG_TASK_ISOLATION
|
#if !DIAG_TASK_ISOLATION
|
||||||
BaseType_t rc;
|
BaseType_t rc;
|
||||||
|
const device_config_t *cfg;
|
||||||
|
|
||||||
if (xTcpSrvTaskS1Handle != NULL) {
|
if (xNetworkTasksStarted != pdFALSE) {
|
||||||
debug_log_write("[NET] start-network-tasks already\r\n");
|
debug_log_write("[NET] start-network-tasks already\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg = config_get();
|
||||||
|
|
||||||
debug_log_printf("[NET] start-network-tasks enter free=%lu min=%lu\r\n",
|
debug_log_printf("[NET] start-network-tasks enter free=%lu min=%lu\r\n",
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
(unsigned long)xPortGetFreeHeapSize(),
|
||||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||||
|
|
||||||
|
if (cfg->links[CONFIG_LINK_S1].enabled != 0u) {
|
||||||
rc = xTaskCreate(TcpSrvTask_S1, "TcpSrvS1", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS1Handle);
|
rc = xTaskCreate(TcpSrvTask_S1, "TcpSrvS1", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS1Handle);
|
||||||
debug_log_printf("[NET] create TcpSrvS1 rc=%ld free=%lu min=%lu\r\n",
|
debug_log_printf("[NET] create TcpSrvS1 rc=%ld free=%lu min=%lu\r\n",
|
||||||
(long)rc,
|
(long)rc,
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
(unsigned long)xPortGetFreeHeapSize(),
|
||||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||||
configASSERT(rc == pdPASS);
|
configASSERT(rc == pdPASS);
|
||||||
|
} else {
|
||||||
|
debug_log_write("[NET] skip TcpSrvS1 en=0\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->links[CONFIG_LINK_S2].enabled != 0u) {
|
||||||
rc = xTaskCreate(TcpSrvTask_S2, "TcpSrvS2", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS2Handle);
|
rc = xTaskCreate(TcpSrvTask_S2, "TcpSrvS2", TASK_STACK_TCP_SERVER, NULL, TASK_PRIORITY_TCP_SERVER, &xTcpSrvTaskS2Handle);
|
||||||
debug_log_printf("[NET] create TcpSrvS2 rc=%ld free=%lu min=%lu\r\n",
|
debug_log_printf("[NET] create TcpSrvS2 rc=%ld free=%lu min=%lu\r\n",
|
||||||
(long)rc,
|
(long)rc,
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
(unsigned long)xPortGetFreeHeapSize(),
|
||||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||||
configASSERT(rc == pdPASS);
|
configASSERT(rc == pdPASS);
|
||||||
|
} else {
|
||||||
|
debug_log_write("[NET] skip TcpSrvS2 en=0\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->links[CONFIG_LINK_C1].enabled != 0u) {
|
||||||
rc = xTaskCreate(TcpCliTask_C1, "TcpCliC1", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC1Handle);
|
rc = xTaskCreate(TcpCliTask_C1, "TcpCliC1", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC1Handle);
|
||||||
debug_log_printf("[NET] create TcpCliC1 rc=%ld free=%lu min=%lu\r\n",
|
debug_log_printf("[NET] create TcpCliC1 rc=%ld free=%lu min=%lu\r\n",
|
||||||
(long)rc,
|
(long)rc,
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
(unsigned long)xPortGetFreeHeapSize(),
|
||||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||||
configASSERT(rc == pdPASS);
|
configASSERT(rc == pdPASS);
|
||||||
|
} else {
|
||||||
|
debug_log_write("[NET] skip TcpCliC1 en=0\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->links[CONFIG_LINK_C2].enabled != 0u) {
|
||||||
rc = xTaskCreate(TcpCliTask_C2, "TcpCliC2", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC2Handle);
|
rc = xTaskCreate(TcpCliTask_C2, "TcpCliC2", TASK_STACK_TCP_CLIENT, NULL, TASK_PRIORITY_TCP_CLIENT, &xTcpCliTaskC2Handle);
|
||||||
debug_log_printf("[NET] create TcpCliC2 rc=%ld free=%lu min=%lu\r\n",
|
debug_log_printf("[NET] create TcpCliC2 rc=%ld free=%lu min=%lu\r\n",
|
||||||
(long)rc,
|
(long)rc,
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
(unsigned long)xPortGetFreeHeapSize(),
|
||||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||||
configASSERT(rc == pdPASS);
|
configASSERT(rc == pdPASS);
|
||||||
|
} else {
|
||||||
|
debug_log_write("[NET] skip TcpCliC2 en=0\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
xNetworkTasksStarted = pdTRUE;
|
||||||
|
|
||||||
debug_log_printf("[NET] start-network-tasks exit free=%lu min=%lu\r\n",
|
debug_log_printf("[NET] start-network-tasks exit free=%lu min=%lu\r\n",
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
(unsigned long)xPortGetFreeHeapSize(),
|
||||||
@@ -87,8 +109,6 @@ void app_start_network_tasks(void)
|
|||||||
|
|
||||||
static void StartDefaultTask(void *argument)
|
static void StartDefaultTask(void *argument)
|
||||||
{
|
{
|
||||||
TickType_t last_snapshot = xTaskGetTickCount();
|
|
||||||
BaseType_t alive_logged = pdFALSE;
|
|
||||||
BaseType_t iwdg_ready = pdFALSE;
|
BaseType_t iwdg_ready = pdFALSE;
|
||||||
|
|
||||||
(void)argument;
|
(void)argument;
|
||||||
@@ -106,25 +126,6 @@ static void StartDefaultTask(void *argument)
|
|||||||
if (iwdg_ready == pdTRUE) {
|
if (iwdg_ready == pdTRUE) {
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
}
|
}
|
||||||
if (alive_logged == pdFALSE) {
|
|
||||||
debug_log_write("[RTOS] alive\r\n");
|
|
||||||
alive_logged = pdTRUE;
|
|
||||||
}
|
|
||||||
if ((xTaskGetTickCount() - last_snapshot) >= pdMS_TO_TICKS(5000)) {
|
|
||||||
debug_log_printf("[RTOS] seq=%lu drops=%lu last=%lu free=%lu min=%lu self_hwm=%lu\r\n",
|
|
||||||
(unsigned long)g_rtt_log_seq,
|
|
||||||
(unsigned long)g_rtt_log_drop_count,
|
|
||||||
(unsigned long)g_rtt_log_last_drop_seq,
|
|
||||||
(unsigned long)xPortGetFreeHeapSize(),
|
|
||||||
(unsigned long)xPortGetMinimumEverFreeHeapSize(),
|
|
||||||
(unsigned long)uxTaskGetStackHighWaterMark(NULL));
|
|
||||||
if (xNetPollTaskHandle != NULL) {
|
|
||||||
debug_log_printf("[RTOS] net_phase=%lu net_hwm=%lu\r\n",
|
|
||||||
(unsigned long)g_netif_phase,
|
|
||||||
(unsigned long)uxTaskGetStackHighWaterMark(xNetPollTaskHandle));
|
|
||||||
}
|
|
||||||
last_snapshot = xTaskGetTickCount();
|
|
||||||
}
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(500));
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user