Hello All,
Is there a way to access the SD card of a FEZ as a USB mass storage device on the host PC?
Hello All,
Is there a way to access the SD card of a FEZ as a USB mass storage device on the host PC?
Search the forum. I think it has been discussed before.
premium feature.
Yes, awesome.
Actually this was answered today
Wow look at that. [url]http://www.tinyclr.com/forum/topic?id=8832[/url]
GHI just loves making my life easier.
Been trying for a few days now to get the USB Mass Storage thing to work. The device comes up in windows however it says that there is no disk.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Native;
using GHIElectronics.NETMF.IO;
using System.IO;
using Microsoft.SPOT.IO;
using GHIElectronics.NETMF.USBClient;
namespace FEZ_Domino_Application1 {
public class Program {
public static void Main() {
PersistentStorage sdCard = new PersistentStorage("SD");
sdCard.MountFileSystem();
USBC_MassStorage sdStorage = USBClientController.StandardDevices.StartMassStorage();
sdStorage.AttachLun(0, sdCard, " ", " ");
sdStorage.EnableLun(0);
Thread.Sleep(Timeout.Infinite);
}
}
}
Anyone have any ideas?
Hum… found the solution, and it’s unreal!
sdCard.UnmountFileSystem();
So you have to explicitly unmount the filesystem when you do this thing? Weird.
Actually, perhaps what you need to do is not mount it in the first place.
Which makes sense at some level; the SD driver locks the file system to the SD card, and the USB client can’t lock it; make one or the other responsible for interacting with the volume at any point in time and you should never clash.
But Brett, didn’t he mount the sdCard? Using the line sdCard.MountFileSystem(); ?
If that is not what you mean then how would he have mounted it in the first place?
Thanks for the help, I’m learning a lot!
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Native;
using GHIElectronics.NETMF.IO;
using System.IO;
using Microsoft.SPOT.IO;
using GHIElectronics.NETMF.USBClient;
namespace FEZ_Domino_Application1 {
public class Program {
public static void Main() {
PersistentStorage sdCard = new PersistentStorage("SD");
sdCard.UnmountFileSystem();
USBC_MassStorage sdStorage = USBClientController.StandardDevices.StartMassStorage();
sdStorage.AttachLun(0, sdCard, " ", " ");
sdStorage.EnableLun(0);
Thread.Sleep(Timeout.Infinite);
}
}
}
When you create the PersistentStorage object. Apparently it automounts the file system.
@ kurtnelle - Do you know how I would go about Unmounting the SD card? I want to be able to unmount the MSD when I push the LDR button. I already have the code involved to act when the button is pressed, but I just don’t no how to disable the card as mass strorage
Thanks
@ jkane121- Call UnmountFileSystem()
@ kurtnelle - Ok, I just got your code to complile, so I will show you how I am trying to implement the unmount when the button is pressed…
public class Program
{
public static void Main()
{
InterruptPort IntButton = new InterruptPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeLow);
IntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);
//"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
PersistentStorage sdCard = new PersistentStorage("SD");
sdCard.UnmountFileSystem();
USBC_MassStorage sdStorage = USBClientController.StandardDevices.StartMassStorage();
sdStorage.AttachLun(0, sdCard, " ", " ");
sdStorage.EnableLun(0);
Thread.Sleep(Timeout.Infinite);
}
static void IntButton_OnInterrupt(uint port, uint state, DateTime time)
{
PersistentStorage sdCard = new PersistentStorage("SD");
sdCard.UnmountFileSystem();
}
}
What am I missing? Thanks for the help by the way!
@ jkane121,
Are you trying to mount the file system when the button is pressed so that the computer is able to see the storage device?
If so then
public class Program {
static PersistentStorage sdCard;
static USBC_MassStorage sdStorage;
public static void Main() {
InterruptPort IntButton = new InterruptPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeLow);
IntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);
//"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Thread.Sleep(Timeout.Infinite);
}
static void IntButton_OnInterrupt(uint port, uint state, DateTime time) {
sdCard = new PersistentStorage("SD");
sdCard.UnmountFileSystem();
sdStorage = USBClientController.StandardDevices.StartMassStorage();
sdStorage.AttachLun(0, sdCard, " ", " ");
sdStorage.EnableLun(0);
}
}
Edit: What Fez Are you using?
@ kurtnelle - Actually I am trying to do the exact oppostie. So that when the button is pressed the file system is unmounted and the computer cannot recognize it
And it is a Panda II
@ jkane121
public class Program {
static PersistentStorage sdCard;
static USBC_MassStorage sdStorage;
public static void Main() {
InterruptPort IntButton = new InterruptPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeLow);
IntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);
//"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
sdCard = new PersistentStorage("SD");
sdCard.UnmountFileSystem();
sdStorage = USBClientController.StandardDevices.StartMassStorage();
sdStorage.AttachLun(0, sdCard, " ", " ");
sdStorage.EnableLun(0);
Thread.Sleep(Timeout.Infinite);
}
static void IntButton_OnInterrupt(uint port, uint state, DateTime time) {
sdStorage.DisableLun(0);
}
}
Edit: that would be DisableLun(0);
@ kurtnelle - Oh I see! Awesome! Thanks a lot for the help!
@ jkane121, Much Welcome.