CLI Magic: CQ DE CLI

35

Author: Joe Barr

There are two types of geeks in the world. Those who only watch and listen, and those who communicate. TV-channel surfers or Ham radio operators. If you can manage to get up from that naugahide-upholstered GUI of yours for a few minutes, I’ll show you how the CLI can help upgrade you from spectator to player. In fact, I’ll show you two ways.The requirements for an Amateur Radio license vary from country to country. Here in the United States, it’s as easy as taking and passing a 35-question multiple-choice test. The first tool we’ll look at is a study-aid for taking that test.

Studying for the test

Actually, there are three different tests for licensing: The Technician class, General class, and Extra class. Christopher J. Carlson has written a very handy Perl program called “Ham Test” to help you study for them. In addition to grabbing and installing the program, you’ll need to download text versions of the pool questions for the exam you’re taking. You’ll find those here. Save the text file(s) in your home directory and remember their names. You’ll need them later.

I suggest that you also download the PDF file for each exam you are interested in studying for. The CLI study aid will sometimes refer to tables and figures in their printed material, and without the PDF, you can’t answer those questions.

Download the current HamTest gunzipped tarball and decompress it using the following command: tar xzf HamTest-v2.0.tar.gz. That creates a new sub-directory called HamTest. Enter it and read the INSTALL.txt you find there.

Then, as root, copy HamTest to a directory in your path — I used /usr/local/bin — and give the world execute permissions on it by entering the following command, while still root:


chmod 755 /usr/local/bin/HamTest

Naturally, if you used a different directory, you’ll substitute that for the on ein the example.

With the program installed, and the pool question text file(s) in your home directory, you’re good to go. Start studying for the Technician class exam by entering:


HamTest tech2003.txt

If everything is correctly in place, you’ll see something like this in your console:

Reading File tech2003.txt...
Generating Random Questions...
Building Test... (35) Questions.

ARRL Question: T3A09 (1/35) (0.00%) What effect does the D region of the ionosphere have on lower-frequency HF signals in the daytime? A. It absorbs the signals B. It bends the radio waves out into space C. It refracts the radio waves back to earth D. It has little or no effect on 80-meter radio waves

Your Answer:

If you don’t see a question like that, check the INSTALL.txt file again and make sure you have Perl and the component required on your system.

I sent Chris an email asking for his motivation in writing the program. He replied:

Motivation? Nothing more than wanting something to help me get my
General that I could use at work. I’m fairly good at Perl, and thought
it would be the perfect language for writing such an app, so I did it.
There wasn’t much out there for ‘at home, no internet’ testing. (there
are plenty of web-based apps, but what if you are using lynx or a text
based browser, or their site is down?) Ultimately I wrote it for
myself, but thought others could benefit. Same reason I write most of
my GPL’ed apps.

Practicing Morse code

The second CLI tool for wannabe Hams — at least those who also want to learn and use Morse code, which is no longer a requirement to get a license — is a nifty little utility called cwtext, written by Randall Bohn (KD7TVZ) and also licensed under the GPL.

Actually, it is three separate programs. One converts text to ASCII dots and dashes (called “dotscii”), another converts the text to an audio stream of morse code, and a third converts the text to something called “MorseMail.”
All three programs are licensed under the GPL.

To get the latest cwtext, click on the Download link on this page. Decompress the tarball and enter the subdirectory created: cwtext-0.94 in my case.

Installation is as easy as typing make install at the command line, as root, of course. Then you can test your system to make sure it can reproduce the sound of Morse code by entering sh test.sh from the command line while in the cwtext directory.

You should hear Morse code after you do so. First the word “SLOW” is sent, very slowly. Then “MEDIUM”, “FAST”, “EXTRA” and “DEFAULT” follow, each sent at the speed indicated. The test script itself is pretty neat, let’s take a look.

echo "slow" | ./cwpcm -ss > /dev/audio
echo "medium" | ./cwpcm -sm > /dev/audio
echo "fast" | ./cwpcm -sf > /dev/audio
echo "extra" | ./cwpcm -sf > /dev/audio
echo "default" | ./cwpcm -sf > /dev/audio

As you can see, it’s just a series of echo commands with the output being piped to cwpcm, which in turn is followed by an option for the transmission speed, directed at the audio device.

If you are wanting to hear the Morse code, instead of see it in “dotscii” or “MorseMail,” this is an easy way to do it. To sound the contents of an entire file at the default (fast) speed, try this:

cat TEXTFILE | cwpcm -sf > /dev/audio

That’s all there is to it. The README contains a really cool usage for impressing your Linux Ham friends. Try this, if you have the finger program installed:


finger @finger.kernel.org | cwpcm > /dev/audio

Of course, when you’re not trying to impress people, you can always just practice your Morse code copying skills to your heart’s content.

I asked Randall the same thing I asked Chris, for his motivation in writing cwtext. He replied:

I wrote a text-to-morse code program in the early 90’s in Microsoft Quick C. When I started using Linux I looked around for something similar, but didn’t find one, so I wrote my own. I was working in a computer lab and wanted to know when different computers rebooted. I also thought it would be cool to get the latest headlines via morse code.

It took me a while to figure out how to generate a usable audio signal, and even longer to get the Farnsworth spacing right. Looking back I should have turned to the ARRL Handbook, all the information is in there.

I knew from the start I wanted to release CWTEXT under the GPL license so others could use it. When I had a reasonably working version I set up the project on SourceForge.net. Several people have told me how they use it for online code practice or making code practice CD’s. I’m currently looing into building an APRS to Morse Code program.

That’s it for this week. But remember:

.... .- .--. .--. -.--  -. . .--  -.-- . .- .-.