- Netduino Forums
- → grimbouk's Content
grimbouk's Content
There have been 8 items by grimbouk (Search limited from 25-September 23)
#13011 switching polarity for a solenoid
Posted by grimbouk on 09 May 2011 - 03:01 PM in General Discussion
#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
#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
#13918 OneWire ALPHA
Posted by grimbouk on 02 June 2011 - 03:15 PM in Beta Firmware and Drivers
#15005 OneWire ALPHA
Posted by grimbouk on 04 July 2011 - 06:14 PM in Beta Firmware and Drivers
#15003 Netduino Firmware v4.2.0 BETA 1
Posted by grimbouk on 04 July 2011 - 06:03 PM in Beta Firmware and Drivers
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
#15006 Netduino Firmware v4.2.0 BETA 1
Posted by grimbouk on 04 July 2011 - 06:33 PM in Beta Firmware and Drivers
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
- test.txt 55bytes 4 downloads
#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
- Netduino Forums
- → grimbouk's Content
- Privacy Policy