Netduino Firmware v4.2.0 BETA 1
#41
Posted 21 June 2011 - 04:32 AM
#42
Posted 22 June 2011 - 10:08 AM
#43
Posted 22 June 2011 - 10:20 AM
Hi Edward,I tried the v4.2 firmware briefly. Had big problems working with SD card (256MB) on the Plus. Seemed like it would only work with files in the root directory.
Trying to access anything in a sub-directory (eg, GetFiles) would throw a NotSupported exception. Same code working fine in the 4.1 beta so rolled back to that for now.
That's interesting. Could you provide me with the brand of the SD-card, the filesystem (FAT16/FAT32), the clustersize (512/1024/etc.) and the full path name of the subdirectory you try to read from (ex.: \SD\Foldername\)?
I'll try to reproduce it tonight. It could be a problem with the filesystem or unsupported characters in the path or something.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#44
Posted 22 June 2011 - 04:28 PM
This is my working code:
using System; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.IO; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; using SecretLabs.NETMF.IO; namespace Folder_Bug_test { public class Program { public static void Main() { // Created a test folder Directory.CreateDirectory("SD\\Test"); // Creates 10 text files for (int FileNo = 0; FileNo < 10; ++FileNo) { FileStream test = new FileStream("SD\\Test\\File " + FileNo.ToString() + ".txt", FileMode.CreateNew); test.Write(new byte[] { 0x54, 0x45, 0x53, 0x54 }, 0, 4); test.Close(); } // Creates 10 subfolders for (int DirNo = 0; DirNo < 10; ++DirNo) { Directory.CreateDirectory("SD\\Test\\Subfolder " + DirNo.ToString()); } // Reads all filenames string[] Files = Directory.GetFiles("SD\\Test"); for (int FileNo = 0; FileNo < Files.Length; ++FileNo) { Debug.Print("Found file: " + Files[FileNo]); } // Reads all directories string[] Directories = Directory.GetDirectories("SD\\Test"); for (int DirNo = 0; DirNo < Directories.Length; ++DirNo) { Debug.Print("Found directory: " + Directories[DirNo]); } } } }
This is the output:
Found file: \SD\Test\File 0.txt
Found file: \SD\Test\File 1.txt
Found file: \SD\Test\File 2.txt
Found file: \SD\Test\File 3.txt
Found file: \SD\Test\File 4.txt
Found file: \SD\Test\File 5.txt
Found file: \SD\Test\File 6.txt
Found file: \SD\Test\File 7.txt
Found file: \SD\Test\File 8.txt
Found file: \SD\Test\File 9.txt
Found directory: \SD\Test\Subfolder 0
Found directory: \SD\Test\Subfolder 1
Found directory: \SD\Test\Subfolder 2
Found directory: \SD\Test\Subfolder 3
Found directory: \SD\Test\Subfolder 4
Found directory: \SD\Test\Subfolder 5
Found directory: \SD\Test\Subfolder 6
Found directory: \SD\Test\Subfolder 7
Found directory: \SD\Test\Subfolder 8
Found directory: \SD\Test\Subfolder 9
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#45
Posted 22 June 2011 - 10:10 PM
#46
Posted 23 June 2011 - 05:23 AM
Hi Edward,Thanks for trying to replicate.
I'll install the firmware here again and retry..
If your code fails to run, could you please provide us (a portion of) your code?
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#47
Posted 23 June 2011 - 09:49 PM
#48
Posted 23 June 2011 - 10:04 PM
#49
Posted 24 June 2011 - 06:56 AM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#50
Posted 24 June 2011 - 06:39 PM
Nope, can't reproduce it that way. Is it possible you can mention the exact steps and perhaps (a part of) the source code to reproduce it?Interesting. So to reproduce it, I need to execute the following steps:
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#51
Posted 24 June 2011 - 09:19 PM
using System; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.IO; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; using SecretLabs.NETMF.IO; namespace SD_Card_test { public class Program { public static void Main() { var fs= Directory.GetFiles(@"SD"); } } }
and the exception is:
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.IO.dll
An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.IO.dll
By the way, remember, beta software can always contain a few flaws, it's a risk using Beta firmware.
appairently you found a flaw
yup - trying to help find them and fix them!
#52
Posted 25 June 2011 - 03:12 AM
#53
Posted 25 June 2011 - 06:10 AM
What happens if you use the full path?
var fs= Directory.GetFiles(@"SD");
fs = Directory.GetFiles(@"\SD");
Chris
#54
Posted 25 June 2011 - 08:13 AM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#55
Posted 28 June 2011 - 09:35 PM
#56
Posted 03 July 2011 - 10:07 AM
#57
Posted 03 July 2011 - 10:46 AM
We build the tuning down of buffer sizes into the v4.1.0.0 firmware, and it's now included in the v4.2 firmware as well.One question; clarification about what is in and what in not included in the 4.2 B1 release - is the tuning down of buffer sizes and counts for SD card FAT file access to alleviate memory allocation problems included in this firmware?
What is the FAT file access count memory issue? If that has been changed in the 4.2 codebase, it's included as well.
The GC bugfixes are included for sure.
We'll be posting v4.2 beta 2 later this weekend, now with "WithEvents" support for VB programmers.
Chris
#58
Posted 04 July 2011 - 06:03 PM
should "EndOfStream" for StreamReader be working at the momment?
The following code always returns "True" and never drops into the loop to read data
StreamReader sr = new StreamReader("SD\\Filename.txt"); while (!sr.EndOfStream) { string line = sr.ReadLine(); } sr.Close()
any ideas?
thanks
Tim
#59
Posted 04 July 2011 - 06:09 PM
#60
Posted 04 July 2011 - 06:33 PM
Hi Tim,
Could you please attach the file? [Also, silly question...is the file empty?]
Chris
sure. I'm actually writing the file in a previous session using streamwriter. The file looks fine, I can open it by taking the SD card and putting it in an addapter on my PC. I haven't checked yet if the lines are terminated correctly though.
Here's some sample code:-
string filename = "SD\\test.txt"; StreamWriter sw = new StreamWriter(filename); for (int i = 0; i < 5; i++ ) { sw.WriteLine("TestLine" + i.ToString()); } sw.Flush(); sw.Close(); Debug.Print(File.Exists(filename) ? "File Found" : "File Not Found!"); StreamReader sr = new StreamReader(filename); while (!sr.EndOfStream) { string line = sr.ReadLine(); Debug.Print(line); } sr.Close();
When I run the code I get the "FileFound" output, but nothing is returned for reading the lines. Any ideas what I'm doing wrong?
I've attached the file that's created as well.
thanks
Tim
Update: If I skip the check for !sr.EndOfStream, and just do a ReadLine, I do just get the first line of data. At least this proves that reading data works and that each line of data seems terminated correctly. It does just seem that EndOfStream is not working... or I'm misusing it ;-)
Attached Files
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users