Shop OBEX P1 Docs P2 Docs Learn Events
[solved] Need help getting Line Feed in my logged txt file from Parallax USB D — Parallax Forums

[solved] Need help getting Line Feed in my logged txt file from Parallax USB D

Tired2Tired2 Posts: 29
edited 2009-10-15 09:07 in Propeller 1
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...

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. smile.gif

Post Edited (Tired2) : 10/14/2009 4:35:15 PM GMT

Comments

  • Tired2Tired2 Posts: 29
    edited 2009-10-14 16:31
    So,

    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:

    logger.writeToFile(string("Line1"),5,0)        ' first string
    logger.writeToFile(string(logger#CR),1,0)   ' Carriage return (DEC 13)
    logger.writeToFile(string($0A),1,0)             ' Line Feed (DEC 10)
    logger.writeToFile(string("Line2"),5,0)         'second string
    
    



    Sorry for the forum clutter [noparse]:)[/noparse]
  • SRLMSRLM Posts: 5,045
    edited 2009-10-15 03:24
    Here is a link where I discovered the CR/LF requirement for myself...

    http://forums.parallax.com/showthread.php?p=836771
  • Tired2Tired2 Posts: 29
    edited 2009-10-15 04:47
    SRLM,

    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.
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2009-10-15 09:07
    This actually goes way back to the days of dot matrix printers. The carriage return is used to return the print head carriage to it's home position (far left). The line feed is to advance the paper rollers to the next line for printing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    WBA-TH1M Sensirion SHT11 Module
    Special Olympics Polar Bear Plunge, Mar 20, 2010
Sign In or Register to comment.