New serial cable works, scripting for the TH-D7A

One of the reasons that I chose the Kenwood TH-D7A(G) as my hand held transceiver is its integration with packet radio. It includes a TNC (that’s terminal node controller) that works at either 1200 baud or 9600 baud. This allows it to exchange digital information over amateur radio frequencies. It also has the ability to connect to a GPS and send information over the APRS (Automatic Position Reporting System). This is an amateur system that allows individuals to broadcast positions over the amateur network, and is also used to broadcast weather information and for simple messaging.

It is actually quite capable even by itself, but obviously a great deal of additional capability can be had by linking the little HT to a computer. It’s actually setup for that pretty well, it only requires a couple of cables. Kenwood charges $50 or so for the cable + some software, which seems like a pretty harsh price, considering the cable has no active components, and the software.. well, as you see, you really don’t need.

So, instead I ordered some pigtails from Vetco Electronics. The cables are good quality, heavy and shielded and are exactly what you need, and cost $2.50. A trip to Fry’s (yes, I swore I wouldn’t go back to Fry’s, but I was in a hurry) netted a bag of female DB9 connectors (10 for $3.50) and a couple of shells to cover it (cheap $.59 a piece), and I was ready to go. The manual tells you what connections need to be soldered up (there are only three of them: ground, TX and RX) and voila. I hooked it to my old FreeBSD box, fired up minicom -o, and typed ID, to which the receiver echoed ID TH-D7AG. Cool, I was in!

I then had a bit of a miscue: the laptop I use is a MacBook, and of course, like many modern computers, it doesn’t have any DB9 ports. No problem thought I: I got on Amazon and ordered a Sabrent USB->serial converter for under $10. It advertises as being compatible with both OS X and with Linux, so I thought great! Sadly, it didn’t work at all, on either Linux or Mac OS X. I did a quick poll of our local Mac experts, and they recommended a KeySpan one. A trip to our local CompUSA netted one, at $40 (frown), but I must admit: it works just fine with their MacOS driver. There are some issues using it on Ubuntu under linux (driver licensing makes it not work by default) but for now, I am happy with just using it on my MacBook.

So…

Python is my preferred scripting language, so I wanted to use some of the programming information I had found earlier to control and access the information inside the TH-D7A. I downloaded the “pyserial” module for the MacBook, and wrote the following near trivial script:

#!/sw/bin/python2.5

import sys
import serial

s = serial.Serial("/dev/tty.KeySerial1", 9600, timeout=1)

s.write("r")
print s.readline()
s.write("IDr")
print s.readline()

for x in range(40):
        s.write("LIST %02dr" % (x+1))
        print s.readline()

s.close()

This program basically just makes the radio id itself, then gets the information for the 40 most recently scene stations received via APRS. Each station is identified by a callsign, and is followed by a latitude and longitude code,, and other information. The output looks like this:

ID TH-D7G
LIST 01,KI6GPQ-9,38335800122488501,/j,01,:, ,,220000------
LIST 02,KA6MAL-9,37079900122081701,/>,01,:, ,,329030------
LIST 03,KB7NV,39181300119316901,/-,,3, ,Tony, Dayton, Nv. kb,------------
LIST 04,KF6HJO,36306800119409101,/_,,6, ,p001P001b10201h00,137000056000
LIST 05,WA6AOB-12,39135 00121035 01,/k,00,:, ,,343000------
LIST 06,N6QGV-5,38168 00122031 01,/j,00,:, ,Kevin's Truck Sonoma,231000------
LIST 07,KE6FRA-14,37007400122020701,LK,,?, ,.3,031107,,*02,181017------
LIST 08,W6HMC,36361000121419601,/-,,4, ,Thanks for Supportin,3130--------
LIST 09,WB6AHC-1,37131000121511001,/_,,6, ,p000P000h65b10204tU2,259000060000
LIST 10,KA6DWN-9,37404700121536301,/>,02,:, ,,129035------
LIST 11,N6TBQ,------0--------0-,  ,,6, ,p001P001h81b10173wU2,358000055000
LIST 12,N6ZOZ,36592000122018101,/j,02,:, ,CQ 144.390 100Hz Ton,283014------
LIST 13,W6CO-5,38220000122250001,/#,,4,N,W6CO Systems - SARS ,2736--------
LIST 14,N6RZR-3,40361000122390001,/#,,4,S,Wn,NCAn/APRS Digi Sh,5810--------
LIST 15,WA6YLB-12,36178900119155201,/j,02,:, ,,000023------
LIST 16,K6TJS-1,36089200120101201,/v,,7, ,odd's work mobile {U,323070------
LIST 17,KI6ETL-9,37226100121565501,/j,02,9, ,,103008------
LIST 18,K6FAA-9,37534400121144701,/k,,7, ,,000000------
LIST 19,WA6USI,38359500121296601,/_,,6, ,OD1w,301000075073
LIST 20,KE6GLA-14,38409700121007501,/k,01,:, ,Using Voice Alert 10,141000------
LIST 21,KF6HJO-5,36323800119409701,/>,01,8, ,,180056------
LIST 22,KC6SUS,37577900121255501,/',01,9, ,,045021------
LIST 23,KG6QPT,------0--------0-,  ,,6, ,p000P000h..b.....tU2,332000053000
LIST 24,N5CV-2,37375400121527901,/>,,7, ,A=000324,358056------
LIST 25,K6MMG-1,37580500122222801,/s,,7, ,11.6V 29CTunapalooza,221000------
LIST 26,K6MZ,37262500122096301,/k,00,8, ,TinyTrak3,137000------
LIST 27,AA6AV,38197500122191401,/x,,4, ,ASTIR-Linux,3030--------
LIST 28,K6DKH-1,37415200122083901,/>,01,:, ,Lstng-146.640 PL-162,308050------
LIST 29,W6CX-3,37489400122037301,/#,,4,S,W2,NCAn/Rocky Ridge/,7450--------
LIST 30,KD6NIG-8,38424400121184901,/v,00,8, ,,331011------
LIST 31,AF6JP-5,37490100121172401,/>,04,:, ,,258000------
LIST 32,N6OIM-12,38398500121149701,/j,02,8, ,,269032------
LIST 33,SHASTA,41132900122142701,/#,,4,S,W3, K6SIS-3 NEAR DUN,5800--------
LIST 34,KF6TYS-7,38274500122434101,/-,02,:, ,Mark's D700 & GPS3+,000000------
LIST 35,KE6STH,37249100121514601,/j,02,:, ,1287.20- 88.5 /145.2,058035------
LIST 36,DANAHR,38446500120400801,/?,05,:, ,AG6AU: CALFIRE Publi,000000------
LIST 37,KE6YJC-7,36311000119473901,K,02,:, ,=,090035------
LIST 38,KG6QVB-2,37453100121206101,/k,02,:, ,145.550 simplex KG6Q,002064------
LIST 39,KG6PPD-8,37213300122048801,/_,,6, ,OU2k,340000063000
LIST 40,K4RJS-5,37245200121507701,k,01,8, ,,000000------

It’s a pretty small step from here to plotting their positions on a Google or Yahoo map. If I get some time, you can expect to see that soon.

Fun stuff.

[tags]Amateur Radio, APRS, Kenwood TH-D7A[/tags]

Addendum: A pass of the amateur satellite GO-32 just concluded, and I managed to pick up a couple of APRS packets from it. As recorded in my TH-D7A..

ID TH-D7G
LIST 01,4XTECH-12,------0--------0-,  ,,2, ,Sat Nov 03 17:57:55 ,------------
LIST 02,W7KKE,45006700124003501,/-,05,:, ,D-700 jpole Lincoln ,000000------

4XTECH-12 is the transponder aboard the satellite. W7KKE is a ham in Lincoln City, Oregon.

Modifying my program in a trivial way allowed me to dump the message buffers (the TH-D7A stores the last 16 messages it receives via APRS). This includes some more messages from the GO-32 satellite, and surprisingly a message from PCSAT-1. PCSAT-1 is also known as NO-44. It was passing to the west just as GO-32 was setting, so I hastily reconfigured the radio to talk to it, and I could hear it, but I didn’t think I decoded anything from it. Neat!

AMSG B,PCSAT-1,Look for dual hop paths and other experiments,4
AMSG B,4XTECH-12,D7&D700 posits use 145.9s,3
AMSG B,4XTECH-12,su APRS!!Use pth via 4XTECH,1
AMSG 0,K6MMG-1,g,1
AMSG B,4XTECH-12,D7&D700 posits use 145.93,3
AMSG B,4XTECH-12,APRS msgs and clients use 145.85 Upl,2
AMSG B,4XTECH-12,cu APRS!!Use pth via 4XTECH,1