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.

366cobra

Member Since 24 Jan 2013
Offline Last Active Sep 05 2015 05:52 AM
-----

Topics I've Started

I2C issue with multiple sensors

09 October 2014 - 11:23 AM

Hi,

 

If I use one device, all is good.

If I connect a second one, without even communicating with it, I cannot get any more readings.

 

My base class creates only one I2CDevice and for a read, the configuration is assigned and then the "Execute" is called inside a lock of the device.

Have found a post of someone using a similar technique: http://forums.netdui...bus/#entry41552

Only difference I have, is that I create the array inside the function and throw an exception in case of an error.

 

I have no idea where I am going wrong.

Would be great, if someone has an idea or comment.

 

Thanks

Martin

 

Netduino Plus 2, firmware 4.3.1

I2C Lux sensor

I2C PH meter

 


FileStream Write blocks multi threaded app

20 August 2014 - 11:18 AM

Hi,

 

I have updated my NP2 to 4.3.1 about 3 weeks ago and also upgraded my app to .NET 4.3.

Now I am noticing that the file write seems to kill the whole app.

 

The app is multi threaded, reading different sensors, which write the data to a file.

i am using the file as a buffer, as the network may be cut, but the app should not miss any readings.

 

The write is inside a lock, so the threads will not be able to use the same file obj at the same time.

I open the file once in a singleton obj and use it to write and flush the data to file.

Since there is a lot of data going into the file, I do not want to open, wite, flush and close it all the time.

The app can log dozens of readings per sec.

 

Below is the line where the file gets opened and below that how the data get written to the file.

The last log that is printed is "WriteToFile lock" and after that the whole app just dies.

All thread seem to get blocked.

I would expect multiple "WriteToFile begin" lines, until all thread are stuck at the "WriteToFile begin"

e.g.

 

WriteToFile begin

WriteToFile lock

WriteToFile begin

WriteToFile begin

WriteToFile begin

WriteToFile begin

m_oWriteFile = new FileStream(m_sLogFileName, FileMode.OpenOrCreate, FileAccess.Write);
   protected void WriteToFile(byte[] a_sData)
   {
      Debug.Print("WriteToFile begin");
      lock (m_oFileLock)
      {
         Debug.Print("WriteToFile lock");
         try
         {
            if (m_oWriteFile != null)
            {
               m_oWriteFile.Write(a_sData, 0, a_sData.Length);
               m_oWriteFile.Flush();
            }
         }
         catch (Exception ex)
         {
            Debug.Print("EXCEPTION: CSdCard:WriteToFile - " + (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
         }
      }
      Debug.Print("WriteToFile end");
   }

With an older firmware version the code above worked fine.

Has anyone got an idea what this could be?

Bug in 4.3.1?

 


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.