Netduino home hardware projects downloads community

Jump to content


Photo

ND3 hangs calling File.Delete()

SD Wifi Netduino

  • Please log in to reply
4 replies to this topic

#1 ukkiwisurfer

ukkiwisurfer

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationLondon

Posted 06 November 2015 - 09:19 AM

Hi,

 

I've had a search through the forums and found questions being asked (with no solutions from Secret Labs) on how to address hanging NDs with respect to corruption on SDs.

 

Scenario: ND3 (Wifi) on mains, power fails while ND is writing to SD. Subsequent to this the File.Delete() operation will hang the ND indefinitely. Theres no exception being raised and (obviously) there is no timeout you can provide when requesting a delete operation.

 

One solution is to provide a battery back up for the ND so you don't get this sort of scenario, but I'd like to understand what is actually happening so I actually address the issue and not the symptom.

 

Has anyone else had any luck remedying this sort of issue, especially for remotely deployed devices that are difficult to get access to?

 

Thanks,

Jason.



#2 ukkiwisurfer

ukkiwisurfer

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationLondon

Posted 08 November 2015 - 11:27 PM

I've swapped out the SD card from this ND3 for another and the issue seems to have gone away. However it implies that the file.IO logic is choking on something and completely killing the ND3. That doesn't seem right...

 

Chris, is there any known issues around this that you are aware of?



#3 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 09 November 2015 - 06:30 AM

I've swapped out the SD card from this ND3 for another and the issue seems to have gone away. However it implies that the file.IO logic is choking on something and completely killing the ND3. That doesn't seem right...

Just out of interest, what size SD card were you using ?

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#4 ukkiwisurfer

ukkiwisurfer

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationLondon

Posted 09 November 2015 - 09:53 AM

Hi Mark,

 

It's a 2GB SanDisk micro SD card. However after my last post it seems the problem is back on a different card. 

 

The thread ran from 2015-11-09 00:28:09.152 until 2015-11-09 00:52:44.284 this morning. Interestingly, after looking at the log files the last entry in the log file is:

 

2015-11-09 00:52:44.284 | 13 | ArchiveDataService | Deleting 6 of 7 files.

 

The code is as below:

 

    m_Logger.Debug("Deleting {0} of {1} files.", fileIndex, fileCount);

 

    long fileSize = m_FileHelper.GetFileSize(m_Configuration.TargetPath, fileName);

    if (fileSize >= 0)

    {

      m_Logger.Debug("Deleting file. Filesize: {0} bytes, ArchivePath: '{1}', Filename: '{2}'",  fileSize, m_Configuration.ArchivePath, fileName);

      m_FileHelper.DeleteFile(m_Configuration.ArchivePath, fileName);

     }

 

which implies that the code blocked on attempting to get the file size. And getting the file size operation is as follows:

 

 public long GetFileSize(string targetPath, string fileName)

 {

            long fileSize = 0;

 

            string filePath = Path.Combine(targetPath, fileName);

            if (File.Exists(filePath))

            {

                var info = new FileInfo(filePath);

                fileSize = info.Length;

            }

 

            return fileSize;

  }

 

Any suggestions?

 

Thanks,

Jason.



#5 ukkiwisurfer

ukkiwisurfer

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationLondon

Posted 09 November 2015 - 10:02 AM

What is also interesting is whether there is any relationship between this issue and http://forums.netdui...become-broken/ 

 

I've seen this File.Delete() issue before and I've also seen the FileStream.Read() operation issue as well. The FileStream.Read() issue reared its head yesterday afternoon and late last night I saw the first incidence of the File.Delete() blocking issue. I powered off the board and continued running the soak test.

 

This morning found the File.Delete issue had re-occurred. I find it difficult to see it as a simple coincidence given they are both File.IO issues against the same SD card.

 

Thanks,

Jason. 







Also tagged with one or more of these keywords: SD, Wifi, Netduino

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.