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.

grimbouk's Content

There have been 8 items by grimbouk (Search limited from 23-May 23)


By content type

See this member's

Sort by                Order  

#15027 Netduino Firmware v4.2.0 BETA 1

Posted by grimbouk on 05 July 2011 - 07:44 AM in Beta Firmware and Drivers

Hmm. Thanks for the details. Very interesting.

Two questions:
1. Does ColinR's sample work as a workaround?
2. Does your example work with files on Windows (i.e. is the behavior inconsistent between .NET and .NET MF)?

Chris


Very interesting. I wonder if that has become the recommended way to check for EndOfStream? If you search you'll find that a lot of people give examples they way I use EndOfStream. I managed to find one official example as well: http://msdn.microsof...y/ee461504.aspx (step 9).

Answers:-
2. This design pattern does work in the standard framework as I use it quite often.

1. Interesting, this pattern manages to read all the lines, but doesn't stop trying to read lines when the EndOfStream is hit:-

Debug.Print(File.Exists(filename) ? "File Found" : "File Not Found!");

using (StreamReader sr = new StreamReader(filename))
    {   
        Debug.Print("Initial EOS:" + sr.EndOfStream.ToString());

        String line;    
        // Read and display lines from the file until the end of    
        // the file is reached.    
        while ((line = sr.ReadLine()) != null)    
        {
            Debug.Print("LINE:" + line + " - EOS:" + sr.EndOfStream.ToString());
        }
}

This gived me the following output...

File Found
Initial EOS:True
LINE:TestLine0 - EOS:False
LINE:TestLine1 - EOS:False
LINE:TestLine2 - EOS:False
LINE:TestLine3 - EOS:False
LINE:TestLine4 - EOS:True
LINE: - EOS:True
LINE: - EOS:True
LINE: - EOS:True
...

So it looks like EndOfStream isn't set until the first line is read.

If I step over the code, "line" is never set to null, if there's no data available it seems to be set to empty string. I wouldn't be happy to use this to determin the end of file.

It looks like I can get what I want by using a mix of this approach and adding a check for EndOfStream within the loop, like this:-

using (StreamReader sr = new StreamReader(filename))
{
    Debug.Print("Initial EOS:" + sr.EndOfStream.ToString());
    String line;    
    // Read and display lines from the file until the end of    
    // the file is reached.    
    while ((line = sr.ReadLine()) != null)    
    {
        Debug.Print("LINE:" + line + " - EOS:" + sr.EndOfStream.ToString());
        if (sr.EndOfStream) break;
    }
}

Tim



#15006 Netduino Firmware v4.2.0 BETA 1

Posted by grimbouk on 04 July 2011 - 06:33 PM in Beta Firmware and Drivers

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



#15005 OneWire ALPHA

Posted by grimbouk on 04 July 2011 - 06:14 PM in Beta Firmware and Drivers

Hi Guys, Do you have an update as to when we can expect the OneWire functionality to be rolled into the core platform? From what I've seen it works great... But I am only using it with a couple of DS18B20s. Thanks Tim



#15003 Netduino Firmware v4.2.0 BETA 1

Posted by grimbouk on 04 July 2011 - 06:03 PM in Beta Firmware and Drivers

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



#13918 OneWire ALPHA

Posted by grimbouk on 02 June 2011 - 03:15 PM in Beta Firmware and Drivers

Hi guys, this is great work! Is it possible to provide the same beta firmware for the NetduinoMini? Or have I missed something somewhere? thanks Tim



#13067 switching polarity for a solenoid

Posted by grimbouk on 10 May 2011 - 11:45 AM in General Discussion

Tim, why do you need pushing the N's outputs to +5V?
I agree with Dan: the specs say it is Netduino compatible.
Cheers


Hi Mario,

like I say, I'm a newbie, so I'm probably missing something. I was just worried that the Netduino wouldn't have enough voltage to drive the logic side of the H-Bridge. You guys seem to think there won't be a problem, so I've placed an order and will give it a go.

thanks to both of you for your advice

Tim



#13045 switching polarity for a solenoid

Posted by grimbouk on 10 May 2011 - 07:44 AM in General Discussion

Unless I'm reading the spec sheet wrong, it can handle 2 to 5.5v on the logic side, which means the Netduino can safely drive the SN754410 with out the need for additional components.


Hi Dan,

thanks for the link.

The reason I was asking about driving 5v from netduino was because on the hardware details page:
http://www.netduino....duino/specs.htm

it says this:
digital i/o are 3.3 V--but 5 V tolerant

to me that says the digital outputs will push out 3.3v but the inputs can take up to 5v. Am I wrong? Do I need to do anything to get the outputs to push out 5v?

thanks
Tim



#13011 switching polarity for a solenoid

Posted by grimbouk on 09 May 2011 - 03:01 PM in General Discussion

Hi all, I'm new to electronics, so this may be a silly question... I have 4 9v solenoids that I want to drive independently of each other. To do this I need to be able to reverse the polarity to the solenoids to get them to toggle in one direction or the other (they don't return when unpowered). I asked the best way to achieve this on a different forum and someone suggested I look at an "H-Bridge". I've looked and found L293D or SN754410. Both of these sound like they can drive 2 solenoids, so I'd need 2 of them to drive 4 solenoids. Is this the best approach, or does anyone else have any better / cheaper / easier suggestions? Also, the Logic voltage seems to be 5v. How would I wire this up to the Netduino? thanks Tim




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.