Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: t3.5 write sd listing to file

  1. #1

    t3.5 write sd listing to file

    I'm trying to write a file to the sd card that contains a listing of all the files on the sd card.
    my question is can I use root.ls(LS_R) and send it to a file instead of it sending to the serial?
    I can do it with the printDirectory example but seems I should be able to send the output from root.ls to the sd card.
    Any ideas, I'm thinking I need to redirect the stream somehow...

  2. #2
    Ok I think I found it, I create a 'file savData' then call root.ls(&savData, LS_R); this sends the output to the savData file.
    So far seems to work but I found a glitch,
    When I send the output to the Serial with root.ls(LS_R) I get the following list..

    ss718/
    SteriA/
    2020/

    followed by the correct output. However when the stream is output using root.ls(&savData, LS_R) I see the following..

    ss718/
    S???????/
    2020/
    again followed by the correct output. I can't find the reason I get the S??????? instead of the SteriA I'm suppose to get.
    If I look at the sd card I see the file got written with the S???????? as a folder name.
    On the sd card itself the folders are named correctly.

    (EDIT) OK so more testing, if I rename the 2nd folder to steriA from SteriA it works fine. Also if I try Unit1 it gives me the ??????
    anything I try that has a folder name that starts with a capital letter it gives the question marks in the out put.
    More testing required..
    Also, if I try all caps it works fine. tried Unit = ????? but UNIT works fine. It seems to happen only when the first letter is a cap.
    Last edited by Frankthetech; 08-10-2021 at 08:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •