Hello all
I don’t know why but some memory sticks can not be readable:
Device connected…
ID: 2694788704, Interface: 0, Type: 6
USB Mass Storage detected…
#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (3) ####
#### Message:
#### Microsoft.SPOT.IO.NativeIO::GetAttributes [IP: 0000] ####
#### System.IO.Directory::Exists [IP: 0015] ####
#### System.IO.Directory::GetChildren [IP: 000a] ####
#### System.IO.Directory::GetFiles [IP: 0008] ####
#### MFConsoleApplication1.Program::DeviceConnectedEvent [IP: 008a] ####
#### GHI.Premium.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
#### GHI.Premium.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHI.Premium.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####
Une exception de première chance de type ‘System.NotSupportedException’ s’est produite dans Microsoft.SPOT.IO.dll
#### Exception System.IO.IOException - CLR_E_DIRECTORY_NOT_FOUND (3) ####
#### Message:
#### System.IO.Directory::GetChildren [IP: 0017] ####
#### System.IO.Directory::GetFiles [IP: 0008] ####
#### MFConsoleApplication1.Program::DeviceConnectedEvent [IP: 008a] ####
#### GHI.Premium.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
#### GHI.Premium.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHI.Premium.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####
Une exception de première chance de type ‘System.IO.IOException’ s’est produite dans System.IO.dll
Une exception non gérée du type ‘System.IO.IOException’ s’est produite dans System.IO.dll
Here’s the code:
using System;
using Microsoft.SPOT;
using System.IO;
using System.Threading;
using GHI.Premium.System;
using GHI.Premium.USBHost;
using Microsoft.SPOT;
using GHI.Premium.IO;
namespace MFConsoleApplication1
{
public class Program
{
public static PersistentStorage USBps;
public static void Main()
{
// Subscribe to USBH events.
USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
USBHostController.DeviceDisconnectedEvent += DeviceDisconnectedEvent;
// Sleep forever
Thread.Sleep(Timeout.Infinite);
}
static void DeviceConnectedEvent(USBH_Device device)
{
Debug.Print("Device connected...");
Debug.Print("ID: " + device.ID + ", Interface: " + device.INTERFACE_INDEX + ", Type: " + device.TYPE);
if (device.TYPE == USBH_DeviceType.MassStorage)
{
Debug.Print("USB Mass Storage detected...");
Thread.Sleep(1000);
USBps = new PersistentStorage(device);
Thread.Sleep(1000);
USBps.MountFileSystem();
Thread.Sleep(1000);
string[] pth = Directory.GetFiles("\\USB\\");
for (int i = 0; i < pth.Length; i++)
{
Debug.Print(pth[i]);
}
}
}
static void DeviceDisconnectedEvent(USBH_Device device)
{
Debug.Print("Device disconnected...");
Debug.Print("ID: " + device.ID + ", Interface: " +
device.INTERFACE_INDEX + ", Type: " + device.TYPE);
}
}
}
[edit] This happens with a 64Gb MemoryStick