-
Notifications
You must be signed in to change notification settings - Fork 7.6k
EEPROM.length() returns zero by default? #2280
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
Comments
It is certainly worth discussion, as the current result seems overly simplistic. I haven't really used _user_defined_size. Are there situations where it would not just be |
Its not at all clear to me what the intent of void EEPROMClass::write(int address, uint8_t value) {
if (address < 0 || (size_t)address >= _size)
return;
if (!_data)
return; So as I think it would just need to be: uint16_t EEPROMClass::length ()
{
return _size;
}
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This stale issue has been automatically closed. Thank you for your contributions. |
Summary Related to the issue #5773 and #2280. _user_defined_size is removed from EEPROMClass because it is redundant in the current code EEPROMClass::length() returns _size that is the true available size of EEPROM Impact _user_defined_size is removed from EEPROMClass EEPROMClass::length() returns _size that is the true available size of EEPROM
Is there a design reason that
EEPROM.length()
is returning the value of_user_defined_size
rather than_size
? It would appear that the_user_defined_size
is only set by the constructors and is never used, whereas the size specified toEEPROM.begin()
is the one that all other EEPROM functions use to limit the writable area.To be consistent with the Arduino EEPROM API for AVRs (where
EEPROM.length()
returns the actual EEPROM limit for the chip), it would seem to be more logical forEEPROM.length()
to either return the size specified inEEPROM.begin()
or to returnSPI_FLASH_SEC_SIZE
when_user_defined_size
hasn't been set.I'd be happy to submit a patch if appropriate.
For context, I'm working on converting some personal library code to work on my existing boards and a new one based on the Esp32, and ran into this probably while doing so.
The text was updated successfully, but these errors were encountered: