Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for a deadlock startup problem where "port_serial_task" is suspended and never resumed. (IDFGH-14964) #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modbus/mb_ports/serial/port_serial.c
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ void mb_port_ser_enable(mb_port_base_t *inst)
mb_port_ser_bus_sema_release(inst);
ESP_LOGD(TAG, "%s, resume port.", port_obj->base.descr.parent_name);
// Resume receiver task from known position
vTaskResume(port_obj->task_handle);
xTaskNotifyGive(port_obj->task_handle);
}
}

@@ -142,9 +142,9 @@ static void mb_port_ser_task(void *p_args)
(void)mb_port_ser_rx_flush(&port_obj->base);
while(1) {
// Workaround to suspend task from known place to avoid dead lock when resume
if (!atomic_load(&(port_obj->enabled))) {
while (!atomic_load(&(port_obj->enabled))) {
ESP_LOGI(TAG, "%s, suspend port from task.", port_obj->base.descr.parent_name);
vTaskSuspend(NULL);
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
}
if (xQueueReceive(port_obj->uart_queue, (void *)&event, MB_SERIAL_RX_TOUT_TICKS)) {
ESP_LOGD(TAG, "%s, UART[%d] event:", port_obj->base.descr.parent_name, port_obj->ser_opts.port);