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.

Duefectu

Member Since 29 Nov 2012
Offline Last Active Nov 20 2014 11:00 AM
-----

Posts I've Made

In Topic: Hang on socket connect

05 April 2014 - 11:22 PM

I'm very disappoined about the ND2 network quality.

I solved the problem opening the socket in a new thread. If it hangs not freeze the main thread.

But at long time, I have hangs on the ND2, only if the Ethernet cable is pluged.

I try to change to UDP sockets, with less hangs, but many as desired.

No good quality for me, not for industrial use!


In Topic: Read problems from SD Card

23 December 2013 - 08:13 PM

As I mentioned, you must implement your own ReadLine method.

 

This is a simple implementation. Not tested, and four sure, not the best implementation.

	public bool SearchText(string fileName, string textToFind)        {		var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);		string line="";		while(line!="ERROR")		{            			line=ReadLine(fs);			if(line==textToFind)			{				fs.Close();				return true;			}                }		fs.Close();                return false;        }	private static string Readline(FileStream fs)        {            try            {                byte[] buffer = new byte[1024];                byte b = 0;                byte r = 0;                int l = 1024;                for (int n = 0; n < 1024; n++)                {                    b = (byte)fs.ReadByte();                    if (b == 13)                    {                        r = (byte)fs.ReadByte();                        if (r == 10)                        {                            l = n;                            break;                        }                        else                        {                            buffer[n] = b;                            n++;                        }                    }                    bufer[n] = b;                }                string line = new string(Encoding.UTF8.GetChars(buffer, 0, l));                return line;            }            catch            {                return "ERROR";            }        }

Hope it helps!


In Topic: Read problems from SD Card

23 December 2013 - 09:07 AM

I changed StreamReader to FileStream and it Works, but you must to implement the ReadLine method.


In Topic: read file from SD

09 December 2013 - 07:54 PM

Right (or not), StremReader has a bug, at least for me. FileStream seams to work, at least for now!


In Topic: read file from SD

09 December 2013 - 05:47 PM

Today I take the same error without any change on the code nor ND+2.

 

I changed StreamReader way by FileStream, and it works fine, but with more code.


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.