Go Down

Topic: SD variable storage check and deletion/appending (Read 572 times) previous topic - next topic

Alexisa

I everyone

So I have an idea for a project involving using an rfid scanner to "touch on" and touch off" a card.
So one Arduino scans the card uid in and sends it via serial to the other Arduino. The other Arduino stores the received uid on it's connected sd card in a text file so that when the card is scanned on the second Arduino it can cross check the scanned card uid and the stored uid and then delete it off the text file or give an error if not found.

So the step process would be:
Arduino1-scans card
Arduino1 sends uid to arduino2
Arduino2 stores received uid
Arduino2 scans card
Arduino2 cross checks scanned uid with stored uid's
Arduino2 deletes the uid

Ideally this will be tested with multiple cards, but my question is, is it suitable to simply store the uid's in a text file separated by a "/c" or space or other token so that the second Arduino can search for the uid?
If this is done say 1000 times with the data appended to the new uid appended to the end of the file each time, with scans on and off then I can see the text file will become heavily "fragmented" with a whole heap of gaps where uid's have been deleted. Might eventually end up with 30 blank lines in the text file which the Arduino will have to waste time searching each time it goes to check for uid's.
Is there a better way than this to do handle the data storage/checking?
Would it be possible to do something like check for a new line where there is no text and if there is then fill it with the newly scanned uid? Not quite sure how to do that but could it limit the "fragmentation that might occur?

Thanks, any advice/insight is appreciated

PaulS

Quote
is it suitable to simply store the uid's in a text file separated by a "/c" or space or other token so that the second Arduino can search for the uid?
Yes. It makes more sense to me to store each UID on a new record/line, so that all records are fixed length, which makes searching faster.

Quote
If this is done say 1000 times with the data appended to the new uid
With what data appended to the UID?

Using fixed length record, each consisting of 2 characters ("in use" and a space) followed by the UID and a CR/LF, you could quickly find the appropriate UID record. Then, set or clear the in use flag.

That way, the number of records will never exceed the number of tags, and there will be no empty records.

Go Up