Is FSRW's setdate actually supposed to work? - SOLVED!
ElectricAye
Posts: 4,561
I thought I read (somewhere?) in FSRW's OBEX downloads description that working with dates wasn't yet implemented, but then inside the Object I found setdate, with which I've been tinkering but with no success. Is it supposed to work? or... why else would it be in the Object?
I would like to give my SD card files a date and time stamp, if possible, but I've heard it's one of your typical Microsoft-Rules-The-World problems. So I'm confused about what's going on with FSRW.
Clues?
I would like to give my SD card files a date and time stamp, if possible, but I've heard it's one of your typical Microsoft-Rules-The-World problems. So I'm confused about what's going on with FSRW.
Clues?
Comments
I can't speak for earlier versions, comments at the top indicate it might need to be version 2.4a or higher:
("v2.4a 6 October 2009 modified setdate to explicitly set year/month/etc.")
Kal,
The "caveats.html" file that came with the fsrw26 folder says"...No explicit date or time support yet." But sometimes those comments are never updated. I'm probably doing something totally stupid, so your feedback gives me encouragement to keep trying.
thanks,
Mark
Is there a simple way to fix this problem?
Kal,
which Object are you using for rtc? Do you happen to know if it's returning a Byte, a Word, a Long... or what?
thanks again,
Mark
2: Read the documentation.
3: Write one line of code.
4: Be happy.
The right sequence is:
1: Download my DS1307 RTC object.
2: Read the documentation.
3: Write one line of code.
4: Be happy.
5: ???
6: Profit ! ;-)
bytevar := longvar
You could also say bytevar := longvar.byte[0] to get the lower byte amount or just use longvar.byte[0] without assigning it to a byte variable.
If the LONG value is greater than 8 bits, there is no way to 'stuff' the LONG into the byte.
1: Download the data producer object.
2: Read it's documentation to determine the output format.
3: Download the data consumer object.
4. Read it's documentation to determine it's input format.
5: Write the necessary code to convert between formats. (Or modify the code for either object.)
In the fray of shameless self-promotion you may have missed the answer (posted by T Chap) that you're looking for:
bytevar := longvar.byte[0]
You can extract any byte from a long or a word using this syntax.
Kye,
I used your object to generate times, etc. and inserted them into the FSRW's setdate just as Kal showed, but I'm still getting oddball dates. (I'm still not sure Kal used FSRW or Kye's SD routines.)
I tried T Chap's technique to create bytes from the longs derived from the DS1307OBJ, bytes that I then put into FSRW's setdate, but I'm still getting oddball dates, though different dates from those generated by Kye's object when used as stated above.
I'm beginning to suspect that the FSRW does something weird with bytes that I fundamentally don't understand. And perhaps Kye's RTC object works really well with Kye's SD card routine, but maybe not with FSRW. I can't find anywhere in the FSRW documentation what kind of variable setdate is supposed to take - byte, word or what?
My program originally used the DS1307OBJ from the i2c object:
http://obex.parallax.com/objects/217/
which returns longs, so all my other code utilizes those longs. But Kye's object returns bytes. And the FSRW does something to the bytes that I haven't been able to fathom.
I guess I could just abandon FSRW and use Kye's SD routine with Kye's RTC and see if that works. But I'm freaked out about this FSRW thing.
Can't a guy get a decent date, even with a microchip?
Okay, will do. It's nice to know that it even works since some of the comments said it didn't.
But what is FSRW want for setdate? A byte?
The DS1307OBJ from the i2c object:
http://obex.parallax.com/objects/217/
returns only the last two digits of the year, so when that value gets plugged into setdate, and gets 1980 or whatever subtracted from it in FSRW, it screws up the bit string.
Maybe a guy can get a decent date after all!
Thanks everyone for your suggestions and patience!