Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Talk about your MIDI interfaces, microphones, keyboards...

Moderators: MattKingUSA, khz

Post Reply
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by bluebell »

Hi all,

I am planning to use 2 Scarlett 2i2 at once to have more outputs that can be differently EQed/routed. But regardless if you use alsa_out or a combined device on ALSA level (.asoundrc) you want to have the same setup after each boot.

That's not easy when you have 2 identical interfaces. The only difference I can imagine is the serial number. Getting it would allow some shell script magic to assign the interfaces to jackd and alsa_out or to create an .asoundrc on the fly before starting jackd. But how can I get it? I tried several methods I found in the web but all I got was nothing or a string with the interface's name. The serial number was never shown.

Any ideas?

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Drumfix
Established Member
Posts: 299
Joined: Mon Jan 26, 2009 5:15 pm
Been thanked: 11 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by Drumfix »

If the devices are connected to a different host controller you could use the bus id from lsusb output:

Bus 007 Device 002: ID 0480:a202 Toshiba America Inc Canvio Basics HDD
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub[/b]
Bus 002 Device 003: ID 0df6:0042 Sitecom Europe B.V. WL-345 Wireless USB adapter 300N X3
Bus 002 Device 002: ID 0480:a202 Toshiba America Inc Canvio Basics HDD
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub[/b]
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub[/b]

How to retrieve a serial number is vendor defined. So you're most likely out of luck.
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by bluebell »

Drumfix wrote:If the devices are connected to a different host controller you could use the bus id from lsusb output:

Bus 007 Device 002: ID 0480:a202 Toshiba America Inc Canvio Basics HDD
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub[/b]
Bus 002 Device 003: ID 0df6:0042 Sitecom Europe B.V. WL-345 Wireless USB adapter 300N X3
Bus 002 Device 002: ID 0480:a202 Toshiba America Inc Canvio Basics HDD
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub[/b]
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub[/b]

How to retrieve a serial number is vendor defined. So you're most likely out of luck.
Yes. Even the much better command
udevadm info --name=/dev/bus/usb/003/006 | grep SER
shows
E: ID_SERIAL=Focusrite_Scarlett_2i2_USB
and not the serial number. I have to use 2 different interfaces, e.g. a 2i4 and a 2i2.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Drumfix
Established Member
Posts: 299
Joined: Mon Jan 26, 2009 5:15 pm
Been thanked: 11 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by Drumfix »

If you know how to compile your own kernel i can provide you with a trivial patch to add the usb bus number at the end of the device's alsa shortname.
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by bluebell »

Drumfix wrote:If you know how to compile your own kernel i can provide you with a trivial patch to add the usb bus number at the end of the device's alsa shortname.
That wouldn't help much. I could get a similar result with lsusb/aplay -l and a little script magic. I have to use them on the same controller/bus (on a hub).

So I'll use 2 different interfaces for now.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Drumfix
Established Member
Posts: 299
Joined: Mon Jan 26, 2009 5:15 pm
Been thanked: 11 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by Drumfix »

Well, apparently i have not been working on USB drivers for too much time. The device descriptor contains the string index for the serial number, so it can be retrieved by the driver and appended to the alsa name. A patch should be almost as trivial to write as the one for the bus number above.
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by bluebell »

Drumfix wrote:Well, apparently i have not been working on USB drivers for too much time. The device descriptor contains the string index for the serial number, so it can be retrieved by the driver and appended to the alsa name. A patch should be almost as trivial to write as the one for the bus number above.
But then it's still up the interface's firmware to provide the serial no. I am afraid that the Scarlett's don't do it.

My solution with a 2i4 and a 2i2 works, so it's ok for me.

-> 2i4: microphones, direct monitoring -> to headphone amp, output from jack_mixer (without direct monitoring) to its builtin headphone amp
-> 2i2: output to the active speakers (from jack_mixer to CALF plugin host and CALF EQ via alsa_out to give some more treble)

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Drumfix
Established Member
Posts: 299
Joined: Mon Jan 26, 2009 5:15 pm
Been thanked: 11 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by Drumfix »

No, forget what i wrote above. Every USB device provides its serial number through the string referenced by the index given in the iSerial member of the device descriptor.
E.g:

Code: Select all

Bus 003 Device 002: ID 04e7:0020 Elo TouchSystems Touchscreen Interface (2700)
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x04e7 Elo TouchSystems
  idProduct          0x0020 Touchscreen Interface (2700)
  bcdDevice            1.07
  iManufacturer           1 
  iProduct                2 
  iSerial                 3
  bNumConfigurations      1
So here, the serial number is provided by the device's USB string in its string table at index 3.
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Get Serial no from Focusrite Scarlett 2i2, 2i4 ...

Post by bluebell »

Drumfix wrote:No, forget what i wrote above. Every USB device provides its serial number through the string referenced by the index given in the iSerial member of the device descriptor.
iSerial is 0 when using lsusb -v

There is another on, ID_SERIAL. But it's unusable, too.
Unfortunately the Focusrite firmware coders don't fill this part with the device's serial number but with its model name:

Code: Select all

hm@regen:~$ udevadm info --name=/dev/bus/usb/004/006 | grep SER
E: ID_SERIAL=Focusrite_Scarlett_Solo_USB
It could be so easy but it isn't :-/

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Post Reply