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

Netduino Firmware v4.2.0 BETA 1


  • Please log in to reply
83 replies to this topic

#41 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 June 2011 - 04:32 AM

Hi msgersch, Netduino Plus will automatically mount SD cards. Just look for the "\SD" folder once you insert the card. Welcome to the Netduino community, Chris

#42 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 22 June 2011 - 10:08 AM

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.

#43 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 22 June 2011 - 10:20 AM

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.

Hi Edward,

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.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#44 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 22 June 2011 - 04:28 PM

So far I can't reproduce it. I use firmware "Netduino Plus (v4.2.0.0 b1) by Secret Labs LLC" (BuildDate: Jun 8 2011)

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


"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#45 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 22 June 2011 - 10:10 PM

Thanks for trying to replicate. I'll install the firmware here again and retry.. Card is a 128MB SanDisk (dug out from the back of a dusty drawer, came with an old phone) Formatted as FAT32/2048 by Win7 - files were written by Win7. Path \\SD\www.

#46 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 23 June 2011 - 05:23 AM

Thanks for trying to replicate.
I'll install the firmware here again and retry..

Hi Edward,

If your code fails to run, could you please provide us (a portion of) your code?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#47 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 23 June 2011 - 09:49 PM

I reinstlled everything, reflashed everything and reformatted the card. And all is working fine now. Thanks for taking the time to run those tests it gave me the confidence to give 4.2 another try. Hopefully my next feedback will be more worthwhile!

#48 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 23 June 2011 - 10:04 PM

Spoke to soon. The problem seems to be a power cycling one. If the netduino is powered up with the card in the slot then the exception is thrown. If I take the card out and re-insert it with the power kept on then the progtam will run. So is the problem that the card isn't being mounted at power on only on insertion?

#49 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 24 June 2011 - 06:56 AM

Interesting. So to reproduce it, I need to execute the following steps: - Insert the µSD-card into the Netduino Plus - Put power the Netduino Plus - Execute the program I posted in this thread earlier Then it will fail, am I right? If so, I'm going to try it out tonight! By the way, remember, beta software can always contain a few flaws, it's a risk using Beta firmware. appairently you found a flaw :D
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#50 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 24 June 2011 - 06:39 PM

Interesting. So to reproduce it, I need to execute the following steps:

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?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#51 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 24 June 2011 - 09:19 PM

The code is:

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 mikepo

mikepo

    Member

  • Members
  • PipPip
  • 29 posts

Posted 25 June 2011 - 03:12 AM

Now, reading that it does not work on power-on, but works afterwards, maybe it's a timing/initialization issue for the SD card. Especially since you mentioned it's an older card. How about putting some delay in the code before trying to read the files? Like Thread.Sleep or some delay loop. Giving the card time to initialize. If the timing issue is in the firmware itself mounting the card, this will not help, but it's worth a try. Also, not sure if you have tied that already, but reproducing it with another card might pinpoint ifit's a netduino issue or card compatibility, HTH, Mike

#53 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 June 2011 - 06:10 AM

Hi Edward,

           var fs= Directory.GetFiles(@"SD");

What happens if you use the full path?

fs = Directory.GetFiles(@"\SD");

Chris

#54 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 25 June 2011 - 08:13 AM

Can't reproduce it still, but I thought of something which could be the case. Just to be sure. If you go to your project properties, and go to .NET Micro Framework, to which device are you deploying?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#55 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 28 June 2011 - 09:35 PM

Thanks all for the various helpful suggestions but no change for any of them. I'm awaiting delivery of some 2GB cards to compare results against. Will update again as soon as I get my hands on them.

#56 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 03 July 2011 - 10:07 AM

My 2GB SD cards arrived but only hours before going on vacation. A quick test suggested that they do >not< exhibit the access problems described abover for the 128MB card. 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?

#57 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 03 July 2011 - 10:46 AM

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?

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.

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 grimbouk

grimbouk

    New Member

  • Members
  • Pip
  • 8 posts

Posted 04 July 2011 - 06:03 PM

hi guys,

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 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 July 2011 - 06:09 PM

Hi Tim, Could you please attach the file? [Also, silly question...is the file empty?] Chris

#60 grimbouk

grimbouk

    New Member

  • Members
  • Pip
  • 8 posts

Posted 04 July 2011 - 06:33 PM

Hi Chris,

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

  • Attached File  test.txt   55bytes   4 downloads





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.