Skip to content

Instantly share code, notes, and snippets.

@relistan
Last active September 18, 2024 21:50
Show Gist options
  • Save relistan/bd9c4b8bab55b81c0374f30bf565bbe0 to your computer and use it in GitHub Desktop.
Save relistan/bd9c4b8bab55b81c0374f30bf565bbe0 to your computer and use it in GitHub Desktop.
Enable CAT control for WSJT-X on the (tr)uSDX on macOS

CAT Control on the (tr)uSDX for WSJT-X on macOS

This will enable CAT control on your Mac running WSJT-X with the (tr)uSDX and possibly other USDX rigs as well. WSJT-X uses Hamlib to connecto to and manage CAT on different radios. The problem (thanks to Guido PE1NNZ for identifying), is that Hamlib resets the port when it connects. This causes the radio to reset and then it's not yet available when Hamlib tries to connect. We can work around that by blocking the ability for Hamlib to reset the port. The simplest way to do that is to have the port already in use when Hamlib starts up.

I was not able to achieve that using the Hamlib built into WSJT-X. However, by installing Hamlib separately, and running it in TCP server mode (acts like a network server), I was able to get this all to work.

You need to install hamlib with brew install hamlib. If you don't have brew already, then you will need to either install it, or use a different method for installing hamlib. Once that is installed, you should be able to run rigtctld on its own.

Running It

  1. Connect the (tr)USDX to external power first
  2. Connect the USB cable to the rig
  3. Copy the shell script above into your path (e.g. /usr/local/bin)
  4. Run chmod 755 <where you put it> to make it executable
  5. Run the script with urig if it's in your path or ./urig if it's in the current directory

Once that says 'rigctld' running, you can start WSJT-X. Configure WSJT-X like the screenshot included in this gist.

#!/bin/sh
PORT=`ls -tr "/dev/tty.usbserial-[0-9]*" | tail -1`
if [ -z $PORT ]; then
echo "No suitable USB serial port found"
exit 1
else
echo "Found USB serial port named ${PORT}"
fi
cat $PORT &
CAT_PID=$!
echo "Starting 'rigctld'"
## NOTE! Some versions of the (tr)uSDX use 115200 and you may
## need to change this setting from 38400 -> 115200
rigctld --model=2028 --listen-addr=127.0.0.1 --port=7006 -s 38400 -r $PORT &
RIG_PID=$!
echo "Waiting for radio initialization to complete"
sleep 3
echo "Stopping 'cat' command"
kill $CAT_PID
echo "'rigctld' running"
wait $RIG_PID
@madler
Copy link

madler commented May 26, 2023

Thanks for this! It looked like it would solve this problem, but alas, it's not working for me. The script finds the port and runs rigctld, resetting the (tr)uSDX. However when I try Test CAT in WSJT-X (with the configuration you show above), it resets the (tr)uSDX five more times, and then gives up. I get:

Hamlib error: read_string_generic(): Timed out 10.001 seconds after 0 chars, direct=1
Communication timed out

netrigctl_open: vfo_mode=0
netrigctl_transaction: called len=12
rig_flush: called for network device
network_flush called
write_block(): TX 12 bytes, method=2
0000    5c 64 75 6d 70 5f 73 74 61 74 65 0a                 \dump_state.    
read_string_generic called, rxmax=1024 direct=1, expected_len=1
read_string_generic(): read failed, direct=1 - Connection reset by peer
  2:netrigctl.c(299):netrigctl_open returning(-6) IO error

  2:rig.c(7478):async_data_handler_stop entered
  2:rig.c(7508):async_data_handler_stop returning(0) 
network_close: close socket ret=0
 1:rig.c(1273):rig_open returning(-6) IO error

IO error
IO error
 while opening connection to rig

(hamlib version 4.5.4, wsjtx.app 2.6.1)

@relistan
Copy link
Author

@madler Are you able to get any other software to connect to the radio with that rigctl? I wonder if something is misconfigured between the rigctld and the radio.

I any case, I'm running hamlib 4.5.5 and WSJT-X version 2.5.4 and it works for me.

@madler
Copy link

madler commented May 26, 2023

It was the baud rate. I have version 2.00 of the (tr)uSDX firmware, which now uses 115200 baud. I updated your script, and it seems to be working now. (Though not entirely reliably. I'll futz with it some more.)

@relistan
Copy link
Author

@madler gist updated with a comment in the script to call this out so people can set it appropriately. Thanks!

@madler
Copy link

madler commented Jun 10, 2023

Noticed another small variation. On my MacBook Pro, it connected to /dev/tty.usbserial-110, which was found by your script. However on my Mac Studio, my (tr)uSDX connected to /dev/tty.usbserial-410. No other usbserial's show up, so I removed the 1 that the script was looking for.

@relistan
Copy link
Author

That's fine @madler. A better solution is to use [0-9] instead of removing it. Because otherwise it can match other devices too easily. I have several other USB serial devices. I will updated the script.

@NavyMikeHam
Copy link

I have an M1 Mac Book Pro running mac OS 14.2.1. I am connected to my (tr)uSDX radio through an Apple USB-C to USB adaptor.

I don't know much about com ports or UNIX scripts but I determine that I needed to use "/dev/tty.usbserial-110" as my Serial Port setting in WSJT-X. I then had to modify the script a bit to PORT=ls -tr "/dev/tty.usbserial-110" | tail -1. Not sure if this is the correct syntax but it did allow the script to complete correctly. From there I upped the Baud Rate to 115200 per your note and Test CAT went green!

Thanks for this script and the helpful details, I would not have gotten up and running without it.

@relistan
Copy link
Author

Thanks for this script and the helpful details, I would not have gotten up and running without it.

Hey, glad it helped!

I then had to modify the script a bit to PORT=ls -tr "/dev/tty.usbserial-110" | tail -1. Not sure if this is the correct syntax but it did allow the script to complete correctly. From there I upped the Baud Rate to 115200 per your note and Test CAT went green!

The original script should work with that port. The [0-9]* is a pattern match for anything that starts with a digit. It only matters because if you were to plug the radio into a different port or via a USB hub you might find that it's no longer on -110. But as long as it works for you, it doesn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment