Web Based Remote Control Radio
My plan is to remote control a Flex Radio using a web based front end. The general architecture appears below. This allows the web server, hamlib (control library) and radio to exist on three different computers.
Hamlib provides an API for many different radios. That is, you can use the same commands to control many different types of radios. Hamlib essentially translates standard commands (e.g. set_freq) to a radio specific command. (e.g. FA14100000;) Even though this is a target specific project (i.e. flex) the concepts can be expanded to include any radio controllable by hamlib.
Since hamlib ctrld only runs under Linux, I chose to install hamlib on the same computer as the web server. A CGI application provides a set of controls on a web page. When a button is pushed, a TCP connection is made to hamlib and the command is passed over an network extended serialport to the radio.
In this case, the serial port is a pseudo terminal, which connects to a remote COM port over the network. SOCAT provides the serial-TCP connection on the linux side and tcp2com provides the connection on the Windows side. Note: tcp2com comes from the com0com project and is NOT the tcp2com.bat file, nor the tcp2com astronomy file. Other tcp/com port servers cost about $100-$200, so this is a real find. I tried HW Virtual Serial Port driver, which didn't work.
com0com creates a virtual serial cable, which completes the connection to the Flex CAT port.
Of course, the various modules can be combined to simplify this. For example, it should be possible to use the Win32 hamlib libraries to create a service, which could be accessible from any TCP connection. This would remove the complexity of socat/tcp2com.
However, after several hours of work (2/13/11), I didn't have any success. I tried compiling hamlib for windows using mingw32 because the ctrld file wasn't included with the binary distribution. Compiling failed complaining with a missing file, iconv.h which seems related to the xml parser. Then I found a blurb in a forum that says fdopen() isn't available under mingw! That's the function required to open a socket. No work around. This is a real bummer. Once this is available, hamlib will be available to control the flex radio with much less complexity.
The concept works well. My next task is to figure out how to use a flash front end. The CGI is very spartan, but works. It would also be cool to creat an iPhone app. Check out RFCORB (see the references section below) to see some flash examples.
Extended Serial Port
I used this set options to connect a serial port on a windows computer to pseudo terminal on a linux computer. It's best to let the windows box be the server. With a VBS script, you can set it up to listen on startup.
The com0com pair are COM7(listening) and COM15 (CAT Port).
On the Windows box, COM7 listens to port 2525:
com2tcp --baud 38400 --ignore-dsr \\.\COM25 2525
On the Linux box:
socat pty,link=/dev/tty1,nonblock,raw,echo=0,ocrnl=1 tcp4:192.168.10.48:2525,reuseaddr
Then the VBS script (c2t.vbs) can be:
Set objShell = CreateObject ("WScript.Shell") objShell.Run "cmd /K C:\downloads\com2tcp\com2tcp --baud 38400 --ignore-dsr \\.\COM7 2525",0,false
Start it with:
Make sure it works. You start the server first on the windows box, then socat on the linux box...then restart hamlib. When you disconnect the socat session, hamlib will need a restart, but the windows tcp/com server won't. This is a good thing, because chances of restarting socat and hamlib remotely are better than starting a windows service. The linux stuff can be done through SSH.
Modify the registry to start the server on startup and hide the window. Tip located here: http://www.goodjobsucking.com/?p=214
This script effectively hides the program so that it can run in the background, so all that remains is to have it launch when the system starts. That’s best accomplished using the registry to create a new “Expandable String Value” under “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run”. It doesn’t matter what the Name of the String Value is, but the Data should be the command line necessary to launch the script:
These commands connect the terminal window to the device (/dev/tty1). This can also be used to connect to serial ports for a quick and dirty COM port console.
screen /dev/tty1 ctrl-A-K to quit
- http://forums.remotehams.com/index.php?board=22.0 - Provides an network enabled API on a windows platform via ham radio deluxe. They use Flash as the front end on the web page.
- http://sourceforge.net/apps/mediawiki/hamlib/index.php?title=Main_Page - home pages for hamlib, which is a library to interface with various radios. Runs on linux.