Hello
I just connected an USB hub to my FEZ Cobra II and put 2 USB flash drives into it. The first one is mounted correctly:
USB Mass Storage detected...
Storage "\USB" is inserted.
Total size of storage device \USB is : 3.44 GB.
Total free memory on \USB is : 2.93 GB.
The second is mounted but gets a very strage name:
USB Mass Storage detected...
Storage "\USB_1��NO NAME " is inserted.
Total size of storage device \USB_1��NO NAME is : 3.80 GB.
Total free memory on \USB_1��NO NAME is : 3.59 GB.
When I remove the first one everything seems to work:
Storage "\USB" is ejected.
But I get an exception when I remove the USB flash drive that was inserted last:
#### Exception System.Exception - CLR_E_WRONG_TYPE (4) ####
#### Message:
#### System.String::ToUpper [IP: 0000] ####
#### System.IO.FileSystemManager::ForceRemoveNameSpace [IP: 0007] ####
#### Microsoft.SPOT.IO.RemovableMedia::MessageHandler [IP: 005c] ####
A first chance exception of type 'System.Exception' occurred in mscorlib.dll
An unhandled exception of type 'System.Exception' occurred in mscorlib.dll
It might have to do with the strange name the second drive gets assigned, since it originates in String::ToUpper.
Here is my test code:
using System.Collections;
using System.Threading;
using GHI.Premium.IO;
using GHI.Premium.System;
using GHI.Premium.USBHost;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
namespace UsbWrite
{
public class Program
{
private static readonly ArrayList Storages = new ArrayList();
public static void Main()
{
USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
RemovableMedia.Insert += RemovableMedia_Insert;
RemovableMedia.Eject += RemovableMedia_Eject;
Thread.Sleep(Timeout.Infinite);
}
static void DeviceConnectedEvent(USBH_Device device)
{
if (device.TYPE == USBH_DeviceType.MassStorage)
{
Debug.Print("USB Mass Storage detected...");
var storage = new PersistentStorage(device);
storage.MountFileSystem();
Storages.Add(storage);
}
}
static void RemovableMedia_Insert(object sender, MediaEventArgs e)
{
Debug.Print("");
Debug.Print("Storage \"" + e.Volume.RootDirectory + "\" is inserted.");
if (e.Volume.IsFormatted)
{
Debug.Print("Total size of storage device " + e.Volume.RootDirectory + " is : " + (e.Volume.TotalSize / (float)(1<<30)).ToString("F2") + " GB.");
Debug.Print("Total free memory on " + e.Volume.RootDirectory + " is : " + (e.Volume.TotalFreeSpace / (float)(1 << 30)).ToString("F2") + " GB.");
}
else
{
Debug.Print("Storage is not formatted. Format on PC with FAT32/FAT16 first.");
}
}
static void RemovableMedia_Eject(object sender, MediaEventArgs e)
{
Debug.Print("Storage \"" + e.Volume.RootDirectory + "\" is ejected.");
}
}
}
Is there something I did wrong, or are 2 flash drives just not supported?
Greetings
Peter