Go Down

Topic: Save strings in EEPROM (Read 2053 times) previous topic - next topic

conanim

Hi,
I want to save some strings in EEPROM, which have an uncertain length and am not sure how to do this. Does anyone know a way of doing this?

Thankyou in advance...
Conor :)

AWOL

Decide how *many* strings you think you want to save, and store a simple index array at the start of EEPROM to point to the strings.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

florinc

Strings are terminated with 0. You can have the strings one after the other, no matter their length.

AWOL

Quote
You can have the strings one after the other, no matter their length

But you still need to know where they start..
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

conanim

if I try to save strings in EEPROM I get an error message... :(
How would I go about saving them as an array?

:)

TBAr

#5
Jun 27, 2009, 02:39 am Last Edit: Jun 27, 2009, 02:40 am by TBAr Reason: 1
What is the C code you use to try to save the strings?

What is the error message?

John_Ryan

You need a function like this, whereby:-

newWriteLocation is the start position in eeprom
byteCount is the length of yourString

EEPROM.write(newWriteLocation+byteCount, int(yourString[byteCount]));

Once you start storing data in eeprom, you might need additional routines to:-

search records
delete records
add new records
determine number of free blocks available

And each of those routines need supporting routines, like you might want to use 2 large arrays, both the same size as eeprom, that you manipulate before writing the entire array back to eeprom, especially if your trying to delete a string and reorder the eeprom to make more efficient use of the available space after the strings been deleted.

It's a real can of worms unless you can find code in the playground that already does what your wanting.

florinc

#7
Jun 28, 2009, 03:56 am Last Edit: Jun 28, 2009, 03:57 am by florinc Reason: 1
conanim, you may want to take a look at my recent post here:
http://timewitharduino.blogspot.com/2009/06/storing-strings-in-eeprom-byte-by.html
A bit of explanation, a bit of code...

Go Up