esp-box icon indicating copy to clipboard operation
esp-box copied to clipboard

I2C read error is not handled correctly in TT21100 driver

Open ratzori opened this issue 2 years ago • 1 comments

I2C read error is not handled correctly as ret_val == ESP_OK and data_len > 0 is not checked here: https://github.com/espressif/esp-box/blob/c46079095e4115282babbddb78179af547b6d548/components/i2c_devices/touch_panel/tt21100.c#L122

This will cause that tt21100_read will be called with data_len == 0 https://github.com/espressif/esp-box/blob/c46079095e4115282babbddb78179af547b6d548/components/i2c_devices/touch_panel/tt21100.c#L123

https://github.com/espressif/esp-box/blob/c46079095e4115282babbddb78179af547b6d548/components/i2c_devices/touch_panel/tt21100.c#L33

esp_err_t i2c_master_read(i2c_cmd_handle_t cmd_handle, uint8_t *data, size_t data_len, i2c_ack_type_t ack)
{
...
    ESP_RETURN_ON_FALSE(data_len > 0, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_DATA_LEN_ERR_STR);

ratzori avatar May 05 '22 12:05 ratzori

You are right. It's strange that we haven't encountered data_len=0 yet. Anyway, it'll be fixed soon.

alic-maker avatar May 06 '22 02:05 alic-maker

Hi, if you don't have any questions, please close this issue. Thank you!

ESP-Mars avatar Jun 30 '23 09:06 ESP-Mars