Pages: [1]   Go Down
Author Topic: Save strings in EEPROM  (Read 1874 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26485
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26485
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You can have the strings one after the other, no matter their length
But you still need to know where they start..
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

 smiley
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the C code you use to try to save the strings?

What is the error message?
« Last Edit: June 26, 2009, 07:40:21 pm by TBAr » Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: June 27, 2009, 08:57:30 pm by florinc » Logged

Pages: [1]   Go Up
Jump to: