[solved] Need help getting Line Feed in my logged txt file from Parallax USB D
Tired2
Posts: 29
Hi,
I have had pretty decent luck using the Data Logger SPI Mode object for the propeller memory stick data logger (Vinculum Chip)
http://obex.parallax.com/objects/237/
I am able to write a file using similar structure to as demonstrated in the test program, but all of my code ends up on one line in the log.
So, the following code...
...will result in the txt file containing the test "String1String2" as expected.
So, for the Line Feed, I have tried many different things between the two strings such as:
I have had mixed results, but nothing ends up generating an actual line feed in the txt file.
I know the line feed character is "%1010" "$0A" "10", etc, but I'm not sure how to get it to send that data to the file.
Any help would be appreciated, I have not had much luck with the documentation or sample programs... most samples use the UART interface which I have not tried yet... I just felt like SPI would be faster and with less overhead.
Any input is appreciated.
Thanks.
Post Edited (Tired2) : 10/14/2009 4:35:15 PM GMT
I have had pretty decent luck using the Data Logger SPI Mode object for the propeller memory stick data logger (Vinculum Chip)
http://obex.parallax.com/objects/237/
I am able to write a file using similar structure to as demonstrated in the test program, but all of my code ends up on one line in the log.
So, the following code...
if logger.openFileForWrite(string("testfile.txt"),0) logger.writeToFile(string("String1"),7,0) ' test data 1 logger.writeToFile(string("String2"),7,0) ' test data 2 logger.closeFile(string("testfile.txt"))
...will result in the txt file containing the test "String1String2" as expected.
So, for the Line Feed, I have tried many different things between the two strings such as:
logger.writeByte(logger#LF)
logger.writeByte("W") logger.writeByte("R") logger.writeByte("F") logger.writeByte(10)
I have had mixed results, but nothing ends up generating an actual line feed in the txt file.
I know the line feed character is "%1010" "$0A" "10", etc, but I'm not sure how to get it to send that data to the file.
Any help would be appreciated, I have not had much luck with the documentation or sample programs... most samples use the UART interface which I have not tried yet... I just felt like SPI would be faster and with less overhead.
Any input is appreciated.
Thanks.
Post Edited (Tired2) : 10/14/2009 4:35:15 PM GMT
Comments
Sometimes, it seems, putting your thoughts on paper leads you to the answer...
The problem was that when using notepad, I was getting a small box instead of the "invisible" line feed I was hoping for. All it took was me remembering the old unix2dos days, and the difference in a CR vs CR/LF.
I'll leave this post up for anyone who might have the same problem in the future...
The way windows (dos) likes to have the file is a CR, then an LF.
Here is the code:
Sorry for the forum clutter [noparse]:)[/noparse]
http://forums.parallax.com/showthread.php?p=836771
Thanks for the reply, and the additional information! I guess I should have searched more thoroughly.
I'll have to read through your test program and such tomorrow when I'll comprehend it. I chose to use SPI because I assumed it would have less overhead and higher performance... though I have to admit I just guessed it and dove in [noparse]:)[/noparse]
I'm glad you mentioned the things you learned that seemed undocumented... especially the closing of a file... I think I'll have to close and reopen it every X iterations of the log just to make sure I get a decent tradeoff between throughput and poweroff data retention.
Looking forward to digging through your code tomorrow.
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
WBA-TH1M Sensirion SHT11 Module
Special Olympics Polar Bear Plunge, Mar 20, 2010