i2s_read instead of i2s_read_bytes

dayem23
Posts: 1
Joined: Thu Nov 17, 2022 6:54 am

i2s_read instead of i2s_read_bytes

Postby dayem23 » Thu Nov 17, 2022 7:10 am

Greetings,

I'm trying to upload this project on my ESP32 :
https://github.com/MhageGH/esp32_SoundRecorder I got an error in I2S.cpp file and based on what I found here: https://docs.espressif.com/projects/esp ... s/i2s.html
that i2s_read_bytes function that the project used is deprecated. and I should "Use ‘i2s_read’ instead."
but when I change it still gives me an error:

Code: Select all

In function 'int I2S_Read(char*, int)':
I2S.cpp:43:66: error: invalid conversion from 'TickType_t' {aka 'unsigned int'} to 'size_t*' {aka 'unsigned int*'} [-fpermissive]
   return i2s_read(I2S_NUM_0, (char *)data, numData, portMAX_DELAY);
                                                                  ^
I2S.cpp:43:66: error: too few arguments to function 'esp_err_t i2s_read(i2s_port_t, void*, size_t, size_t*, TickType_t)'
how I can use i2s_read instead of i2s_read_bytes correctly?

from the documentation:
int i2s_read_bytes(i2s_port_ti2s_num, void *dest, size_t size, TickType_t ticks_to_wait)
Read data from I2S DMA receive buffer.

This function is deprecated. Use ‘i2s_read’ instead. This definition will be removed in a future release.

Return
The amount of bytes read, if timeout, bytes read will be less than the size passed in
ESP_FAIL Parameter error
esp_err_ti2s_read(i2s_port_ti2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait)
Read data from I2S DMA receive buffer.

Note
If the built-in ADC mode is enabled, we should call i2s_adc_start and i2s_adc_stop around the whole reading process, to prevent the data getting corrupted.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2s_num: I2S_NUM_0, I2S_NUM_1
dest: Destination address to read into
size: Size of data in bytes
bytes_read: Number of bytes read, if timeout, bytes read will be less than the size passed in.
ticks_to_wait: RX buffer wait timeout in RTOS ticks. If this many ticks pass without bytes becoming available in the DMA receive buffer, then the function will return (note that if data is read from the DMA buffer in pieces, the overall operation may still take longer than this timeout.) Pass portMAX_DELAY for no timeout.

chegewara
Posts: 2371
Joined: Wed Jun 14, 2017 9:00 pm

Re: i2s_read instead of i2s_read_bytes

Postby chegewara » Thu Nov 17, 2022 8:27 am

There is small asterisk, easy to miss:

Code: Select all

'TickType_t' {aka 'unsigned int'} to 'size_t*' {aka 'unsigned int*'}
You are passing somewhere a pointer instead of value.

Who is online

Users browsing this forum: No registered users and 115 guests