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.

MartinK

Member Since 07 Aug 2012
Offline Last Active Jun 06 2013 04:24 PM
-----

Posts I've Made

In Topic: Netduino Plus 2 problems (InterruptPort & I2C)

12 February 2013 - 10:05 AM

Thanks CW2, you were spot on! :-)

 

The netduino plus 2 is  faster than the old one and so I never noticed that I ignored the max write cycle time - it just wasn't able to poll the eeprom fast enough.

 

Thanks Chris, this could have been the problem - in the meantime I updated to the newest release so I am not absolutely sure if swapping the reference or updating to the newest firmware solved my problems.

 

Anyway, both problems are fixed - thanks for the support!

 

Take care,

Martin


In Topic: Netduino Firmware v4.2.0 RC5 (Netduino + Netduino Plus)

07 August 2012 - 01:47 PM

Hi,
I am using Netduino Plus (v4.2.0.0 RC5) and I've got the following problem:

When reading some files from an Sd-Card an ArgumentOutOfRangeException is thrown when calling StreamReader.ReadLine().

using (FileStream fs = File.OpenRead(filePath))
{
  using (TextReader tr = new StreamReader(fs))
  {
    string line;
    while ((line = tr.ReadLine()) != null)
    ...
  }
}

The stacktrace shows that the exception is thrown inside StreamReader.Peek() which is called internally by StreamReader.ReadLine().

StackTrace:
IndexOutOfRangeException HRESULT: 2835349504
System.IO.StreamReader::Peek
System.IO.StreamReader::ReadLine

The exception
- is only thrown in some files
- is never thrown on the first line
- is always thrown on reading the same line in a file, so I can reproduce it
- is thrown in bigger files (24Kb+), in smaller ones it's working (could be coincidence)

I checked the lines in question and they are neither longer than lines where it works, nor are there any special characters. The only common factor I see atm is the size of the file.

I'd be grateful for suggestions.

EDIT:

I refactored the code to not use the StreamReader and ReadLine and got rid of the exception.

int read;
var buffer = new byte[100];

using (FileStream fs = File.OpenRead(filePath))
{
  while ((read = fs.Read(buffer, 0, buffer.Length)) != 0)
  ..
}

Take care,
Martin

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.