Re: [Dorset] Things discussed and results:
On Saturday, 10 December 2016 11:45:03 GMT William R Sowerbutts wrote: > You can write a udev rule to name the device according to the USB port it is > plugged into (either on the host or a downstream hub). This should allows > you to give them persistent names. > > Here's an example for serial ports, I assume the same can be done for audio > devices: > > http://askubuntu.com/questions/49910/how-to-distinguish-between-identical-us > b-to-serial-adapters Thanks. From this and the link provided by Ralph, it looks like I should be able to do what I want, based on the physical USB socket that the device is plugged in to. This is ideal, because if the device ever fails, we don't want to have to reprogram the code, just because someone substitutes the spare. We just have to ensure that the User Manual makes it clear that it is important that the correct socket is used. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Distinguishing USB Devices.
Hi Terry, > 0x0d8c:0x013c (C-Media Electronics, Inc : CM108 Audio Controller)) Didn't find anything on setting the serial number. But I did find the output of `lsusb -v' for it and it seems to have a `Microphone' interface descriptor? Don't know if you can hook up something to one of the microphones so it's got a `hum' that's different to the other idle one. I did see someone with multiple cameras have external circuitry to power them up in a fixed order. USB then adds each as they appear and the software takes note of their varying allocated device name. > The problem that I see is that the two devices may not just be flipped > around, they may actually have been allocated to a totally different > port, so it could be quite a laborious process I'm using port to mean the port number on a numbered USB bus. Linux makes the device accessible under some name, e.g. /dev/ttyUSB0 for a USB/serial-port adapter. I don't think the port number and bus number change unless you add more buses or move the plug to a different socket. The /dev/ttyUSB0 can change to be ...1, ...2, etc., which is the problem as software uses that name to access it. If your Pi has udev running then it can be given rules to fix the name for a device according to a pattern that describes the device. The pattern can't use Serial as that's always zero, but it should be able to use the bus and port number. > It'll need extensive testing to be sure of the solution though. If you go the USB bus and port number route and it works with the obvious tests of breaking when cables are moved then I think that would be good enough to field test given what I've read this morning. :-) Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Things discussed and results:
You can write a udev rule to name the device according to the USB port it is plugged into (either on the host or a downstream hub). This should allows you to give them persistent names. Here's an example for serial ports, I assume the same can be done for audio devices: http://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters W On Sat, Dec 10, 2016 at 10:14:35AM +, Terry Coles wrote: >On Saturday, 10 December 2016 00:44:51 GMT Ralph Corderoy wrote: >> Terry has two USB audio adapters plugged in and wants to always play one >> track so it comes out of the "left" one and the other track to emit from >> the "right" regardless of the order they were enumerated by Linux. >> They're the same product from the same vendor. Terry, there is a >> "serial number" field in the USB descriptor, but you may find it's not >> set to a unique value by the manufacturer. `sudo lsusb -v' will show it >> as `iSerial'. > >My cunning plan thereby comes crashing around my ears. I only have one of the >devices here at the moment, but it advertises iSerial as '0', so I've no doubt >the others will also be called that. > >The system will be run headless except when the code is being developed or >debugged, so how can I find a foolproof way to identify which channel is >which? >The alternatives to using these devices work out at £30 - £40 per channel >because they are aimed at the hi-fi market. These devices are about £3 each. > >I've already considered using the hdmi audio channel and putting one track on >the left channel and one on the right, but that would require that the >Wimborne Model Town Staff have a means to create the specially crafted mp3 >files. I'd rather not go down that path. > >Any other ideas? > >-- > > > > Terry Coles > >-- >Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 >Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ >New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING >Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR _ William R Sowerbutts w...@sowerbutts.com "Carpe post meridiem" http://sowerbutts.com main(){char*s=">#=0> ^#X@#@^7=",c=0,m;for(;c<15;c++)for (m=-1;m<7;putchar(m++/6%3/2?10:s[c]-31&1<
Re: [Dorset] Distinguishing USB Devices. (Was: Things discussed and results:)
On Saturday, 10 December 2016 10:53:46 GMT Ralph Corderoy wrote: > What's the vendor:product ID shown by lsusb? Some things offer a means > to set the serial number. It's unlikely in this case, but worth a > Google. I only found examples of the output of lsusb for these devices (Vendor:Product 0x0d8c:0x013c (C-Media Electronics, Inc : CM108 Audio Controller)). These examples all said that iSerial was 0, so it looks like that's universal. > And I think you said in a sealed box, so no switch whereby an operator > can flip them around if they're wrong after a boot? Or request a test > play, etc. And they're off the network. We do have switches to control the playback modes and other features of the system, so we could use something like that (I had wondered myself). The problem that I see is that the two devices may not just be flipped around, they may actually have been allocated to a totally different port, so it could be quite a laborious process > I think the port may not change if you don't physically move the USB > connector? But it can be assigned a varying device name and that's the > problem. Investigate the tree of USB devices, `lsusb -t'. `find > /dev/bus/usb | sort' will show the ports you have available to use, I > think. Understanding this particular answer may help: > http://www.linux-usb.org/FAQ.html#i6 Ah, here's someone showing how to > walk the path to find the port numbers. http://superuser.com/a/974522 The idea of using the physical connection from the last link looks promising. > Pick randomly, play a test on reset, and have them power cycle if it's > wrong. It has to be random since Linux's allocation may be consistent > for a good few goes in a row. Sourcing randomness might be a problem. > > Put the output of `sudo lsusb -v' into a file. Copy it. And cut each > down so one of the adapters is in each. Then compare, e.g. diff(1), to > see if anything else might consistently be different. I won't be able to get hold of the other two devices (one's a spare) until Monday, but I'll certainly have a look then. It'll need extensive testing to be sure of the solution though. Thanks for the ideas. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
[Dorset] Distinguishing USB Devices. (Was: Things discussed and results:)
Hi Terry, > My cunning plan thereby comes crashing around my ears. Yeah, hardware, only ever causes problems. :-) > I only have one of the devices here at the moment, but it advertises > iSerial as '0', so I've no doubt the others will also be called that. What's the vendor:product ID shown by lsusb? Some things offer a means to set the serial number. It's unlikely in this case, but worth a Google. > The system will be run headless except when the code is being > developed or debugged And I think you said in a sealed box, so no switch whereby an operator can flip them around if they're wrong after a boot? Or request a test play, etc. And they're off the network. > so how can I find a foolproof way to identify which channel is which? I think the port may not change if you don't physically move the USB connector? But it can be assigned a varying device name and that's the problem. Investigate the tree of USB devices, `lsusb -t'. `find /dev/bus/usb | sort' will show the ports you have available to use, I think. Understanding this particular answer may help: http://www.linux-usb.org/FAQ.html#i6 Ah, here's someone showing how to walk the path to find the port numbers. http://superuser.com/a/974522 Pick randomly, play a test on reset, and have them power cycle if it's wrong. It has to be random since Linux's allocation may be consistent for a good few goes in a row. Sourcing randomness might be a problem. Put the output of `sudo lsusb -v' into a file. Copy it. And cut each down so one of the adapters is in each. Then compare, e.g. diff(1), to see if anything else might consistently be different. Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Things discussed and results:
On Saturday, 10 December 2016 10:14:35 GMT Terry Coles wrote: > My cunning plan thereby comes crashing around my ears. I only have one of > the devices here at the moment, but it advertises iSerial as '0', so I've > no doubt the others will also be called that. > > The system will be run headless except when the code is being developed or > debugged, so how can I find a foolproof way to identify which channel is > which? The alternatives to using these devices work out at £30 - £40 per > channel because they are aimed at the hi-fi market. These devices are > about £3 each. > > I've already considered using the hdmi audio channel and putting one track > on the left channel and one on the right, but that would require that the > Wimborne Model Town Staff have a means to create the specially crafted mp3 > files. I'd rather not go down that path. > > Any other ideas? Answering myself, I suppose that the obvious answer is to play one track into the hdmi audio channel and the other track into the USB audio device, (which I can identify from its vendor ID). It seems a bit of a kludge though, so suggestions will still be gratefully received!! -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Things discussed and results:
On Saturday, 10 December 2016 00:44:51 GMT Ralph Corderoy wrote: > Terry has two USB audio adapters plugged in and wants to always play one > track so it comes out of the "left" one and the other track to emit from > the "right" regardless of the order they were enumerated by Linux. > They're the same product from the same vendor. Terry, there is a > "serial number" field in the USB descriptor, but you may find it's not > set to a unique value by the manufacturer. `sudo lsusb -v' will show it > as `iSerial'. My cunning plan thereby comes crashing around my ears. I only have one of the devices here at the moment, but it advertises iSerial as '0', so I've no doubt the others will also be called that. The system will be run headless except when the code is being developed or debugged, so how can I find a foolproof way to identify which channel is which? The alternatives to using these devices work out at £30 - £40 per channel because they are aimed at the hi-fi market. These devices are about £3 each. I've already considered using the hdmi audio channel and putting one track on the left channel and one on the right, but that would require that the Wimborne Model Town Staff have a means to create the specially crafted mp3 files. I'd rather not go down that path. Any other ideas? -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2017-01-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR