是否可以将单个物理 USB 设备显示为两个独立的设备类?
我正处于需要 USB 连接的设备开发的早期阶段。该设备至少必须显示为传统串行端口,但如果它可以同时显示为大容量存储设备,则会很有用。
这是否可能,或者设备是否需要在大容量存储和通信设备之间切换,以便一次只处理一件事?
**[编辑]**我提出问题的速度可能有点快; 这表明,使用 USB Composite 确实可以做到这一点设备框架。。如果有人有这方面的经验,并且可能有一些提示或指示,使用了什么平台,以及他们可能使用过的任何第三方工具或堆栈,我仍然会感兴趣。
I am in the early stages of development of a device requiring USB connectivity. As a minimum the device must appear as a legacy serial port, but it would be useful if it could simultaneously appear as a mass-storage device.
Is this possible, or will the device need to switch between mass-storage and communications-device so that it is only one thing at a time?
**[edit]**I was probably a bit quick in firing off a question; this suggests that it can indeed be done, using the USB Composite Device Framework. I'd still be interested if anyone has any experience of this and might have some tips or pointers, what platform was used, and what if any third-party tools or stacks they may have used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您可以使同一设备显示为两个(或多个)逻辑设备。
几年前我为一个项目做了这个,但已经有一段时间了,我已经忘记了细节。我想我的大容量存储、视频捕捉和串行端口都同时运行。
是的,复合设备听起来很熟悉。我从事的项目没有使用任何第三方操作系统或 USB 库;这都是 Freescale i.MX21 CPU 的“裸机”代码。 Jan Axelson 的 USB Complete 非常宝贵,Packet-Master USB 分析器。
Yes, you can make the same device appear as two (or more) logical devices.
I did this for a project a couple of years ago, but it's been a while now and I've forgotten the details. I think I had mass storage, video capture, and serial port all running simultaneously.
Yes, Composite device sounds familiar. The project I worked on didn't use any third party OS or USB libraries; it was all "bare metal" code for the Freescale i.MX21 CPU. Jan Axelson's USB Complete was invaluable, as was the Packet-Master USB analyser.
是的,这是可能的。例如,我有一个用于 UMTS(3G 移动)连接的华为 E220 USB 棒,它有四个接口:两个是供应商特定的(内核驱动程序最终将它们映射为
/dev/ttyUSB{0,1}
),另外两个是特定于供应商的(内核驱动程序最终将它们映射为/dev/ttyUSB{0,1}
)是大容量存储。我知道您可以同时使用两个
/dev/ttyUSB{0,1}
。Yes, this is possible. E.g. I have a Huawei E220 USB stick for UMTS (3G mobile) connectivity which has four interfaces: Two are vendor specific (kernel driver eventually maps them as
/dev/ttyUSB{0,1}
) and two are mass storage.I know you can use the two
/dev/ttyUSB{0,1}
simultanously.您不必在这里做任何复杂的事情,只需正确设置描述符即可。
只需为您想要的每个“功能”提供一个接口描述符(显然您将需要与该“功能”相关的所有其他描述符),操作系统将整理所有复合设备内容。
我建议,如果您打算进行任何稍微严肃的 USB 开发,您可以使用 USB 分析器 - 您不仅可以分析自己的东西,还可以插入其他人的工具包,看看他们是如何完成描述符的。 。
You don't have to do anything complicated here, it's just a matter of getting the descriptors right.
Just provide an interface descriptor for each 'function' you want (obviously you'll need all the other descriptors which go with that 'function'), and the OS will sort out all the composite device stuff.
I would suggest if you're going to do any even slightly serious USB development that you get a USB analyser - not only can you analyse your own stuff, but you can also plug in other people's kit and see how they did their descriptors...