Windows PC 作为 USB 从设备来模拟拇指驱动器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/682193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows PC as a USB slave to emulate a thumbdrive
提问by Douglas Anderson
I need to create a application that will allow a Windows PC (XP/Vista) to emulate a thumbdrive. That is, when the PC is plugged into either another Windows system, or in this case, a piece of hardware that allows for USB thumbdrives to be plugged in, a folder on the computer looks like a giant thumbdrive. Any thoughts on where a guy would start to investigate this?
我需要创建一个允许 Windows PC (XP/Vista) 模拟拇指驱动器的应用程序。也就是说,当 PC 插入另一个 Windows 系统,或者在这种情况下,允许插入 USB 拇指驱动器的硬件时,计算机上的文件夹看起来像一个巨大的拇指驱动器。关于一个人会从哪里开始调查这个的任何想法?
Update (more specific description):I need to connect my PC to one of the newer multifuction devices that support scanning to a USB thumbdrive that is inserted into the front of the device. These units do not support WIA or TWAIN via the rear USB connector that you'd typically use for connectivity to a PC.
更新(更具体的描述):我需要将我的 PC 连接到支持扫描到插入设备正面的 USB 拇指驱动器的较新的多功能设备之一。这些设备不通过通常用于连接到 PC 的后部 USB 连接器支持 WIA 或 TWAIN。
采纳答案by MSalters
You cannot do this in an application. At the lowest level, the USB ports on your computer are controlled by an Host Controller Interface. This chip will manage up to 127 slave USB devices. You would need to seriously reprogram this chip before it implements the slave side of the USB protocol. Of course, at that point any USB hub in your PC will break down - those 8 USB ports you probably have are usually implemented by 2 smart USB hubs connecting to both USB1 and USB2 host controllers. Next, your USB keyboard and mouse will stop working.
您不能在应用程序中执行此操作。在最低级别,计算机上的 USB 端口由主机控制器接口控制。该芯片将管理多达 127 个从 USB 设备。在它实现 USB 协议的从端之前,您需要认真地重新编程该芯片。当然,那时您 PC 中的任何 USB 集线器都会发生故障——您可能拥有的 8 个 USB 端口通常是由连接到 USB1 和 USB2 主机控制器的 2 个智能 USB 集线器实现的。接下来,您的 USB 键盘和鼠标将停止工作。
回答by thijs
Most USB controllers in regular pc's dont have the possibility to function as an USB slave. So I'd start with investigating what kind of hardware you're going to use.
普通电脑中的大多数 USB 控制器都无法用作 USB 从设备。所以我会先调查你要使用什么样的硬件。
Another way to go: there are USB Link cables to link up 2 pc's over USB, maybe that's usable for you?
另一种方法:有 USB Link 电缆可以通过 USB 连接 2 台电脑,也许这对您有用?
回答by user5369592
Take an MCU with two Slave USBs. Write a simple frimware which makes one USB act as a Special Device Class and wait until PC on this USB provides mandatory data (including Device Class, of course) for the other USB. Write a PC program which connects to the Special Device (your MCU), uploads Mass Storage Device Class and redirects I/O to a dedicated partition. The other USB on the MCU will become an emulated Mass Storage Device.
以带有两个从 USB 的 MCU 为例。编写一个简单的固件,使一个 USB 充当特殊设备类,并等待此 USB 上的 PC 为另一个 USB 提供强制性数据(当然包括设备类)。编写一个连接到特殊设备(您的 MCU)的 PC 程序,上传大容量存储设备类并将 I/O 重定向到专用分区。MCU 上的另一个 USB 将成为模拟大容量存储设备。
Some of those code can be taken from Linux.
其中一些代码可以从 Linux 中获取。