diff --git a/PLAN.md b/PLAN.md index 5d36f3e..bb2109a 100644 --- a/PLAN.md +++ b/PLAN.md @@ -14,10 +14,6 @@ unconfigure` to undo it. - [ ] Run `TEST.md` against real radios, and mark the `radios.conf` values they confirm `# verified`. Fix or remove the ones they don't -- [ ] More radios in `radios.conf`: Icom IC-7851, IC-7600 and IC-9100; Xiegu - (which speak CI-V) and Lab599 (Kenwood-style CAT). Check each one's - Hamlib model, CI-V address or `ID;` reply, and flrig name, as for the - others - [ ] Radios with older Yaesu CAT that doesn't answer `ID;` (FT-817, FT-818, FT-857, FT-897): find out what `radio probe` could safely send them to tell what they are, or have `radio configure --model` set them up diff --git a/TEST.md b/TEST.md index 54333f5..be4f908 100644 --- a/TEST.md +++ b/TEST.md @@ -41,6 +41,15 @@ Hamlib does. Check `radio detect --probe` names the right one; if not, note what `echo "OM;" > /dev/ttyUSB0` gets back (with `cat /dev/ttyUSB0` running in another terminal, at the radio's baud rate). +A Xiegu answers Icom's "read transceiver ID" from an address an Icom uses too, +so `radio detect --probe` lists both; check the Xiegu is among them. Note the +reply's address and ID bytes, which `python3 -c 'import sys; +sys.stdout.buffer.write(bytes.fromhex("fefe00e01900fd"))' > /dev/ttyUSB0` gets +(with `xxd /dev/ttyUSB0` running in another terminal, at the radio's baud +rate): the G90's address is 88 by flrig and A4 by Hamlib. The IC-7851, IC-7600 +and IC-9100 have USB serial chips: note the serial number `radio` lists, and +whether it names the radio, as the IC-7300's does. + Interfaces to try, as well as radios with built-in USB: a Digirig (CP2102 and CM108 behind its own hub, RTS keys PTT), an FTDI CAT cable, and an Icom CI-V cable. diff --git a/radio b/radio index e39ecc5..2b2a4b7 100755 --- a/radio +++ b/radio @@ -366,8 +366,9 @@ for baud in sys.argv[2:]: options = om.group(1).decode() if om else "" print(baud, "cat_id", found.group(1).decode(), options) break - # To any address (00) from a computer (E0); the radio answers to E0 from its address - found = re.search(rb"\xfe\xfe\xe0(.)\x19\x00.\xfd", ask(bytes.fromhex("fefe00e01900fd")), re.S) + # To any address (00) from a computer (E0); the radio answers to E0 from + # its address, with its ID: one byte from an Icom, two from some Xiegus + found = re.search(rb"\xfe\xfe\xe0(.)\x19\x00[^\xfd]{1,2}\xfd", ask(bytes.fromhex("fefe00e01900fd")), re.S) if found: print(baud, "civ", found.group(1).hex().upper()) break @@ -599,7 +600,9 @@ probe() { reason="$(cant_probe "$port")" [ -z "$reason" ] || { echo "Can't ask: $reason" >&2; return 1; } if probe_port "$port"; then - echo "$(describe_answer), at $ANSWER_BAUD baud" + local described + described="$(describe_answer)" + echo "${described^}, at $ANSWER_BAUD baud" elif [ -n "$PROBE_ERROR" ]; then echo "Can't ask: $PROBE_ERROR" >&2 return 1 diff --git a/radios.conf b/radios.conf index dd8cc05..6a497a6 100644 --- a/radios.conf +++ b/radios.conf @@ -19,7 +19,8 @@ # no driver for it, or several (the TS-480's HX and SAT) # # A radio needs usb_serial=, cat_id= or civ=, or `radio` can't recognise it. -# The Hamlib model numbers were checked against Hamlib 4.6. The other values +# The Hamlib model numbers were checked against Hamlib 4.6 (the IC-7851, +# IC-7600, IC-9100, Xiegus and Lab599 against 4.7.2). The other values # come from the radios' CAT manuals and Hamlib's tables; mark one "# verified" # once a real radio has answered with it. @@ -60,6 +61,55 @@ hamlib=3090 usb_serial=IC-905 * civ=AC +# These three have USB too, but what their USB serial chips' serial numbers +# say isn't known, so they're recognised by asking them + +[Icom IC-7851] +hamlib=3075 +flrig=IC-7851 +civ=8E + +[Icom IC-7600] +hamlib=3063 +flrig=IC-7600 +civ=7A + +[Icom IC-9100] +hamlib=3068 +flrig=IC-9100 +civ=7C + +# Xiegu. They speak CI-V, at addresses Icoms use too, so asking one may list +# an Icom as well; give --model to say which it is. Their USB serial chips +# (a CH340 in the G90's DE-19 interface) carry no model. The G90's address is +# flrig's; Hamlib says A4. The X6100, X6200 and G106 answer "read transceiver +# ID" with two bytes, which Hamlib reads as their model; radio goes by the +# address they answer from, as for the Icoms + +[Xiegu G90] +hamlib=3088 +flrig=Xiegu-G90 +civ=88 + +[Xiegu X6100] +hamlib=3087 +flrig=X6100 +civ=A4 + +[Xiegu X6200] +hamlib=3091 +flrig=X6200 +civ=A4 + +[Xiegu X5105] +hamlib=3089 +flrig=Xiegu-5105 +civ=70 + +[Xiegu X108G] +hamlib=3076 +civ=70 + # Yaesu. Their USB serial chips (CP2105) carry no model, so they're recognised # by asking them, with `radio detect --probe` @@ -143,6 +193,13 @@ hamlib=2041 flrig=TS-890S cat_id=024 +# Lab599. Kenwood-style CAT, answering ID; as a TS-2000 does + +[Lab599 TX-500] +hamlib=2050 +flrig=TX500 +cat_id=019 + # Elecraft. They all answer ID; as a Kenwood TS-570 would; their reply to OM; # tells them apart diff --git a/tests/radio.bats b/tests/radio.bats index 15c12d9..2bc53e4 100644 --- a/tests/radio.bats +++ b/tests/radio.bats @@ -343,7 +343,11 @@ while time.monotonic() < end: heard = b"" if sys.argv[2] == "icom" and civ_request in heard: # With CI-V USB echo on, the radio echoes the request first - os.write(master, civ_request + bytes.fromhex("fefee0a41900a4fd")) + os.write(master, civ_request + bytes.fromhex("fefee094190094fd")) + heard = b"" + if sys.argv[2] == "xiegu" and civ_request in heard: + # An X6100: its ID in two bytes, from the IC-705's address + os.write(master, bytes.fromhex("fefee0a419006100fd")) heard = b"" EOF python3 "$BATS_TEST_TMPDIR/fake_radio.py" "$BATS_TEST_TMPDIR/pty" "$1" 3>&- & @@ -371,7 +375,22 @@ teardown() { fake_radio icom run bash "$REPO/radio" probe "$PTY" [ "$status" -eq 0 ] - [ "$output" = "Icom IC-705 (Hamlib model 3085), at 38400 baud" ] + [ "$output" = "Icom IC-7300 (Hamlib model 3073), at 38400 baud" ] +} + +@test "probe hears a Xiegu's two-byte ID, and lists the radios at its address" { + fake_radio xiegu + run bash "$REPO/radio" probe "$PTY" + [ "$status" -eq 0 ] + [ "$output" = "One of: Icom IC-705 (Hamlib model 3085), Xiegu X6100 (Hamlib model 3087), Xiegu X6200 (Hamlib model 3091), at 38400 baud" ] +} + +@test "--probe lists a Lab599 TX-500 with the TS-2000, which answers ID; alike" { + usb 1-4 0403:6001 FTDI "FT232R USB UART" A12345 + port 1-4 ttyUSB0 + answers ttyUSB0 "38400 cat_id 019" + run bash "$REPO/radio" --probe + [ "${lines[0]}" = "1. One of: Kenwood TS-2000 (Hamlib model 2014), Lab599 TX-500 (Hamlib model 2050), answered on ttyUSB0 at 38400 baud" ] } @test "probe says when nothing answers on a real port" {