Know twin interfaces by their USB socket, and say so
Two interfaces with the same vendor, product and serial number (none, often) share a /dev/serial/by-id name, which udev points at whichever came last, so their serial ports are named by /dev/serial/by-path instead. radio and radio configure say when an interface has a twin, and that its sound card goes by the order the two came up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d910982ea7
commit
7697a785d3
@@ -1461,6 +1461,48 @@ digirig() {
|
||||
grep -q -- "-p /dev/input/by-path/pci-0000:00:14.0-usb-0:1-3:1.3-hidraw -P CM108" "$HOME/.config/systemd/user/hampack-rigctld.service"
|
||||
}
|
||||
|
||||
@test "says when an interface has a twin that only its USB socket tells apart" {
|
||||
configurable
|
||||
rm -r "$RADIO_SYSFS/class/tty/ttyUSB0" "$RADIO_SYSFS/class/sound/card1"
|
||||
aioc
|
||||
usb 1-4 1209:7388 "AIOC" "All-In-One-Cable"
|
||||
card 1-4 card3 AIOC_1
|
||||
pcm card3 p c
|
||||
hidraw 1-4 hidraw3 open usb-AIOC_All-In-One-Cable-if03
|
||||
run bash "$REPO/radio"
|
||||
[ "$(grep -c "There's another AIOC All-In-One-Cable plugged in, which nothing tells apart from this one but the USB socket each is in" <<< "$output")" -eq 2 ]
|
||||
[[ "$output" != *"if the radios get each other's audio"* ]]
|
||||
run bash "$REPO/radio" configure 2
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Keep each in its socket, and if the radios get each other's audio, run \`radio configure\` again"* ]]
|
||||
}
|
||||
|
||||
@test "names a serial port by its USB socket when a twin shares its by-id name" {
|
||||
configurable
|
||||
rm -r "$RADIO_SYSFS/class/tty/ttyUSB0" "$RADIO_SYSFS/class/sound/card1"
|
||||
# Two CH340 cables with no serial number: udev's by-id link is the last one's
|
||||
usb 1-4 1a86:7523 "QinHeng Electronics" "USB Serial"
|
||||
port 1-4 ttyUSB1
|
||||
usb 1-5 1a86:7523 "QinHeng Electronics" "USB Serial"
|
||||
port 1-5 ttyUSB2
|
||||
ln -s ../../ttyUSB2 "$RADIO_DEV/serial/by-id/usb-1a86_USB_Serial-if00-port0"
|
||||
mkdir -p "$RADIO_DEV/serial/by-path"
|
||||
ln -s ../../ttyUSB1 "$RADIO_DEV/serial/by-path/pci-0000:00:14.0-usb-0:4:1.0-port0"
|
||||
ln -s ../../ttyUSB2 "$RADIO_DEV/serial/by-path/pci-0000:00:14.0-usb-0:5:1.0-port0"
|
||||
run bash "$REPO/radio" configure --model 1020 1
|
||||
[ "$status" -eq 0 ]
|
||||
grep -q -- "-r /dev/serial/by-path/pci-0000:00:14.0-usb-0:4:1.0-port0 " "$HOME/.config/systemd/user/hampack-rigctld.service"
|
||||
[[ "$output" == *"There's another QinHeng Electronics USB Serial plugged in"* ]]
|
||||
[[ "$output" != *"has no stable name"* ]]
|
||||
|
||||
# On its own, it has its by-id name
|
||||
rm -r "$RADIO_SYSFS/class/tty/ttyUSB2"
|
||||
ln -sfn ../../ttyUSB1 "$RADIO_DEV/serial/by-id/usb-1a86_USB_Serial-if00-port0"
|
||||
run bash "$REPO/radio" configure --model 1020
|
||||
grep -q -- "-r /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 " "$HOME/.config/systemd/user/hampack-rigctld.service"
|
||||
[[ "$output" != *"There's another"* ]]
|
||||
}
|
||||
|
||||
@test "configure sets up a handheld on a Digirig with --no-cat and --ptt" {
|
||||
configurable
|
||||
rm -r "$RADIO_SYSFS/class/tty/ttyUSB0" "$RADIO_SYSFS/class/sound/card1" "$RADIO_DEV/serial/by-id/"* "$FAKE_RADIOS/ttyUSB0"
|
||||
|
||||
Reference in New Issue
Block a user