Suppose there are two or more USB audio devices with identical VIDs and PIDs connected to a windows 10+ PC. These USB audio devices are composite devices...they have a non audio control interface that an application could use libusb to control the device. libusb can distinguish identical devices by the USB descriptor serial number if the device's firmware populates it. (Lets assume it does) Windows audio endpoints have a Endpoint ID string that appears to be a UUID. The USB descriptor serial number does not appear in the Endpoint ID directly (maybe it is hashed?) or in the audio endpoint's friendly name. MacOS and Linux both put the USB descriptor serial number in the audio device's friendly name. Is there a way to associate a USB Audio composite device with its control interface on widows? via USB descriptor serial number or other method?
I have tried printing out the audio endpoint's friendly name as well as all of the PKEY_Device_* listed here.
Related
What I want to achieve is that I plug in a device, for example a mouse, but in general any device that outputs serial data via USB, and then either screen it in terminal, or store it in a file and, if possible, use python to do things with it.
As a concrete example, let's say I want access to the data from a trackpad plugged into a USB port on a macbook. When I run /dev/{tty,cu}.* in terminal, I get a bunch of devices, but none of them is the one I want. When I run ioreg -p IOUSB -l -b | grep -E "#|PortNum|USB Serial Number", I see that the device is plugged in, at a specific address (i.e. #14200000), as well as <class AppleUSBDevice, id 0x100002c38, registered, matched, active, busy 0 (10 ms), retain 14> and "PortNum" = 2.
Yes, the device is plugged in, no it does not show up in /dev/{tty,cu}.*. I don't want to have to write a device driver, I have heard that it is not the easiest thing to do. Are there any solutions for accessing low-level data from devices that don't show up in the /dev/ directory?
Devices showing up as /dev/tty... and /dev/cu... are devices implementing the asynchronous serial data communication protocol derived from RS-232. There used to be dedicated serial ports on computers. Today on a Mac, they are usually connected via USB.
Few USB devices implement the serial protocol. Instead they implement the HID protocol (keyboard, mouse etc.), USB mass storage protocol (external drives of all kind), USB ECM (for network adapters) or a custom protocol. Except for the ones with a custom protocol, macOS provides device drivers for all of them.
USB isn't a simple serial communication. Instead, devices configure several endpoints. Each endpoint uses a separate communication channel. Even USB CDC ACM for RS-232 like communication uses three endpoints. In addition, USB devices can pretend to be several devices at once. This is call composite device.
My understanding is that you want to observe and record USB communication. The main approaches are:
Use Wireshark. It is well known for observing and recording network traffic but it can do the same for USB. Unfortunately, with the ever tighter security on macOS, it isn't so easy to set up and probably doesn't work on Apple Silicon Macs anymore.
Use a dedicated USB protocol analyzer. They are very powerful and start at about USD 300.
When I connect several USB audio devices using the default drivers I usually end up with some kind of friendly device description like "nn- USB Audio codec" or something else, so I have currently no unique property which refers to a specific hardware the e.g. manufacturer ID. I would like to ensure that in case of re-enumerating or replugging the hardware to a different port that my software will automatically identify the changed windows audio device which maps to this hardware. I there a possibility to gather further windows audio device information which can be used to determine the physical hardware ?
Maybe a little clarification is needed:
I have two or more USB audio devices, not necessarily same product or manufacturer. The audio connections have different purposes, so I want to ensure that I my software uses constantly the same physical audio devices for different tasks. This sometimes fails when a re-enumeration occurs ( sometimes without changing the physical USB port connections, it's a windows thing...)
Ideally I would distinguish them by an individual serial number, which usually is only available with storage devices. But what I can retrieve is the "physical" USB topology when I'm looking at the device with a tool such as USBDeview from Nir Sofer. There I have a property like "Hub 3, Port1". If I could map this to a sound device I get from audio audio api like "nn- USB Audio codec" as seen in the sound control panel I would be perfectly happy.
Edit2:
May be this[1] post helps here, but I still have to figure out how to get a USB Port <-> Windwos Sounddevice mapping.
[1]: Can the physical USB port be identified programatically for a device in Windows? "
This is the closest I could fine but it enumerates all usb devices. In my case I am handling WM_DEVICECHANGE event where I handle arriving usb device and want to gather extended information from this device when its plugged in other than the simple USB strings that contains the vid and pid.
I can't find any resource on it, is that possible?
I am using windows 7 and qt 5.5
I would like to experiment with real time audio and was wondering what options are there for accessing audio via a usb port?
I would like to get data from this hardware in an audio stream.
Is this sort of thing best handled by audio frameworks or should the data be fetched using IOKit and passed to e.g. an audio component using a framework?
Also, how is this access effected if e.g. A DAW is accessing the audio from the port? Is dual access handled by the OS?
The specs page for that hardware (Moog Minitaur) doesn't claim that it can transmit audio over USB, only that it has USB MIDI- essentially it has a built in MIDI interface.
If you wanted to get audio from it into your computer you would have to connect it to your computer's line or mic input, or an external soundcard - which may itself connect via USB. One way to handle audio in OSX would be Core Audio. You shouldn't need to write any drivers or anything to deal with the low-level I/O with the soundcard, as the soundcard should come with a driver if there isn't one already in the OS.
I am developing a USB composite device. The composite device have 8 switches and one LED.
When I plugged the Composite device to PC,I could find five devices (each with same device ID but different instance IDs) in the HID section of Device Manager.
Why OS is showing multiple instances instead of One. Can anyone help me understand the concept?
As I recall 'composite device' is just a name in windows to mark that you have multiple devices on your USB line. There isn't a composite device class in the USB protocol. When you connect your USB device to your PC it communicates with all the devices contained in it and reports individually all their address and types. If you are missing some devices in your device manager it could be a driver issue or the device itself is broken. I don't know for sure but maybe there is a limit lower then it could be in theory in the windows hid host driver for the number of supported devices on a single line.