Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP_I2S.h: error: 'int read' redeclared as different kind of entity #9914

Closed
1 task done
kowyo opened this issue Jun 21, 2024 · 1 comment · Fixed by #9916
Closed
1 task done

ESP_I2S.h: error: 'int read' redeclared as different kind of entity #9914

kowyo opened this issue Jun 21, 2024 · 1 comment · Fixed by #9916
Assignees
Labels
Area: Peripherals API Relates to peripheral's APIs. Type: Documentation Issue pertains to Documentation of Arduino ESP32 Type: Example Issue is related to specific example.

Comments

@kowyo
Copy link

kowyo commented Jun 21, 2024

Board

XIAOESP32S3

Device Description

Hardware Configuration

USB connected to Mac

Version

v3.0.1

IDE Name

Arduino IDE

Operating System

macOS 14.5

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

115200

Description

@lucasssvaz @me-no-dev I ran the example code in https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2s.html?highlight=i2s and the output reported error

Sketch

#include <ESP_I2S.h>

const int buff_size = 128;
int available, read;
uint8_t buffer[buff_size];
I2SClass I2S;

void setup() {
  I2S.setPins(5, 25, 26, 35, 0); //SCK, WS, SDOUT, SDIN, MCLK
  I2S.begin(I2S_MODE_STD, 16000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO);
  I2S.read();
  available = I2S.available();
  if(available < buff_size) {
    read = I2S.read(buffer, available);
  } else {
    read = I2S.read(buffer, buff_size);
  }
  I2S.write(buffer, read);
  I2S.end();
}

void loop() {}

Debug Message

/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:4:16: error: 'int read' redeclared as different kind of entity
    4 | int available, read;
      |                ^~~~
In file included from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/newlib/platform_include/sys/unistd.h:11,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp-xs3/2302/xtensa-esp32s3-elf/sys-include/unistd.h:4,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/port/include/lwipopts.h:14,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/lwip/src/include/lwip/opt.h:51,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/lwip/src/include/lwip/ip_addr.h:40,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/cores/esp32/IPAddress.h:25,
                 from /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/cores/esp32/Arduino.h:196,
                 from /private/var/folders/6r/s6_mxzqs2nq3vp6jb2hh8xpr0000gn/T/arduino/sketches/A17C809F49E99F211DA5F2057498F7E6/sketch/firmware.ino.cpp:1:
/Users/kowyo/Library/Arduino15/packages/esp32/tools/esp-xs3/2302/xtensa-esp32s3-elf/sys-include/sys/unistd.h:189:25: note: previous declaration 'int read(int, void*, size_t)'
  189 | _READ_WRITE_RETURN_TYPE read (int __fd, void *__buf, size_t __nbyte);
      |                         ^~~~
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino: In function 'void setup()':
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:14:20: error: no matching function for call to 'I2SClass::read(uint8_t [128], int&)'
   14 |     read = I2S.read(buffer, available);
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:1:
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate: 'virtual int I2SClass::read()'
   81 |   int read();
      |       ^~~~
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note:   candidate expects 0 arguments, 2 provided
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:16:20: error: no matching function for call to 'I2SClass::read(uint8_t [128], const int&)'
   16 |     read = I2S.read(buffer, buff_size);
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate: 'virtual int I2SClass::read()'
   81 |   int read();
      |       ^~~~
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note:   candidate expects 0 arguments, 2 provided
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:18:21: error: invalid conversion from 'int (*)(int, void*, size_t)' {aka 'int (*)(int, void*, unsigned int)'} to 'size_t' {aka 'unsigned int'} [-fpermissive]
   18 |   I2S.write(buffer, read);
      |                     ^~~~
      |                     |
      |                     int (*)(int, void*, size_t) {aka int (*)(int, void*, unsigned int)}
/Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:65:40: note:   initializing argument 2 of 'size_t I2SClass::write(uint8_t*, size_t)'
   65 |   size_t write(uint8_t *buffer, size_t size);
      |                                 ~~~~~~~^~~~

exit status 1

Compilation error: 'int read' redeclared as different kind of entity

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@kowyo kowyo added the Status: Awaiting triage Issue is waiting for triage label Jun 21, 2024
@lucasssvaz
Copy link
Collaborator

I'll update the example but for now you can just rename the read variable to byte_read and available to bytes_available and it should work fine

@lucasssvaz lucasssvaz self-assigned this Jun 21, 2024
@lucasssvaz lucasssvaz added Type: Documentation Issue pertains to Documentation of Arduino ESP32 Area: Peripherals API Relates to peripheral's APIs. Type: Example Issue is related to specific example. and removed Status: Awaiting triage Issue is waiting for triage labels Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs. Type: Documentation Issue pertains to Documentation of Arduino ESP32 Type: Example Issue is related to specific example.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants