ICOM IC-9700 and IC-7300 coexisting in Linux
Iβve just added an IC-9700 to the desk alongside the IC-7300, they look very nice together and very similar. Unfortunately the Audio and Serial devices also look very similar in Linux!
Both radio sound cards appear as PCM2901 making it hard to differentiate between them, and my previous udev rule to create a symlink for the IC-7300 ttyUSB device on /dev/ic7300 picked up the 9700 instead.
My previous udev serial rule created a symlink to /dev/ttyUSBx from /dev/ic7300 when a device with the 7300βs serial adapter idVendor and idProduct was seen like so:
SUBSYSTEM==βttyβ, ATTRS{idVendor}==β10c4β³, ATTRS{idProduct}==βea60β³ SYMLINK+=βic7300β³
This worked fine until the 9700 was plugged in as it also has the same idVendor and idProduct number. We can narrow this down easily as another available attribute is βserialβ which contains the radios unique serial number along with its name.
We can get the serial numbers using udevadmΒ (or better with lsusb below) against each of the /dev/ttyUSBx devices, the 9700 has two serial devices, the first works fine with hamlib for control but not sure what the second serial device at the moment.
$ udevadm info βattribute-walk βpath=/sys/bus/usb-serial/devices/ttyUSB4 | grep IC-
ATTRS{serial}==βIC-9700 13000000 Aβ$ udevadm info βattribute-walk βpath=/sys/bus/usb-serial/devices/ttyUSB5 | grep IC-
ATTRS{serial}==βIC-9700 13000000 Bβ$ udevadm info βattribute-walk βpath=/sys/bus/usb-serial/devices/ttyUSB1 | grep IC-
ATTRS{serial}==βIC-7300 03000000β³
An easier way to get the serial numbers is by running lsusb as root as follows, thanks to PA3MET for the pointer!
# lsusb -vvvvv | egrep "9700|7300" iSerial 3 IC-9700 13000000 B iSerial 3 IC-9700 13000000 A iSerial 3 IC-7300 03000000
We can take these and create appropriate udev rules for adding symlinks for the radios serial devices including the unique serial numbers. Here is an extract from my /etc/udev/rules.d/99-hamlib.rules file:
SUBSYSTEM==βttyβ, ATTRS{idVendor}==β10c4β³, ATTRS{idProduct}==βea60β³, ATTRS{serial}==βIC-7300 03000000β³, SYMLINK+=βic7300β³
SUBSYSTEM==βttyβ, ATTRS{idVendor}==β10c4β³, ATTRS{idProduct}==βea60β³, ATTRS{serial}==βIC-9700 13000000 Aβ, SYMLINK+=βic9700aβ
SUBSYSTEM==βttyβ, ATTRS{idVendor}==β10c4β³, ATTRS{idProduct}==βea60β³, ATTRS{serial}==βIC-9700 13000000 Bβ, SYMLINK+=βic9700bβ
Take care if copying the above text as the quotation marks are displaying incorrectly in WordPress. If you copy it as is you will need to replace them all with proper quotation marks.
A reload of udev rules with βudevadm triggerβ and we have our serial devices available from convenient symlinks so no chasing about ttyUSB device names:
$ ls -l /dev/ic* lrwxrwxrwx 1 root root 7 Apr 4 14:27 /dev/ic7300 -> ttyUSB1 lrwxrwxrwx 1 root root 7 Apr 4 14:27 /dev/ic9700a -> ttyUSB4 lrwxrwxrwx 1 root root 7 Apr 4 14:27 /dev/ic9700b -> ttyUSB5
Next up is the sound cards. I use quite a lot of different programs and need to easily switch and adjust my audio inputs/outputs using pavucontrol. The problem here is both audio devices have the same name, PCM2901, meaning I canβt easily tell what sound card belongs to what radio.
Thereβs no way to differentiate the sound cards like with the serial above as they return the exact same information and attributes. The only way to differentiate them from what I can see is with the physical USB port they are plugged in to. This is fine here as itβs a desktop and they will remain plugged in to the same ports. If you plug the radios in to a different USB socket you will need to update the paths again.Β
We can list the devices with the following command, this shows both the IC-7300 and IC-9700 sound cards. Iβve removed some other sound cards from the output, as weβre just looking for the βBurr-Brown_from_TI_USB_Audio_CODECβ entries here
$ pacmd list-sources | egrep βname:|sysfsβ
name: <alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.2.monitor>
sysfs.path = β/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.4/3-2.4:1.0/sound/card4β
name: <alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.2>
sysfs.path = β/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.4/3-2.4:1.0/sound/card4β³
name: <alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.3.monitor>
sysfs.path = β/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.0/sound/card5β
name: <alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.3>
sysfs.path = β/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.0/sound/card5β³
We are looking to extract the unique portion from device paths above, here we can see the paths differ atΒ 3-3/3-3.4/3-3.4Β andΒ 3-2/3-2.4/3-2.4. We will want to identify which entry belongs to which radio so run it with the USB disconnected then connected to identify which device matches which radio.
We can then run the following to apply a device description of IC9700 to the IC-9700 sound card source and sink which will show against the audio device in pulse applications instead of PCM2901.
The 3-3.4 below is referencing the end of the USB port discovered above.
pacmd update-source-proplist $(pacmd list-sources | egrep βname:.*Burr-Brown*|3-3.4β | grep -B 1 sysfs.path | grep name | sed βs/.*<\(.*\)>/\1/β | grep -v monitor) device.description=IC9700
pacmd update-sink-proplist $(pacmd list-sinks | egrep βname:.*Burr-Brown*|3-3.4β | grep -B 1 sysfs.path | grep name | sed βs/.*<\(.*\)>/\1/β) device.description=IC9700
And the same for the IC7300 with 3-2.4:
pacmd update-source-proplist $(pacmd list-sources | egrep βname:.*Burr-Brown*|3-2.4β | grep -B 1 sysfs.path | grep name | sed βs/.*<\(.*\)>/\1/β | grep -v monitor) device.description=IC7300
pacmd update-sink-proplist $(pacmd list-sinks | egrep βname:.*Burr-Brown*|3-2.4β | grep -B 1 sysfs.path | grep name | sed βs/.*<\(.*\)>/\1/β) device.description=IC7300
The audio devices should now be available using the name we set above in pavucontrol and other applications. This can be put in a script to run manually or at system startup.