The built-in support from the .NET Micro Framework
and GHI greatly simplifies the code you need to provide.
Detecting and initializing a drive requires jumping through
a few programming hoops, but the same boilerplate code
can do the job for any application. Example code will get
you going quickly.
The .NET Micro Framework’s RemovableMedia class
provides events for detecting insertion and removal of SD
cards and similar storage media. The class’s Insert and
Eject events can define handlers that execute on detecting
a newly attached or removed RemovableMedia device:
GHI’s SystemManager and PersistentStorage classes
enable using these same events to detect attachment and
removal of Flash drives. The SystemManager class has a
Start method that registers a routine that executes when a
Flash drive is attached or removed:
SystemEventType type, SystemEventArgs args)
if (type ==
args.device.deviceType == DeviceType.Drive)
// A drive has been attached.
// A drive has been removed.
PersistentStorage storageList =
myPersistentStorage in storageList)
if (myPersistentStorage.ID ==
The parameters received by the SystemEvent routine
identify the event type and provide a device ID.
On device attachment, the event routine can use the
device ID to create a PersistentStorage object. The
MountFileSystem method enables accessing the drive’s
NEW! Orangutan SVP 1284 Ro
” 2. 20
with coupon code
April 2010 49
earn more at www.pololu.com/svp or call 1-877-7-POLOLU