Is there a way to access a "dat" section stored on a sd card?
Don M
Posts: 1,652
Was wondering if I stored this on an sd card as am1.txt
Can it be included somehow during compile?
Should it have a different file name?
Are there any code examples doing this?
Thanks.
Don
dat am1 byte $08, $02, "Data 1........... " ' 30 bytes total - 2 numbers & 28 characters byte $08, $07, "Data 2........... " byte $08, $12, "Data 3........... " byte $08, $16, "Data 4........... " byte $08, $17, "Data 5........... ", 0
Can it be included somehow during compile?
Should it have a different file name?
Are there any code examples doing this?
Thanks.
Don
Comments
If you want to read a block during run-time, what you could do, assuming your structure is absolutely intact (size), is a block read from a file to the DAT section of your program -- you can do it in one line:
If check = DAT_BLOCK_BYTES then you had a successful read. Do this at the top of your program before other elements want to access values in the DAT table.
You should probably verify that the file is present and the correct size before running that line.
Another way is to add a method that returns the address of am1, and include the file as an object. So in this case am1.spin would look like this.
Actually I like this method probably the best. I allows me to have different dat files on the sd card and be able to call them up into the program at will. The only gotcha is knowing ahead of time the number of bytes in the file... I wonder if the filesize method in fsrw would give me that number... I'll have to experiment a bit.
Thanks for the suggestions.
Yes. I use this feature in the AP-16+. I can provide firmware updates to customers. On boot-up, the program looks for a special file name. If it exists and is exactly 32K (an eeprom image file), then it gets read and copied to the boot eeprom, the file is erased, and the Propeller reboots itself running the new firmware.
Here's what is on the sd card in a file named data.txt
And here is my DAT section
And I do this to retrieve the data from the sd card
When I look at the data from the DAT section it is messed up.
How do I get it to format correctly in the DAT section?
Do I have the data stored wrong on the sd card?
so Data.txt will not work. After compile the DAT section is no source anymore just binary bytes. see #3 by Dave Hein.
Enjoy!
Mike
Just so I understand here... I'm not trying to compile the data from the sd card along with my other spin file but instead be able to access the file from within the spin program to "populate" the DAT section DatBlock if that's possible.
Does this make sense? Is this what you are referring to doing in Dave's post?
if you compile this you get a binary file of 180 bytes. save to disk (sd) as AM1.bin
to load your bin file into the existing space in your main prog you need to skip the first 24 bytes (init and first pub) to find your dat block.
Hope this helps...
Enjoy!
Mike