USB 驱动器 LED 闪光灯
我最近阅读了有关 Arduino 的 Hello World 应用程序的内容,我心里想,“我想知道如果我可以用我现在拥有的硬件来做到这一点。”
由于我没有 Arduino,所以我抓起了一个 USB 闪存驱动器,开始在谷歌上搜索有关它的信息。 我在这方面没有找到太多有用的信息,所以我现在在这里问:我是否可以访问 USB 驱动器的硬件(例如 LED)并通过某些编程环境与其交互(我认为 C# 应该可能有办法做到这一点)?
另外,与这个主题相关 - 有谁知道 USB 驱动器使用什么样的命令? 例如,SCSI存储设备有标准化的命令集; ATA 设备具有类似的协议。 诸如简单的读/写命令之类的事情是如何向 USB 存储设备发出的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
虽然 USB 协议相当通用,但外围设备实际上具有特定功能,并且需要主机上的某种设备驱动程序才能正常运行。
虽然 USB 闪存驱动器上有一个微控制器,但大多数 USB 存储设备都遵循通用协议。 这就是为什么您不必为插入 Windows 的每个驱动器安装不同的设备驱动程序。
我很确定大容量存储协议没有“打开 LED”消息:)
虽然实现 USB 驱动器的公司实际上可能有一个特殊的命令来执行此操作(可能用于调试),但我怀疑它是否会被发布。
虽然我不是 Windows 方面的专家,但我相信为了让您直接访问 USB 堆栈,您必须编写自己的设备驱动程序并将其插入内核中。 您能想象常规应用程序是否可以将“格式化所有内容”命令发送到任意 USB 设备吗?
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.
这是一个 DIY USB 控制 LED 灯的链接,还需要做一些工作一点然后插入 USB 记忆棒。
如果您想打开 USB 硬盘驱动器上的灯,您只需将数据写入该驱动器上的文件即可,尽管我认为某些驱动器会让所有驱动器上的灯都亮着。有时,它们中的大多数只是在写入数据时才会亮起。
因此,如果您的 USB 驱动器安装为 F:,您只需创建一个类似 F:\lights.txt 的文件,并向其中写入几 k 数据,然后擦除该文件并重新开始。
闪存驱动器的一个缺点是,使用一段时间后就会磨损,这会磨损它。 您也可以尝试从驱动器读取数据。
如果您想要更精确的控制,您可以使用 USB 数据采集设备,例如 这些它可以让您驱动特定的电力输出,为您想要的任何东西供电,包括灯泡或 LED。 它们最初被科学家用来测量实验室设备的输入,我在大学物理课上使用过类似的东西,尽管当时我们使用 RS-232。
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.
我会这里查看。 他们使用一种称为大容量存储的东西。
I would look here. They use something called Mass Storage.
Linux 中的 USB 驱动器看起来像 SCSI 驱动器,因此您可以执行查询、读取、写入等操作。通常闪存驱动器的控制器制造商可能有特定于供应商的“后门”,而公众对此并不了解。
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.
您可以像控制RS232端口一样控制USB希望这个MSDN链接对您有更多帮助
http://www.microsoft.com/downloads/details.aspx microsoft.com/downloads/details.aspx?FamilyID=075318ca-e4f1-4846-912c-b4ed37a1578b&DisplayLang=en
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