Skip to content

Commit 0f01533

Browse files
committed
Merge branch 'bugfix/fix_port_deadlock_startup_issue' into 'main'
fix serial port deadlock startup issue in specific conditions See merge request idf/esp-modbus!124
2 parents 9c7cc28 + b459a0e commit 0f01533

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

modbus/mb_ports/serial/port_serial.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void mb_port_ser_enable(mb_port_base_t *inst)
119119
mb_port_ser_bus_sema_release(inst);
120120
ESP_LOGD(TAG, "%s, resume port.", port_obj->base.descr.parent_name);
121121
// Resume receiver task from known position
122-
vTaskResume(port_obj->task_handle);
122+
xTaskNotifyGive(port_obj->task_handle);
123123
}
124124
}
125125

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

0 commit comments

Comments
 (0)