Reading SD card from PC via mini USB connection

It is possible to access the contents of an SD card inserted into a Fez Domino/Panda/Mini directly from a PC connected to the board via the mini USB port.

I’m trying to avoid having to take the SD card out everytime I want to import data from it?


Thats cool, so now I only need to determine how to dynamically switch the device into MSC mode to transfer files and then back to PersistentStorage mode for more logging.

Is that correct? How could I do that?

It’s a data logger and thats its default mode, I would need to trap the connection of the PC as an event and change the mode to MSC so the PC can read the data, then on PC disconnection, switch back to regular traking mode.

Any pointers please.

Depending on board You use, there might be buttons on it (LDR on domino, panda). You can change interface on button click.

There must ba away to determine if the mini usb is connected, so that can act as a switch between modes?

You can poll USBClientController.GetState(). If it is State.Running then it is connected to the PC.

I’ve tried polling the USBClientController.GetState() and the following line always returns 255


Which is Stopped I think, this happens regardless of me plugging/unplugging the mini USB cable which is connected to my PC.

I have put a ‘jumper’ on the mode, and would expect to see the current state change as I plug/unplug it.

Any ideas??

I have started the mass storage device with the following

// Start Mass Storage
MS = USBClientController.StandardDevices.StartMassStorage();

I then have a threading timer to monitor the USB client state

// check if connected to PC
if (USBClientController.GetState() != USBClientController.State.Running)
    // show its connected
    // show its not connected

This works when I connect the client USB cable, but not when I disconnect it??

Polling the USB Client State when I dont start the Mass Storage device just return 255 all the time.

How do I deternime the disconnect event?

That’s fine, you can start the mass storage device… You are still NOT connected to the SD card through PC.
To enable PC access, you have to EnableLun(0)…etc

Please read this and see the examples. There is even an example for switching back and forth between PC and NETMF access.