简体   繁体   English

Raspberry Pi使用USB一起交谈

[英]Raspberry Pi talking together using USB

I want to develop a PyUSB program which listens to data from USB. 我想开发一个PyUSB程序,该程序可以侦听USB的数据。 However, I wish to expand the application to talk another Raspberry Pi through USB port. 但是,我希望扩展该应用程序以通过USB端口与另一个Raspberry Pi通讯。 I wonder is it possible? 我不知道有可能吗?

USB is a master/slave protocol where a USB device is connected to a USB host . USB是主/从协议,其中USB 设备连接到USB 主机 You cannot directly connect a USB host to a USB host. 您不能将USB主机直接连接到USB主机。 The RPi is a USB host. RPi是USB主机。

What is possible however is to use two USB devices that connect via some other interface such as UART and each connect to a different host. 但是,可以使用两个通过其他接口(例如UART)连接的USB设备,每个USB设备连接到不同的主机。 For example you could use two FTDI USB/Serial bridge devices back-to-back: 例如,您可以背对背使用两个FTDI USB /串行桥接设备:

                    __________      ________
                    |     Tx |______|Rx     |
USB Host A ---------|     Rx |______|Tx     |---------USB Host B
                    |________|      |_______|
                      FT323R         FT323R

As such it is largely a hardware problem not a software problem. 因此,这在很大程度上是硬件问题,而不是软件问题。 The data rate will be limited by the capability of the USB/Serial device - 3MBaud for the FT232. 数据速率将受USB /串行设备的能力限制-FT232为3MBaud。 Note that a real implementation you would also connect the RTS/CTS flow control pins, but there is a limit to my ASCII diagramming patience! 请注意,在实际的实现中,您还可以连接RTS / CTS流控制引脚,但是我的ASCII绘图耐心性受到限制!

A probably better solution is to use a commercially available USB bridge cable ; 可能更好的解决方案是使用市售的USB桥接电缆 these use the same principle as serial bridge solution described above, but instead of emulating a COM/TTY port, emulate an network interface and can run at full USB speed. 它们使用与上述串行桥解决方案相同的原理,但不是模拟COM / TTY端口,而是模拟网络接口并可以全USB速度运行。 You could of course implement such a cable but I doubt it would be cost effective even compared with solution I suggested above. 您当然可以实现这种电缆,但是我怀疑即使与我上面建议的解决方案相比,它是否也具有成本效益。 I do not know whether suitable drivers for USB network adapters exist for RPi however. 我不知道RPi是否存在适用于USB网络适配器的驱动程序。

Given that RPi has Ethernet, that would be a far simpler method of board to board communication and is not limited to point-to-point, but can access an entire network, and there will be no USB driver issues to tackle. 鉴于RPi具有以太网,这将是板对板通信的一种简单得多的方法,并且不仅限于点对点,而且可以访问整个网络,并且不会解决USB驱动程序问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM