gutierrezps / ESP32_I2C_Slave

I2C slave library for ESP32
GNU Lesser General Public License v2.1
81 stars 20 forks source link

Timing of Master reader #10

Closed 38saibot closed 2 years ago

38saibot commented 3 years ago

Describe the bug Requesting some bytes from a slave is blocking the main loop for 3..6ms In the implementation of slaveReq.request() is the delay function used in a while loop: WireslaveRequest.cpp in Line 32:

// wait until slave fills its output buffer
delay(retryDelay_ * (attempts + 1));

The request is sent and then it stucks for some ms while waiting for the response. Wouldn't it be possible to get things separated, sending the request, then going back to the main loop, doing a poll in every loop cycle and then read the response if available?

The actual implementation is killing my application which requires a fast CPU cycle.

To Reproduce Use the sample code for master_reader and slave_sender

Additional context

gutierrezps commented 3 years ago

Wouldn't it be possible to get things separated, sending the request, then going back to the main loop, doing a poll in every loop cycle and then read the response if available?

Absolutely. That's indeed a reasonable issue of this library. I'll work on a non-blocking version as soon as I can and upload it for you to test.

gutierrezps commented 2 years ago

Unfortunately, I couldn't address this issue in a timely manner because I haven't been working with the ESP32 ever since. In this meantime, I2C Slave support has been added to the official ESP32 framework as you can see in the updated README of this repo. Therefore this library is no longer needed and its development will be ceased.