I keep getting the System.InvalidOperationException error when trying to subscribe to USBHostController.DeviceConnectedEvent
I am using NETMF 4.1 and also have the 4.1.6.0 firmware loaded.
I’m using the following code:
using System.IO;
using System.Text;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.USBHost;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;
namespace USB_Host_Test
{
public class Program
{
static SD_Read_Write SD;
static string SD_Filename = @ "\SD\USB_HOST_TEST_LOG.txt";
public static void Main()
{
SD = new SD_Read_Write();
SD.Write(SD_Filename, "Starting...");
// Subscribe to USB events
try
{
SD.Write(SD_Filename, "Subscribing to DeviceConnectedEvent");
USBHostController.DeviceConnectedEvent += new USBH_DeviceConnectionEventHandler(USBHostController_DeviceConnectedEvent);
}
catch (System.Exception ex)
{
SD.Write(SD_Filename, ex.Message);
}
try
{
SD.Write(SD_Filename, "Subscribing to DeviceDisconnectedEvent");
USBHostController.DeviceDisconnectedEvent += new USBH_DeviceConnectionEventHandler(USBHostController_DeviceDisconnectedEvent);
}
catch (System.Exception ex)
{
SD.Write(SD_Filename, ex.Message);
}
SD.Write(SD_Filename, "events subscribed");
// Sleep forever
Thread.Sleep(Timeout.Infinite);
}
I have made a USB host cable and with or without the cable I get the error. I don’t have a serial port for my Panda yet that’s why I log to the SD card.
Currently this is a bit of a show stopper for me