Best Answer Kip, 26 February 2014 - 01:01 PM
Netduino doesn't support SDHCs, just plain old SDs
Go to the full post  | ||||||||||||||
Write to SD Card
Started by NoxiaZ, Feb 25 2014 10:58 AM
Best Answer Kip, 26 February 2014 - 01:01 PM
Netduino doesn't support SDHCs, just plain old SDs Go to the full post
7 replies to this topic
#1Posted 25 February 2014 - 10:58 AM Hey,
Im using framework 4.3 and trying to write to an SD card, but gives me an error:
An unhandled exception of type 'System.NotSupportedException' occurred in System.IO.dll
on this line:
Stream st = new FileStream(@"SDtest.txt", FileMode.OpenOrCreate);
Whats wrong? :S #2Posted 26 February 2014 - 01:36 AM
Hi NoxiaZ,
First thing...please add a "" before "SD", making it "SD".
Beyond that: is your Netduino Plus 2 detecting the SD card (i.e. you see a "SD" folder when you do GetDirectories on @"")? Can you see the files on the SD card using GetFiles?
The SD code in 4.3.1 should be identical to 4.2.2.2. We ran our standard SD card tests (from our test jigs) on the firmware before posting it...so the basic SD functionality at minimum is working in the firmware.
Chris
#3Posted 26 February 2014 - 10:53 AM Hi Chris,
i have tried everything nearly for writing.
try
And this is the log:
Directories count: 1 #4Posted 26 February 2014 - 11:21 AM
Hi NoxiaZ,
Please try reformatting your card on your PC.
BTW, what size is the card? <=2GB? Or a larger SDHC card?
Chris
#5Posted 26 February 2014 - 11:48 AM I just reformatting it, and its a SDHC 8GB - Is that a problem? :/ #6Posted 26 February 2014 - 01:01 PM Best Answer Netduino doesn't support SDHCs, just plain old SDs
#7Posted 26 February 2014 - 01:15 PM Ohh
And thanks for you answer #8Posted 20 March 2014 - 01:27 PM Would be nice to have one central location where all the answers are laid out simply. There's a lot of info out there, but it's scattered, and a lot of it is wrong (good-intentioned people who are coding and testing with bad results). Here's what I think I know so far...
I'm using a Netduino Plus 2, programming in VB with Visual Studio 2013, but using MF 4.2 (not 4.3). I've successfully written code to flash LED's, move servos, accept TCP/IP connections, etc.
Like most people, I thought just any old micro form-factor card would work. I found a 2GB SD (non-SDHC) micro SanDisk card for under $6 (I added to my Amazon list here http://astore.amazon...ar01-20?&node=4 if you want a quick reference -- buy two, they're small!).
Per other suggestions, I formatted it on my PC (FAT, allocation unit size 32K, volume label "NetD-01", not quick-formatted).
I have the following simple code, taken from what appears to be several successful C# SD writing examples:
Try Using SW As New System.IO.StreamWriter("\SD\Test.txt") SW.WriteLine("This is a test!") End Using Catch ex as Exception Debug.Print("Error writing to SD card: " & ex.Message) End Try
THIS WORKS! I removed the SD card, put it in my PC, and that file is present and readable! You'll note that the Date Modified is not accurate unless you have something to set your Netduino's clock.
Note: At first I tried the StreamWriter to write simply to "Test.txt", but this threw an error. Apparently you MUST include the full path.
I hope this helps anyone
1 user(s) are reading this topic0 members, 1 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||