Yaesu FT-8xx CAT perl module
by trixter on Aug.29, 2009, under Yaesu FT-897
Update: August 29, 2009 – I added some undocumented commands, their syntax is at the end of this page.
This is a perl module that extends Win32::SerialPort or Device::SerialPort depending on what platform you run it on. This means that it should work in Windows, Linux, BSD, OSX, Solaris and probably elsewhere.
The idea is to be able to let people quickly develop cross platform tools without having to know anything about serial ports, the CAT protocol, or any of that. Fortunately, since I dont know much about it, and got really lucky by closing my eyes and randomly pressing the keys on the keyboard.
This provides every documented CAT command in the FT-897 manual. I will be adding undocumented commands in the near future. I will also be looking at ways to read values out of the EEPROM to give you information that is not available any other way.
The problem with reading the EEPROM is that it is at least radio specific (the FT897 and FT-857 should be identical though, but the FT-817 will be different). I am thinking that I will create maps of the various points of data and when you create a new instance of this module you will specify your model which will have the correct map. That should allow the code to be used by people with other radios, although I only have an FT897 to test, unless someone wants to donate an FT-817 for testing
Currently the only documentation is on this page. So download FT8xxCAT.pm and read below to see how to use it. This is my first perl module, I know that the code needs to be cleaned a bit, and that it can be slightly faster in some places, but I wanted to get it working first.
#!/usr/bin/perl
use FT8xxCAT;my $Radio = new FT8xxCAT (
serialdev => ‘/dev/ttyUSB0′,
bpsrate => 38400
);my $debug = $Radio->setDebug(1);
print “Current debug status is $debug\n”;my $errorstr = $Radio->getError(); # does not erase
my $errorstr = $Radio->clearError(); # erases it
#my $err = $Radio->lock();
my $err = $Radio->unlock();
my $err = $Radio->pressPTT();
my $err = $Radio->releasePTT();
my $err = $Radio->setFrequency(12345670); # 123.4567MHz
my $err = $Radio->setMode(“fm”);
# valid modes lsb, usb, cw, cwr, am, fm, dig, pkt, fmn
my $err = $Radio->enableClarifier();
my $err = $Radio->disableClarifier();
my $err = $Radio->setClarifier(“+123″); # 1.23kHz
my $err = $Radio->toggleVFO();
my $err = $Radio->enableSplit();
my $err = $Radio->disableSplit();
my $err = $Radio->repeaterOffset(“+”); # + – 0
my $err = $Radio->repeaterOffsetFrequency(600000); # 600kHz
my $err = $Radio->toneMode(“CTCSS_ENCODE”);
# valid modes ‘off’ ‘dcs_on’ ‘dcs_decode’ ‘dcs_encode’
# ‘ctcss_on’ ‘ctcss_decode’ ‘ctcss_encode’
my $err = $Radio->setCTCSSTone(885,1230); # 88.5 / 123.0
my $err = $Radio->setDCSTone(23,371); # 023, 371 – leading ’0′s make it octal
my %resp = $Radio->getRxStatus();
print “Squelch: $resp{‘squelch’}\n”;
print “Tone: $resp{‘tone’}\n”;
print “Centered: $resp{‘discriminator’}\n”;
print “S-Meter: $resp{‘smeter’}\n”;
my %resp = $Radio->getTxStatus();
if($resp{‘ptt’}) {
print “PTT: $resp{‘ptt’}\n”;
print “Hi SWR: $resp{‘hi_swr’}\n”;
print “Split: $resp{‘split’}\n”;
print “Power Meter: $resp{‘po_meter’}\n”;
} else {
print “Not transmitting – or error\n”;
}
my %resp = $Radio->getFrequency();
if($resp{‘frequency’}) {
print “Frequency: $resp{‘frequency’}\n”;
print “Mode: $resp{‘mode’}\n”;
} else {
print $Radio->clearError().”\n”;
}### UNDOCUMENTED COMMANDS – THEY MAY OR MAY NOT WORK FOR YOU, SOME REQUIRE CAUTION WHEN USING
my $undocumented = $Radio->setUndocumented(1);
print “Undocumented commands status is $undocumented\n”;my $resp = $Radio->getTxState();
print “Tx state is $resp\n”;my $msb=0;
my $lsb=0;
my $resp=$Radio->readEeprom($msb,$lsb);
printf “%02x:%02x %s %s\n”,$msb,$lsb,
unpack(“H*”, substr($resp,0,1)),
unpack(“H*”, substr($resp,1,1));my $msb=0;
my $lsb=0;
my $data1=0xa5;
my $data2=0x5a;
# “We must be cautious” – Obi Wan
#my $resp=$Radio->writeEeprom($msb,$lsb,$data1,$data2);
print $resp;# this command seems to return different results
# on a FT-817 vs FT-897
my $resp = $Radio->getRadioConfig();
print unpack(“H*”,$resp).”\n”;my %resp = $Radio->getTxMetering();
printf “pwr: %02x\n”,$resp{‘pwr’};
printf “vswr: %02x\n”,$resp{‘vswr’};
printf “alc: %02x\n”,$resp{‘alc’};
printf “mod: %02x\n”,$resp{‘mod’};# “Luke: What’s in there?
# Yoda: Only what you take with you.”
# IF YOU DO NOT HAVE A BACKUP OF YOUR CALIBRATION SETTINGS
# YOU WILL NOT HAVE A CALIBRATED RADIO. IT WILL UNDERPERFORM
# YOU HAVE BEEN WARNED – THERE IS PROBABLY NO REASON TO EVER USE THIS
#my $resp = $Radio->factoryResetandEraseAlignment();
December 2nd, 2009 on 5:50 am
Does anyone know of a list of serial port codes a tuner would use with the 897/857 radios?
February 4th, 2010 on 3:10 am
Bill: I do not think tuners use the CAT command set. I think they use the TUN command set (which is totally different from what I know). I may be wrong on this, I have not looked at it. I have an LDG tuner and may investigate that a bit. I thought I read somewhere that the tuner stuff is based on a +12/-12 voltage but that may have just been for the ATAS antenna.
Basically the way tuners appear to work is:
1. turn transmit power down (5w normally) and mode (SSB doesnt work well for tuning purposes) – not all tuners do this!
2. the tuner adjusts L/C based on what it thinks it should be (some use memories to store the state of the relays so they can tune faster)
3. restore transmit power and mode
If you wanted to do this via CAT instead of the TUNE method you would have to read the current state for anything you are going to change (mode, tx power), then set them to what you need them to be for your tuner to operate (5w AM for example) and perform your tuning operation, then restore the state to what it was before you started.