mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-29 02:07:27 +02:00
fix(esp_modem): DTE command race of timeout vs reply's signal
Race condtion: * First command timeouted, but the reply came just after evaluation and set signal variable to GOT_LINE * Second command should timeout too, but a consistency check validates that it timeouted and at the same time GOT_LINE (from previous step) and throws an exception STR: * Revert change in esp_modem_dte.cpp * Run TEST_CASE("DTE command races", "[esp_modem]") Closes https://github.com/espressif/esp-protocols/issues/110
This commit is contained in:
@ -17,7 +17,7 @@ public:
|
||||
* inject_by defines batch sizes: the read callback is called multiple times
|
||||
* with partial data of `inject_by` size
|
||||
*/
|
||||
int inject(uint8_t *data, size_t len, size_t inject_by);
|
||||
int inject(uint8_t *data, size_t len, size_t inject_by,size_t delay_before=0, size_t delay_after=1);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
@ -26,6 +26,12 @@ public:
|
||||
|
||||
int read(uint8_t *data, size_t len) override;
|
||||
|
||||
void set_read_cb(std::function<bool(uint8_t *data, size_t len)> f) override
|
||||
{
|
||||
Scoped<Lock> lock(on_read_guard);
|
||||
on_read = std::move(f);
|
||||
}
|
||||
|
||||
private:
|
||||
enum class status_t {
|
||||
STARTED,
|
||||
@ -39,4 +45,9 @@ private:
|
||||
bool pin_ok;
|
||||
bool is_bg96;
|
||||
size_t inject_by;
|
||||
size_t delay_before_inject;
|
||||
size_t delay_after_inject;
|
||||
std::vector<std::future<void>> async_results;
|
||||
Lock on_read_guard;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user