question re Use of input string as a filename for SD Card
Paul_H
Posts: 85
Happy Thanksgiving Everyone! I hope you all enjoy this favorite holiday of mine!
I unfortunately left my protoboard at the office yesterday and won;t be going back until Monday so am without a testbed this weekend, hence my question instead of a trial and error effort.
I am using Rokiki's SD card routines for datalogging, but would like to use an input string as the filename on the SD card rather than the fixed name in the DAT section of the standard SD routines. (I'll be using the GPS-provided date string in this case).
How can I use a returned variable string, ie:
in place of the @Filename in:
Thanks for your suggestions. As long as I have been programming SPIN, I still haven't gotten the hang of that @sign...
Paul
I unfortunately left my protoboard at the office yesterday and won;t be going back until Monday so am without a testbed this weekend, hence my question instead of a trial and error effort.
I am using Rokiki's SD card routines for datalogging, but would like to use an input string as the filename on the SD card rather than the fixed name in the DAT section of the standard SD routines. (I'll be using the GPS-provided date string in this case).
How can I use a returned variable string, ie:
variableinfo := gps.date()
in place of the @Filename in:
DAT FileName byte "DATALOG.TXT", 0 ' Name of file that we will write to PUB LOGIT Modem.startx(RX_Pin, TX_Pin, Mode, BaudRate) ' Start serial port for gps sdfat.mount(SD_base) ' mount the SD card on pins P0 to P3 sdfat.popen(@FileName, "a") ' Open the file for append ..etc...
Thanks for your suggestions. As long as I have been programming SPIN, I still haven't gotten the hang of that @sign...
Paul
Comments
Spin has very limited string manipulation. You can basically copy a sequence of bytes from one place to another (with BYTEMOVE) and you can compare two strings for equality (with STRCOMP). You can also do other manipulation one byte at a time by writing your own code to do so. I don't know what gps.date returns, but you need to convert it to an 8 character sequence of bytes, preferably ASCII digits and letters. This needs to be copied over the 1st 8 characters of the FileName variable or you need to pass the address of whatever you use instead of the address of FileName to the sdfat.popen routine.
Thanks for the reply - the @<mem addy> is what I had thought, but I hadn't quite settled on it. Thanks for the clarification.
Sorry I wasn't clear in my question about my functions - gps.date() returns the value of an array containing the current date information that has been previously parsed and zero terminated. It is in bytes. So in the case:
"variableinfo" below is assigned by the gps.data PUB to a value like "071121", (representing Nov 11, 2007).
So...if I get this @ thing correct, I should use:
to point to the memory location of my gps.date()-assigned variable, just like it did when the routine used a fixed DAT-assigned value.
I hope Im on the right track! Thoughts?
Paul
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.
Remember that the filename will be whatever is in that string, so it won't have ".txt" or the like unless you put it there.
I used the code below in a datalogging prog I am working on.
If you want I can mail the whole spinprog.
PUB Createfile 'Creates a filename with todays date and Time and write a timestamp in the created file
DateForSDcard
char:=0
Filnamnet 'PUB which creates the filename se below
'nedan fungerar f
This is just what I am working towards. Your post makes it clear how you are creating the filename from the variable information. I'll work through your example and work this concept into my routine. When complete I'll post the code back here.
Mike - understood on the naming. I'll be adding the file extension myself. It'll start as ".txt" and move to ".xml" when I get my XML heading program together.
Thanks Everyone!
Paul
Post Edited (Paul H) : 11/22/2007 6:21:03 PM GMT
I'd also take a look at FemtoBASIC. It was a valuable source for information when I created
PropDOS
http://forums.parallax.com/showthread.php?p=683157
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.