mirror of
https://github.com/esphome/esphome.git
synced 2025-09-26 15:12:21 +01:00
fix
This commit is contained in:
@@ -246,11 +246,8 @@ void USBUartComponent::start_input(USBUartChannel *channel) {
|
|||||||
chunk->channel = channel;
|
chunk->channel = channel;
|
||||||
|
|
||||||
// Push to lock-free queue for main loop processing
|
// Push to lock-free queue for main loop processing
|
||||||
if (!this->usb_data_queue_.push(chunk)) {
|
// Push always succeeds because pool size == queue size
|
||||||
ESP_LOGW(TAG, "USB data queue full, dropping %u bytes", status.data_len);
|
this->usb_data_queue_.push(chunk);
|
||||||
// Return chunk to pool
|
|
||||||
this->chunk_pool_.release(chunk);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always restart input immediately from USB task
|
// Always restart input immediately from USB task
|
||||||
|
@@ -137,8 +137,8 @@ class USBUartComponent : public usb_host::USBClient {
|
|||||||
LockFreeQueue<UsbDataChunk, USB_DATA_QUEUE_SIZE> usb_data_queue_;
|
LockFreeQueue<UsbDataChunk, USB_DATA_QUEUE_SIZE> usb_data_queue_;
|
||||||
|
|
||||||
// Pool for allocating data chunks (uses EventPool pattern like BLE)
|
// Pool for allocating data chunks (uses EventPool pattern like BLE)
|
||||||
static constexpr int MAX_DATA_CHUNKS = 40;
|
// MUST be same size as queue to guarantee push always succeeds after allocate
|
||||||
EventPool<UsbDataChunk, MAX_DATA_CHUNKS> chunk_pool_;
|
EventPool<UsbDataChunk, USB_DATA_QUEUE_SIZE> chunk_pool_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<USBUartChannel *> channels_{};
|
std::vector<USBUartChannel *> channels_{};
|
||||||
|
Reference in New Issue
Block a user