Datalogger string hassles
CumQuaT
Posts: 156
Hi all,
I'm working on a project that requires me to save number values into a text file on a flashcard (I'm using the memory stick datalogger) and after a LOT of hassles, finally got that part working fine.
Now I'm up to the bit where I need the prop to pull the values back out of the text file. I'm using the default USB Datalogger object to do the transfer and it has the following code in it to read data back from the Flashcard:
It seems to return a string value, but as far as I know, the prop doesn't handle strings, does it? My text document is laid out like this internally:
So yeah, 10 numbers, one on each line, then a hyphen, then another 10 numbers, etc, etc. Is anyone familiar enough with this particular bit of code that would know precisely how to use it?
Any help would be great. Thanks in advance!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
I'm working on a project that requires me to save number values into a text file on a flashcard (I'm using the memory stick datalogger) and after a LOT of hassles, finally got that part working fine.
Now I'm up to the bit where I need the prop to pull the values back out of the text file. I'm using the default USB Datalogger object to do the transfer and it has the following code in it to read data back from the Flashcard:
PUB Read(readLength,stringptr) | i ' Read data from file (file must be preopened) 'This will send back the requested amount of data to the monitor. USB.rxflush USB.str(string("RDF ")) USB.tx((readLength>>24) & $FF) USB.tx((readLength>>16) & $FF) USB.tx((readLength>> 8) & $FF) USB.tx( readLength & $FF) USB.tx(CR) repeat i from 0 to readLength-1 byte[noparse][[/noparse]stringptr++] := USB.rx
It seems to return a string value, but as far as I know, the prop doesn't handle strings, does it? My text document is laid out like this internally:
49 55 48 48 66 67 66 67 67 70 - 49 55 48 48 66 67 51 70 70 55 -
So yeah, 10 numbers, one on each line, then a hyphen, then another 10 numbers, etc, etc. Is anyone familiar enough with this particular bit of code that would know precisely how to use it?
Any help would be great. Thanks in advance!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
Comments
You can create strings with the string() function (check out the string functions in the Manual), or just set aside a block of memory to put a string in it, just make sure it is 0-terminated.
As for help for this specific problem, someone else will need to do so.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
Some of my objects:
MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
stringptr[noparse][[/noparse] 0] == 49
stringptr[noparse][[/noparse] 1] == 55
stringptr[noparse][[/noparse] 2] == 48
Not sure if this really answers you question but it looks like you are reading and writing the file, now trying to figure out how to work with the data after you read it.
Post Edited (Todd Chapman) : 6/16/2010 3:42:50 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
As Todd mentioned you need to post the rest of your code, how you call Read may have problems.
One place to look is in obex look for a file called obex_format.spin it contains various functions for string to number translation which can be used to translate the strings once read from the file into numbers but if the array contains 0, you haven't read the string in correctly yet. I expect you first need to read the file in as a string, so the stringptr will contain 34, 39, .. i.e. 34 is the value for character "4", etc. then translate each line into a number.
The obex_format.spin object sounds interesting, that may have what I need. It's pretty much a string to number conversion that I need, I reckon, so I'll give that a go. Thanks for looking into it for me!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
Try this and see what happens. Put in a fake name to read that is not on the drive, you should get back a response that says something similar to file not found or other error. If you are displaying the real response, you will get some hex the you can post. Use ECS and HEX mode.
Either of these will produce a response. If you cannot get a response from CD or DIR then you have other problems to deal with before you can start reading files.
Post Edited (Todd Chapman) : 6/17/2010 6:34:36 AM GMT