Download "user manual"
Transcript
Beginners guide to C# and .NET Micro Framework
USB Client
{
cdc.Write(bytes, 0, bytes.Length);
}
Thread.Sleep(1000);
}
}
}
28.6. Mass Storage
One of the great GHI unique features of USB client is supporting Mass Storage Class (MSC).
This feature allows access to the connected media right from USB. Let me explain this
through some example. A data logger application needs to save data to an SD card or USB
memory. When the user is done collecting data, they can plug the USB data logger to the PC
and now the PC can detect the device as a mass storage device. The user can then transfer
the files using standard operating system. Think of the device as a memory card reader. We
can even enhance our logger where the USB client interface can be CDC to configure the
device and later dynamically switch to MSC to transfer files.
Once very common question on GHI support is “Why can't I access the media while the
media is also accessed externally (from windows)?”. I will try to explain this better. A media is
accessed though a class called PersistentStorage. The PersistentStorage object can then be
accessed by the internal file system or externally through the USB MSC. Okay, but why not
both? It can't be both because files systems cash a lot of info about the media to speed up file
access time. Accessing the media simultaneously will definitely cause corruption to the media
and therefor, simultaneous access is not allowed. Note that you can easily switch back and
forth between internal file system and USB MSC.
This example code assumes an SD card is always plugged in. It enables MSC showing the
device (I am using FEZ Domino) as a card reader.
using
using
using
using
using
System;
System.IO;
System.Threading;
Microsoft.SPOT;
Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.USBClient;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.Hardware;
namespace USBClient_Example
{
Copyright © 2010 GHI Electronics, LLC
Page 143/170