Код: Выделить всё
void ICBluetoothController::_rxTask(void *pvParameters)
{
ESP_LOGI("ICBluetoothController _serial_task", "started");
auto self = static_cast(pvParameters);
uint8_t b = 0;
char payload[128];
size_t index = 0;
while (true)
{
while (self->_serial.available())
{
b = self->_serial.read();
if (b == '\r' || b == '\n')
{
if (index > 0)
{
payload[index] = '\0'; // Null-terminate the string
if (xQueueSend(self->_rx_queue, &payload, portMAX_DELAY) != pdPASS)
{
ESP_LOGE("ICBluetoothController", "Failed to send to queue");
}
else
{
ESP_LOGI("ICBluetoothController", "Received: %s", payload);
}
index = 0;
}
continue;
}
if (index < sizeof(payload) - 1)
{
payload[index++] = static_cast(b);
}
}
vTaskDelay(pdMS_TO_TICKS(20));
}
}
< /code>
Это отлично работает! .... но только тогда, когда вызов vtaskdelay ()
Код: Выделить всё
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400d17bc PS : 0x00060130 A0 : 0x8008a298 A1 : 0x3ffb4a40
A2 : 0x3ffb21f0 A3 : 0x00000000 A4 : 0x3ffb4a6c A5 : 0x00000001
A6 : 0x00000000 A7 : 0x3f400161 A8 : 0x800d17cc A9 : 0x3ffb4a20
A10 : 0xffffffff A11 : 0x00000049 A12 : 0x3f400124 A13 : 0x00000021
A14 : 0x3f400161 A15 : 0x3f40013e SAR : 0x0000001e EXCCAUSE: 0x0000001c
EXCVADDR: 0xffffffff LBEG : 0x40086271 LEND : 0x40086281 LCOUNT : 0xfffffff7
Backtrace: 0x400d17b9:0x3ffb4a40 0x4008a295:0x3ffb4b10
#0 0x400d17b9 in ICBluetoothController::_rxTask(void*) at src/ICBluetoothController.cpp:41
#1 0x4008a295 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
Подробнее здесь: https://stackoverflow.com/questions/797 ... rtos-tasks