This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
从 USB 的角度来看,这是没有意义的。 USB 是基于主机的协议:除非主机首先请求,否则设备永远不会发送数据。请记住,“主机”和“设备”在协议本身中具有特定含义;您可以将“主机”视为主设备,将“设备”视为从设备。这些角色被纳入 USB 控制器中。无法说服任何给定 PC 或外围设备中的标准 USB 控制器交换角色。 PC 上有一些附加卡是 USB 设备控制器(使您的 PC 充当设备),但我不会用“便宜”这个词来形容它们。
您真正想做的是创建一个 USB 设备到设备的桥接器。所以,好吧,你需要有两个 USB(2.0) 设备控制器(也许不是那么贵,一些微型计算机已经有了便携式控制器)。然后你必须让他们互相传递一些有意义的东西。这确实很难,因为正如我上面提到的,主机必须告诉设备发送数据,并且可以随时向设备发送数据。假设游戏控制器显示为 HID 设备(假设控制台不侦听某些奇怪的自定义描述符,并使用某些奇怪的自定义协议),则将使用中断管道来传输数据。该管道保证以某个最低速率进行轮询。因此,控制台以某种速率请求数据(该速率不是固定的),并且主机作为游戏手柄以某种速率发送数据。两者不可能同步,因此您在尝试创建的小工具上需要某种大小合适的缓冲区,这会增加更多的资金和复杂性。
USB 的速度也相当快。在高速 (USB2.0) 下,帧长为 125 微秒。这意味着您必须以 8KHz 左右的频率完成请求,与微控制器的时钟速度相比,这似乎很慢,但请记住,您必须同时执行其他所有操作。我不确定是否有一款爱好者级微控制器能够满足您所需的一切,尤其是您不需要构建自己的 USB 堆栈的微控制器。
This is non-sensical from a USB perspective. USB is a host-based protocol: a device will never send data unless a host requests it first. Keep in mind here, 'host' and 'device' have specific meanings here within the protocol itself; you can think of a 'host' as the master and the 'device' as the slave. These roles are baked into a USB controller. There is no way to convince a standard USB controller in any given PC or peripheral to swap roles. There are add-in cards for PCs that are USB device controllers (making your PC act as a device), but 'cheap' is not a word I would use to describe them.
What you really are trying to do is create something that is a USB device to device bridge. So, alright, you need to have two USB(2.0) device controllers (maybe not that expensive, some micros already have to on-the-go controllers). Then you have to get them to pass something meaningful to each other. That's really hard because, as I mentioned above, hosts must tell a device to send data, and can send data to a device whenever it wants. Assuming a game controller shows up as a HID device (assuming the console doesn't listen for some weird, custom descriptor, and use some weird, custom protocol), interrupt pipes will be used to transfer data. This pipe is guaranteed to be polled at some minimum rate. So you have the console requesting data at some rate, which is not fixed, and a host-as-gamepad sending data at some rate. It's going to impossible for the two to sync up, so you'll need some kind of decent sized buffer on the gadget you're trying to create, which adds more $$ and more complexity.
USB is also pretty fast. In high-speed (USB2.0), frames are 125 microseconds long. That means you have to be completing requests at around 8KHz, which seems slow compared to the clock speed of a microcontoller, but keep in mind you have to be doing everything else at once. I'm not sure if there's a hobbyist-level microcontroller that's going to have everything you need, especially one for which you don't need to roll your own USB stack.
试试这个芯片 -> FTDI 232 它们是协议芯片,它将数据转换为 i2c、spi、串行,无论你想要什么。不错,简单又便宜:)。 FTDI 公司,有更好的(vinculum),有 otg 和你需要的一切,但我会从 FTDI232 开始。您只需要使用您最喜欢的 uC 来完成您想要的工作。 ...另一方面,你必须做一个小板,也许需要一些焊接,:)。祝你好运!
Try this chip -> FTDI 232 they are protocols chips, it will translate the data to i2c, spi, serial, whatever u want. nice, easy and cheap :) . FTDI firm, have even better ones (vinculum), with otg and everything u need but I would start with the FTDI232. U just need to use your favorite uC to do the work u want. ... on the other hand, u have to do a little board, maybe some soldering, :). good luck!
您将需要 $$$$ 设备和 $$$$$ 开发工作来实现您想象的目标。您最好告诉我们您想要模拟什么,并查看此处如果有人已经为你完成了。如果没有,则将 LUFA 库与一些更大的 USB AVR 一起使用,该 AVR 可以充当 USB 主机,并通过其他协议(I2C/SPI/UART)连接其中两个(一个作为 USB 客户机,另一个作为 USB 主机)。
You will need $$$$ in equipment and $$$$$ in development work to achieve things the way you imagine. You should better tell us what do you want to emulate, and take a look here if someone has already done it for you. If not then use LUFA library with some bigger USB AVR that can behave as USB host and connect two of them (one as USB guest and the other as USB host) via some other protocol (I2C/SPI/UART).
与此同时,这个问题有一个很好的解决方案。使用 FaceDancer 库 以及这款优秀软件支持的板之一(即 < a href="https://greatscottgadgets.com/greatfet/" rel="nofollow noreferrer">GreatFET One)您将得到您想要的:
GreatFET One 有两个 USB 连接器:第一个用于模拟任何类型的 USB 设备,而第二个用于转发通过第一个连接器接收/发送的所有请求/响应。
当然这个工具要求你知道你想要模拟的设备的USB协议。尽管有一些代码示例,但您仍然必须在自定义它们后立即知道自己在做什么。
In the meantime there is a great solution for this Problem. Using the FaceDancer Library together with one of the boards supported by this great piece of software (i.E. GreatFET One) you get exactly what you want:
The GreatFET One has two USB connectors: the first one is used to simulate ANY kind of USB Device, while the second one is used to forward all requests/responses received/send via the first connector.
Of course this tool requires that you know the USB protocol of the device you want to simulate. Although there are some code samples you still have to know what you are doing as soon as you customize them.