Putting a date on an SD card file - Anybody have a snippet that works with the
ElectricAye
Posts: 4,561
Ladies and Gentlemen,
I was wondering if anybody has a snippet of code that will easily put a date stamp on the files created by the SD card object. Currently, I have a system that reads my real time clock and gives each file a name that is based on the time and date, but I notice that there's an "official" date that gets attached to SD card files, and this looks like it's locked in as January 2007. I was just wondering if anyone already has a convenient code snippet for stamping a real "official" date on the SD card files.
thanks,
Mark
I was wondering if anybody has a snippet of code that will easily put a date stamp on the files created by the SD card object. Currently, I have a system that reads my real time clock and gives each file a name that is based on the time and date, but I notice that there's an "official" date that gets attached to SD card files, and this looks like it's locked in as January 2007. I was just wondering if anyone already has a convenient code snippet for stamping a real "official" date on the SD card files.
thanks,
Mark
Comments
Could add the object to the SD driver and grab the time from there.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
There is plenty of code in the Obex to parse the data
Just a thought
Ron
yes, I have a real time clock chip, a DS1307, which is what I use for getting the date and time that I integrate into each of the SD card's file names. For example, 9032416.csv would be year 2009, month 3, day 24, hour 16. So it's not like I don't already have a way to get the date and time, it's just that I was curious if anyone already had a code snippet for setting the date on the files of the SD card. Apparently there are some internal doo-hickeys that can be set through the FAT system???? The Sd card object has a comment about doing it, implying some heavy bit banging was involved, the kind of thing that rolls my eyes into the back of my head. So I was just wondering if somebody had already done it for the sheer thrill and excitement that such things bring to all manners of people - except me.
http://en.wikipedia.org/wiki/File_Allocation_Table
Look in the "Directory Table" part.
It would be pretty straightforward to either make fsrw collect the date from somewhere, or else
for you to add a setdate() call on a file.
I don't think anyone has done this yet.
This is referenced down farther in the "popen" routine to set the file creation date. So you need to rewrite the pdate routine to use the date you're getting from your real time clock....
Mark
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It might be the Information Age but the Eon of Ignorance has yet to end.
It's probably not hard at all.
Figure out how to make an object that returns the date information, maybe filling an array of
a few ints or something.
Add a call to that object in the pdate subroutine in the fsrw code.
That's all you need to do. And then you can show us all how you did it!
If you get stuck, everyone hasn't gone anywhere.. [noparse]:)[/noparse]
(Besides, anyone who mastered the Propeller Boebot can do this.. [noparse]:)[/noparse]
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
·
http://forums.parallax.com/showthread.php?p=622673
·
I’ve got a method written somewhere, if I can find it I’ll post it tonight when I get home. However for my application I decided to have the date encoded in the 8.3 file name for my logging application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
yes, I saw that pdate code but got confused because it says the date will be set for 4 April 2007, but it's actually set for January 2007 4 AM. And the stuff on wikipedia about FAT dating bits is way above my head, I think. Anyway, I'll study this some more and see what Mike Cook has cooked up, too.
thanks, you guys
Mark
Here is what I did to modify the fsrw.spin file to time stamp the file when it was created.
First I added the following variables to the bottom of the VAR section:
Then I modifed the pdate to the following:
And then added the following method to the fsrw.spin file:
Now to use this mess, in my top file I call this method BEFORE I open a file for write:
Here is an example of it's use:
In the original program that I pulled this code this from, I was getting time from a DS1307 chip.
Hope this is enough info to get you started. There are probably better ways of doing this, but this 'quick & dirty' worked for my use.
Note: Edits to this post were for formatting and spelling typo's
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (Mike Cook) : 9/12/2008 11:25:41 PM GMT
Mark
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It might be the Information Age but the Eon of Ignorance has yet to end.