PORTS Forum

Ports and Interfaces => USB => Topic started by: Brynog on March 15, 2018, 11:10:28 pm

Title: Quick question about composite devices
Post by: Brynog on March 15, 2018, 11:10:28 pm
SW group was sitting down trying to come up with a suitable USB design for an upcoming product.

I asked why they didn't simply implement the product with a composite USB device.

What they need:
One product, with one USB link, which has 3 virtual COM ports or HID or whatever, lets assume COM ports.
Different applications on the host would attach to the different ports.

I vaguely remember a composite device so looked up the definition (thanks Jan!):
  + has a single bus address
  + has multiple interfaces, each with a different function
  + each interface can hook to a different driver on the host

Am I correct in believing that each the host would (after enumeration) have 3 hardware device ID?
Each interface on this thing would have the same identical VID and PID, but their interface digits would differ?

And the host would thus allow a separate linkage for each one of these, meaning that separate, independent apps would connect to the different interfaces?

Is all the above reasonable?
If not, then what would be the suggestion on how to do this?

To recap:
You have a product.
It can communicate via USB.
You have up to 3 separate, independent applications running on the host that wish to communicate with it.
Typically, the traffic loads are not very heavy, light actually (no streaming, etc.).

Regards,
Bryce
Title: Re: Quick question about composite devices
Post by: Jan Axelson on March 16, 2018, 09:17:59 am
Yes, in a composite device, the host assigns a driver to each function in the device. In many devices, each interface is a separate function.

From Serial Port Complete, 2nd edition:

***

For most USB classes, creating composite devices is straightforward. Each function has an interface descriptor with bInterfaceClass equal to a class code. In the device descriptor, bDeviceClass = 00h to tell the host computer to look for class codes in the interface descriptors. When a single function uses multiple interfaces, a device can use an interface association descriptor or a class-specific method to identify the interfaces associated with a function.

CDC differs from other classes because it defines a code for bDeviceClass (02h) in the device descriptor. The union functional descriptor defines which interfaces belong to the CDC function, and the host can assume that any additional interface descriptors belong to independent functions.

***

Because of this limitation, offhand I don't know if it's possible to implement more than one CDC-class device in a composite device.

Also, drivers in Windows XP and earlier aren’t always capable of loading the drivers correctly for composite devices that contain CDC functions.

Another option is to use a compound device, which contains an embedded hub and permanently attached devices.

Third parties such as FTDI offer alternate hardware and COM-port drivers that support multiple ports.

HIDs can also implement multiple functions with multiple top-level HID collections.