views:

999

answers:

5

I was recently reading about the Arduino's Hello World application, and I thought to myself, "I wonder if I can do that with hardware that I have right now."

Since I don't have an Arduino, I grabbed a usb flash drive that I had laying around and started googling around for information about it. I didn't find much helpful information in this area, so I'm now asking here: is it possible for me to access a USB drive's hardware (e.g. the LED) and interact with it via some programming environment (I was thinking C# should probably have some way to do this)?

Also, related to this subject - does anyone know what kind of commands USB drives use? For example, SCSI storage devices have a standardized command set; ATA devices have a similar protocol. How are things like simple read/write commands issued to a USB storage device?

+1  A: 

I would look here. They use something called Mass Storage.

Daniel A. White
+5  A: 

While the USB protocol is fairly generic, the peripheral devices are really function specific and require some kind of device driver on the host to function properly.

While a USB Flash Drive has a micro-controller on it, most USB storage devices follow a common protocol. That is why you don't have to install a different device driver for every drive you plug into windows.

I'm pretty sure that the mass storage protocol does not have a "Turn LED on" message :) And while the company that implemented the USB drive might actually have a special command to do that (maybe for debugging), I would doubt it would be published.

While I'm no guru on Windows, I believe that in order for you to access the USB stack directly, you would have to write your own device driver and plug load it in the kernel. Can you imagine if a regular application could send the "format everything" command to an arbitrary USB device.

Benoit
+1  A: 

USB drives in Linux look like SCSI drives, so you can do INQUIRY, READ, WRITE, etc. Usually the flash drive's controller manufacturer may have a vendor-specific "backdoor," which is unknown to the general public.

switchmode
Care to elaborate on this?
Blue
Most USB drive controller vendors have their own unique "vendor-specific" way of accessing the bare-metal the chip, so I can't really speak for all of them since the protocols are either confidential or not public. Let's just say that SCSI READ/WRITE BUFFER have vendor-specific modes for a reason.
switchmode
+1  A: 

Here is a link to a DIY USB controlled LED lamp, it's a little more work then plugging in a USB stick.

If you want to turn the light on a USB hard drive on, you just have to write data to a file on that drive, although I think some drives will leave the light on all the time, most of them just light up while data is being written.

So if you're USB drive is mounted as F:, you can just create a file like F:\lights.txt, and write a few k of data to too it, then erase the file and start again.

One drawback is that Flash drives wear out after a while, and this will wear it out. You could also just try reading data from the drive as well.

If you want more precise control, you can get USB data aquisition devices like these that will let you drive a specific electrical output, to power whatever you want, including lightbulbs or LEDs. They are originally used by scientists to measure inputs from lab equipment, I used stuff like that in my college physics class, although at the time we used RS-232.

Chad Okere
I understand that writing data to a drive will make the LED flash, but the hardware is out of my control. I think you took my question a little too literally. The LED question is more of an example than a goal.
Blue
A: 

You can control USB as like RS232 port hope this MSDN link will help you more http://www.microsoft.com/downloads/details.aspx?FamilyID=075318ca-e4f1-4846-912c-b4ed37a1578b&DisplayLang=en