I have a spider hooked up to usbclientDP, RS232, DIsplay_T35, and USBHost modules. Using VC2010, I have connected the USBClientDP and Display_T35 to a Spider board. The USBHost and RS232 are not connected (in the IDE), not even on the IDE space (so I manually added references to the Host and other GHI.Premium dll’s to make the code work).
I let the IDE and Gadgeteer libraries initialize the USB Client and Display. (I’m not using the display for anything in this project, but it does show me when the board crashes or has an abort).
My code is trying to let a Kingston G2 USB drive show up through the USBClient to a windows (7, 64bit) PC.
I can get the device to show up, but it always appears un-formatted.
Is there a way to pass the Kingston’s file system through the USB client to the PC? Or do I have to reformat the Kingston when I insert it?
Here’s the code.
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using GHI.Premium.USBHost;
using GHI.Premium.IO;
using GHI.Premium.System;
using GHI.Premium.USBClient;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
static PersistentStorage ps = null;
static USBC_MassStorage ms = null;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
// Subscribe to USB events
USBHostController.DeviceConnectedEvent += new USBH_DeviceConnectionEventHandler(DeviceConnectedEvent);
USBHostController.DeviceDisconnectedEvent += new USBH_DeviceConnectionEventHandler(DeviceDisconnectedEvent);
Debug.Print("USB Host subscribed to events");
ms = USBClientController.StandardDevices.StartMassStorage();
Debug.Print("USB ms started");
}
void DeviceDisconnectedEvent(USBH_Device device)
{
Debug.Print("Device Disconnect Event Detected");
Debug.Print("ID: " + device.ID + ", Interface: " + device.INTERFACE_INDEX + ", Type: " + device.TYPE);
ms.DisableLun(0);
}
void DeviceConnectedEvent(USBH_Device device)
{
Debug.Print("Device Connect Event Detected");
Debug.Print("ID: " + device.ID + ", Interface: " + device.INTERFACE_INDEX + ", Type: " + device.TYPE);
if (device.TYPE == USBH_DeviceType.MassStorage)
{
Debug.Print("USB Mass Storage detected...");
ps = new PersistentStorage(device);
ms.AttachLun(0, ps, " ", " ");
ms.EnableLun(0);
}
}
}
}