ANN: New USB Drive Library

Phil Davis revdev at pdslabs.net
Mon Jun 25 17:54:41 EDT 2007


Hi Len,

Len Morgan wrote:
> I can't seem to get any of the drive letters to show up (I've tried 
> three different "drives").  Is this normal?  

It's normal on some computers and not on others. I see it doesn't appear in 
libUsbdrive's output on XP, but does on Mac OS X. That's why I marked it an 
Optional property, not always available.

When I figure out where to find it on XP, I'll add it to the library.


> If I can't access a USB 
> drive as a drive letter (or useable name on Windows), what is the 
> purpose of the library?

Here's the Help info from libUsbDrive:

---help start---
libUsbDrive is a Revolution library that enables your Revolution applications to 
detect USB storage device identity and status information. libUsbDrive works on 
Windows 2000/XP and on Macintosh OS X.



PUBLIC DATA

gPdsUsbDriveProfiles
A global numeric-keyed (1..n) array where each element contains the profile of 
one USB drive (data storage device).
- On Windows, a profile is created for every USB drive that is physically 
plugged in, whether it is currently mounted or unmounted.
- On Mac, a profile is created only for USB drives that are currently mounted.

Profile Format
Each drive profile is a return-delimited set of name-value pairs that represent 
drive attributes. Each name is separated from its value by an equal sign ("=").
Certain drive attributes are always included in the profile; others are included 
when available. Attribute names are modeled after U3 environment global names 
where possible. Here is the complete list of attributes:  (O=optional; 
S=standard, always included)
   DeviceVendor       O  Manufacturer name.
   DeviceVendorID     S  Hexidecimal manufacturer ID.
   DeviceProduct      S  Product name or type.
   DeviceProductID    S  Hexidecimal product ID.
   DeviceSerial       S  Drive hardware serial number.
   DevicePath         O  Full pathname (mount point) of the drive.
   IsDeviceAvailable  S  Mounted state ofthe drive (boolean).



PUBLIC HANDLERS

pdsUsbDriveKeys()
A function that returns a sorted list of 'gPdsUsbDriveProfiles' keys.

pdsRefreshUsbDriveProfiles
A command that retrieves fresh profile information for all USB drives known to 
the system.



HOW TO USE THIS LIBRARY

1) Include the libUsbDrive stack in your system.

2) Add code in your script to 'start using' the libUsbDrive stack at the 
appropriate time.

3) Declare the 'gPdsUsbDriveProfiles' global in the script where you plan to 
interact with USB drive profiles.

---help end---


Does that make it any more clear?

To get the drive letters, try 'the volumes' in Rev.


> 
> Also, is it possible to "turn off" a device?  I ask because I'm trying 
> to write an app that will download images from a digital camera but I 
> want to leave the camera plugged into the computer.  As soon as the 
> cable is plugged in, the camera shuts off.  If I could "turn off" the 
> USB connection, the camera would think that the cable had been 
> disconnected and would turn back on.  The use of this would require too 
> much plugging and unplugging of the cable to make it a long term solution.

If I understand correctly, you're talking about the difference between 
unmounting the drive and unplugging it. The ability to unmount a drive would be 
nice. When I learn how to unmount a device from the command line on Win & Mac, 
I'll add it to this library.

(If anyone already knows, feel free to jump in!)

Thanks Len -
Phil


> 
> Thanks!
> 
> Len Morgan



More information about the use-livecode mailing list