Main Site Documentation

Reading SD card from PC via mini USB connection


#1

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?


#2

http://www.microframeworkprojects.com/index.php?title=USB_Client#Mass_Storage


#3

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.


#4

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


#5

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


#6

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


#7

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

GHIElectronics.NETMF.USBClient.USBClientController.GetState().ToString()

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??


#8

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
}
else
{
    // 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?


#9

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.
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/54b37f26-0981-f721-57fe-1cefaf27a246.htm