Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

MicroSD card failure

Netduino Plus 1 MicroSD

  • Please log in to reply
3 replies to this topic

#1 Sukasa

Sukasa

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationNanaimo, BC

Posted 16 February 2013 - 05:35 AM

Is there a trick to writing text to a file stored on MicroSD?  I am trying to write text to it using a FileStream and StreamWriter, however even when I call Flush() on both the StreamWriter and FIleStream (in that order), data is very rarely written to the MicroSD card, to where files can be created and yet be 0 bytes long, even if I step through the code that writes and flushes data to that file in Visual Studio.

 

Furthermore, I am creating a file named "log.txt", and later in the program after I have retrieved the current date/time over Ntp, I call File.Move().  This results in no change to log.txt (still an empty file), or even worse: it simply deletes log.txt without creating the destination file.  The netduino code manages to, despite this, still open and write to that file in code, yet never write any data to the MicroSD card.

 

I've confirmed that the microSD card works with a separate card reader, and I am able to write data to it just fine.  The nature of the log (in that it is a debug log) means I can only call Close() on it if an exception is thrown as opposed to crashing in a non-exception state.  Even if I am able to successfully call Flush() and then Close() on the StreamWriter and FileStream (Flush() on the StreamWriter first and then the FileStream, and then Close() on both) *and* call Thread.Sleep() to give the netduino time to write to the MicroSD card, no data is written and I'm unable to retrieve debug log information from the Netduino Plus 1.

 

Why does Flush() not immediately write data to the MicroSD card, nor apparently Close()?

 

Better yet, what could I be doing so catastrophically wrong that the netduino is apparently able to open and write to a file that, according to Windows afterwards, doesn't exist?



#2 Verdris

Verdris

    Advanced Member

  • Members
  • PipPipPip
  • 128 posts
  • LocationReno, NV

Posted 16 February 2013 - 05:45 PM

I have started another thread with my sd problems. I'm rarely able to create files unless the card is present at powerup/reset, and ejecting the card mid-program often leads to a corruption. Even powering off the netduino before removing the card potentially corrupts things.

 

It may be that the NP2 just has some SD issues for now.



#3 Sukasa

Sukasa

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationNanaimo, BC

Posted 16 February 2013 - 09:46 PM

This is a plus one, not a plus two.  And the SD card is present from powerup to poweroff, as the program won't even run if that isn't the case (the log file is created immediately upon startup)



#4 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 17 February 2013 - 01:02 AM

Sukasa,

 

Even though your troubles are different from those of Verdris's, it might still be worth your while trying this piece of code that we tried in effort of solving his problems:

 

http://forums.netdui...ems/#entry45513

 

It is written for a regular N+ like yours and no external hardware required. Works on both mine an Verdris's N+ so it should work on yours too.

 

Maybe you can get something out of it to help you?







Also tagged with one or more of these keywords: Netduino Plus 1, MicroSD

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.