I use heavy no_sleep power managment lock. So should I use this for uart_write_bytes?
I never read about internal using locks in uart_write_bytes function. Viewed the source of uart_write_bytes and nothing see about power managment.
what official docs say:
(https://docs.espressif.com/projects/esp ... modes.html)
I think power managment may goes to light sleep during uart_write_bytes execution when sending bytes from buffer to TX line. So it seems to me that tx data may be broken during transmition.UART Output Handling
Before entering sleep mode, esp_deep_sleep_start() will flush the contents of UART FIFOs.
When entering Light-sleep mode using esp_light_sleep_start(), UART FIFOs will not be flushed. Instead, UART output will be suspended, and remaining characters in the FIFO will be sent out after wakeup from Light-sleep.
my code snippet where I use lock:
Code: Select all
...
esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, GNSS_PM_lock_name, &GNSS_PM_lock_handle);
...
xSemaphoreTake( xMutexGNSS, portMAX_DELAY );
{
sprintf(message,"$PMTK%s",data);
crc = get_crc(message+1);
sprintf(msg_end, "*%lx\r\n", crc);
strcat(message, msg_end);
esp_pm_lock_acquire(GNSS_PM_lock_handle);
uart_write_bytes(GNSS_UART_PORT, message, strlen(message));
uart_wait_tx_done(GNSS_UART_PORT,portMAX_DELAY);
esp_pm_lock_release(GNSS_PM_lock_handle);
//xEventGroupSetBits(xGNSS_EventGroup_handle, FLAG_GNSS_FIX_EVT);
}
xSemaphoreGive( xMutexGNSS );