I am using the following code to test the USB Host on a custom G120 based board. The MassStorageConnected event is never fired. I am using the latest SDK. The relevant part of the circuit is attached. Any help is appreciated!
using GHI.Usb.Host;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using System.IO;
using System.Text;
using System.Threading;
public class Program
{
private static AutoResetEvent evt = new AutoResetEvent(false);
public static void Main()
{
Controller.MassStorageConnected += Controller_MassStorageConnected;
Controller.Start();
Thread.Sleep(-1);
}
private static void Controller_MassStorageConnected(object sender, MassStorage massStorage)
{
RemovableMedia.Insert += RemovableMedia_Insert;
massStorage.Mount();
evt.WaitOne();
using (var fs = new FileStream("\\USB\\Hello.txt", FileMode.OpenOrCreate))
fs.Write(Encoding.UTF8.GetBytes("Hello, World!"), 0, 13);
massStorage.Unmount();
}
private static void RemovableMedia_Insert(object sender, MediaEventArgs e)
{
Debug.Print("Inserted.");
evt.Set();
}
I tested this on a Cobra II mainboard and although the MassStorageConnected event was fired, the RemovableMedia.Insert was NOT fired! What am I doing wrong?
@ cyberh0me - MassStorageConnected is NOT fired on the custom board. MassStorageConnected is fired on the Cobra II board, but RemovableMedia.Insert is not fired.