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

A functionality difference between original and EEPROMWearLevel #20

Open
Janovlk opened this issue Nov 5, 2024 · 0 comments
Open

A functionality difference between original and EEPROMWearLevel #20

Janovlk opened this issue Nov 5, 2024 · 0 comments

Comments

@Janovlk
Copy link

Janovlk commented Nov 5, 2024

Hello,

Here is a testing sketch:

#include <EEPROMWearLevel.h>

#define EEPROM_LAYOUT_VERSION 1
#define AMOUNT_OF_INDEXES 2
#define Variables_VAR1 0
#define Array_VAR2 1 

char Array[25];
char ArrayCopy1[25];
char ArrayCopy2[25];

struct VARIABLES {
  uint16_t number;
  char name[25];
};
VARIABLES Variables;
VARIABLES VariablesCopy;


void setup() {
  Serial.begin(115200);
  strcpy(Variables.name, "Testing string 1.");
  strcpy(Array, "Testing string 2.");
  Variables.number = 3512;

  EEPROMwl.begin(EEPROM_LAYOUT_VERSION, AMOUNT_OF_INDEXES);

  EEPROMwl.put(Variables_VAR1, Variables);
  EEPROMwl.put(Array_VAR2, Array);
  EEPROM.put(0, Array);

  EEPROMwl.get(Array_VAR2, ArrayCopy1);  // The crucial line.

  EEPROMwl.get(Variables_VAR1, VariablesCopy);
  EEPROM.get(0, ArrayCopy2);
  
  Serial.print("Variable number: ");
  Serial.println(VariablesCopy.number);
  Serial.print("Variable name: ");
  Serial.println(VariablesCopy.name);
  Serial.print("Array Copy 1: ");
  Serial.println(ArrayCopy1);

  Serial.print("Array Copy 2: ");
  Serial.println(ArrayCopy2);


}

void loop() {

}

The sketch compiles with the error: "invalid array assignment". When I comment out "the crucial line", it will work. Of course, the ArrayCopy1 character array then remains empty. So there is a difference between the original EEPROM functionality in Arduino and your implementation. As you can see, when I "stash" the character array into a structure, it will work with EEPROMWearLevel.

When I change "the crucial line" to:

  EEPROMwl.get(Array_VAR2, ArrayCopy1[25]);

the sketch will compile. (With any number between the brackets.) The character array ArrayCopy1 will remain empty, which is expected behavior.

Did I make a mistake or is it a difference in your implementation of EEPROM?

Thank you for your work.

PP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant