Skip to content

'class EEPROMClass' has no member named 'length' #2868

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

Closed
SkazochnikZlodey opened this issue Jan 15, 2017 · 5 comments
Closed

'class EEPROMClass' has no member named 'length' #2868

SkazochnikZlodey opened this issue Jan 15, 2017 · 5 comments
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Comments

@SkazochnikZlodey
Copy link

Hello after adding bord by board manager from http://arduino.esp8266.com/stable/package_esp8266com_index.json

Hardware

Hardware: Wemos D1 mini pro

Description

Problem description
Hello after adding bord by board manager from http://arduino.esp8266.com/stable/package_esp8266com_index.json
got error : 'class EEPROMClass' has no member named 'length'
before compilation was successful.
Looks like EEPROM.h is old

Settings in IDE

Module: Wemos D1 R2 & mini
Flash Size: 4MB/3MB SPIFFS
CPU Frequency: 80Mhz
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: COM8 SERIAL?
Reset Method: ?ck / nodemcu?

Sketch

/*

  • EEPROM Read
  • Reads the value of each byte of the EEPROM and prints it
  • to the computer.
  • This example code is in the public domain.
    */

#include <EEPROM.h>

// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;

void setup() {
// initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}

void loop() {
// read a byte from the current address of the EEPROM
value = EEPROM.read(address);

Serial.print(address);
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();

/***
Advance to the next address, when at the end restart at the beginning.

Larger AVR processors have larger EEPROM sizes, E.g:
- Arduno Duemilanove: 512b EEPROM storage.
- Arduino Uno:        1kb EEPROM storage.
- Arduino Mega:       4kb EEPROM storage.

Rather than hard-coding the length, you should use the pre-provided length function.
This will make your code portable to all AVR processors.

***/
address = address + 1;
if (address == EEPROM.length()) {
address = 0;
}

/***
As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an
EEPROM address is also doable by a bitwise and of the length - 1.

++address &= EEPROM.length() - 1;

***/

delay(500);
}

@yar-trach
Copy link

I also have this issue. NodeMCU 1.0 on 8266

@kdy1999
Copy link

kdy1999 commented Aug 31, 2017

I have this issue. NodeMCU 1.0 on 8266,too

@MiguelNaumSantana
Copy link

Also here!

@devyte
Copy link
Collaborator

devyte commented Oct 4, 2017

@SkazochnikZlodey A ::length() method implementation that just returns _size should be enough.
Care to make a PR?

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 4, 2017
@devyte
Copy link
Collaborator

devyte commented Dec 5, 2017

Fixed via #3855 . Closing.

@devyte devyte closed this as completed Dec 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

No branches or pull requests

5 participants