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

Sd Card write issues


  • Please log in to reply
4 replies to this topic

#1 claudio.serio

claudio.serio

    Member

  • Members
  • PipPip
  • 25 posts

Posted 07 May 2015 - 11:12 AM

Dear all,

 

i'm tring to create and write a line in a file. This is my sub code :

 

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports Microsoft.SPOT.IO
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino
Imports System.IO
 
    Private Sub Create_Settings_File()
        Dim SetFile As FileStream
        Debug.Print("Create Sub")
        SetFile = New FileStream("\SD\Settings.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)
 
        Debug.Print("File opened")
        Debug.Print("Create streamwriter")
 
        Dim sw As New StreamWriter(SetFile)
        Debug.Print("Streamwriter created")
 
        Try
            Debug.Print("write into the file")
            sw.WriteLine("Test")
 
        Catch ex As Exception
 
        Finally
            Debug.Print("Close all")
 
            sw.Close()
            sw.Dispose()
            SetFile.Close()
            SetFile.Dispose()
 
        End Try
        Debug.Print("Exit")
    End Sub
 

I follow the enteire process by the debug points and it seems work.

But when i take the SD card and i put it into a card reader .... it's empty !!

 

I have a N2+ with MF 4.2

I tried 2 MicroSD (128Mb and 2Gb no SDHC)

i tired Fat and Fat32 formatting

 

I thought it was easier .....

 

Thanks all 



#2 HSven1611

HSven1611

    Member

  • Members
  • PipPip
  • 14 posts

Posted 07 May 2015 - 05:15 PM

Hi

 

Did you try 

sw.Flush();

to make the StreamWriter flush it's content?

 

Regards

 

Sven



#3 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 10 May 2015 - 08:43 AM

HI Claudio
 
Hacked up this code which works on my N2P device & confirmed that I can see the file + contents on my W8 tablet.
 
My VB.Net is a bit rusty, so sorry it's C#.
 
Could you try on you device?
 
Bryn
 
@KiwiBryn
blog.devmobile.co.nz
 
 
      try
      {
         // Option 1 to write to file
         using (FileStream file = File.Open(@"\SD\Settings1.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
         {
            using( StreamWriter sw = new StreamWriter( file ))
            {
               sw.WriteLine(" Test writeline 1 at " + DateTime.UtcNow.ToString());
            }
         }
 
         // Option 2 to write to file
         using (StreamWriter sw = new StreamWriter(@"\SD\Settings2.txt", true))
         {
            sw.WriteLine(" Test writeline 2 at " + DateTime.UtcNow.ToString());
         }      
      }
      catch (Exception ex)
      {
         Debug.Print(ex.Message);
      }


#4 Darrell L.

Darrell L.

    Member

  • Members
  • PipPip
  • 14 posts

Posted 28 May 2015 - 11:57 PM

I had the same issue a while back... turns out that the SD card reader on my Netduino Plus 2 was the culprit.  The internal spring-switch

was badly bent and not making proper contact (not allowing write operations to the card).

 

Once I'd bent it back, it worked as it should.

 

You can inspect for this however YMMV.

 

Regards,

 

D.


"Ever since you've fixed that paper jam, my computer has been running slower."


#5 asciiman

asciiman

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts
  • LocationTurkey

Posted 09 June 2015 - 01:56 PM

hi

 

Microsoft.SPOT.IO.VolumeInfo.GetVolumes()[0].FlushAll();

 

but you must read any document about this






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.