Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

Serial Port CAT Control with Smart SDR for Mac

SDR for Mac doesn’t have the ability to emulate serial ports like the Windows counterpart does. This isn’t normally an issue since most respectable apps support either hamlib Net Rig Control or some other network based CAT control. There are however a few stragglers that still only support CAT control via serial ports. “Winlink Express” (my nemesis) is a fine example of ham radio software that only supports CAT control via serial ports. To be able to use Winlink Express with Smart SDR for Mac I needed a serial to TCP bridge to convert incoming “Serial” (tty in Mac / Linux) connections and redirect them to a TCP connection that Smart SDR for Mac was expecting.

Enter “socat” (Socket Cat). It has the ability to redirect all kinds of incoming connections and it supports both the ability to create a pseudo terminal (pty) for serial connections and a TCP connection.

To install socat you will either need to compile it from source or use a package manager like brew or mac ports:

Install Brew Package manager:

https://brew.sh

or

Install Mac Ports package manager

https://www.macports.org

Once the brew or Mac Ports package manager is installed use the following to install socat from a standard terminal window (from the finder window click “Applications —> Utilities —> Terminal” to open Terminal):

via Brew:

brew install socat 

or 

via Mac Ports:

sudo port install socat


to run socat type the following in a terminal window:

"socat -d -d pty,cfmakeraw TCP4:localhost:4532"

You should see the following in your terminal window

The first line of the output indicates the serial port that socat is using, in the above example it’s “/dev/ttys007”

The second line show the TCP connection to Smart SDR for Mac being setup to 127.0.0.1:4532 (127.0.0.1 = localhost, port 4532)

From here you simply tell your application to use “/dev/ttys007” for the serial connection and all CAT Control commands sent to “/dev/ttys007” will be redirected to Smart SDR for Mac on what ever port you specified when you launched socat (port 4532 in the above example). 

To verify the TCP connection to Smart SDR for Mac is working correctly you can check the CAT Control window in Smart SDR for Mac. In the example below the red box shows the port Smart SDR is expecting to receive CAT commands on and the green box shows the connected status after launching socat (The status will show “Connected if it worked, “Waiting” if the port was specified incorrectly or socat terminated).

Breaking down the socat command:

-d -d = this enables just enough debug messages to be able to determine the pty address. Without the “-d -d” socat will grab the first free pty (/dev/ttys007 in the examples above) but not tell you what pty it selected leaving you to guess.

pty,cfmakeraw = this tells so cat that one side of the connection should be a pty (Pseudo Terminal, fancy name for virtual Serial Port). The “cfmakeraw” option tells socat that you don’t want any processing on the pty, just take the data in and send it back out exactly like it came in. If you google socat examples most of them use “raw” which is the same as cfmakeraw or rawer. I stayed away from “raw” since the man pages say it’s been deprecated and replaced by rawer and cfmakeraw.

TCP4:localhost:4532 = TCP4 Tells socat to make a TCPv4 connection. localhost is your machine, 4532 is the TCP port


Troubleshooting:

before you launch socat Smart SDR for Mac needs to have CAT Control enabled and the port needs to be correct or you will receive the following error:

2020/09/16 23:33:57 socat[12352] E connect(7, LEN=16 AF=2 127.0.0.1:4532, 16): Connection refused

If you see the above message check that the port is specified correctly in the Cat Control window and the socat command. Also verify that Cat Control is enabled. It doesn’t really matter what the port is, it just can’t be used by another application and it has to match in both socat and Smart SDR for Mac. Port “5001” or “4532” are used in many examples but they just need to be the same in Smart SDR for Mac and socat if you have to change it.


Additional useful socat options:

-v -d -d -d = enables additional debug messages and verbose messages

link=<filename> = since the pty option just grabs the next available pty it likely won’t always be “/dev/ttys007”. The link options allows you to specify a file name for the pty by automatically creating a link between the file you specify and whatever pty socat selects. Now you can tell your ham radio application to use the linked file “/Users/kwilliams/tty.v1” instead of whatever random pty socat assigns when you run the command.

Example of socat with the additional options:

socat -v -d -d -d pty,link=/Users/kwilliams/Downloads/tty.v2,cfmakeraw TCP4:localhost:4532

Comments

  • The serial port is created and connect to smartsdr for mac.But this serial port can not be find in skookumlogger's Radio setup.
  • Alan
    Alan Member ✭✭✭✭

    Kevin and other Mac experts:

    I too tried to use "SOCAT" to connect MacDoppler to my Flex 6600 via xCAT. All looks good, however, port "/dev/ttys001" created by SOCAT does not show up in the pulldown menu in the MacDoppler Radio Control Settings Serial Port selector.

    Any suggestions?

    Alan WA9WUD


  • K3DCW
    K3DCW Member ✭✭

    For what it is worth, this works just fine with FLDIGI, although you have to type in the /dev/ttys001 information into the appropriate block as it doesn't appear in the pulldown.

    MacDoppler and SkookumLogger don't allow you to type in port information manually. Perhaps you could create a symlink to the port created by socat, but you will have to place it in the /tmp folder and it doesn't appear that SkookumLogger recognizes this location (I'm not sure about MacDoppler, but MacLoggerDX wouldn't work with it either). You can't create a symlink in the /dev folder as that is prohibited by macOS.