#!/usr/bin/perl -w # # clone-receive # John Simpson 2005-08-01 # # reads data from an Alinco DJ-296T radio when it sends cloning data # ############################################################################### # # Copyright (C) 2005 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### require 5.003 ; use strict ; use Serial ; my $device = "/dev/cu.USA19QWb232P1.1" ; ############################################################################### # # debugging function my $do_debug = 0 ; sub debug($) { $do_debug && print STDERR $_[0] ; } ############################################################################### ############################################################################### ############################################################################### # # figure out where we're writing the output my $outfile = ( shift || "-" ) ; open ( O , ">$outfile" ) or die "Can\'t create $outfile: $!\n" ; ############################################################################### # # open the port system "stty -f $device 9600 cs8 -parenb -cstopb -crtscts raw" ; openport ( $device ) ; while ( my $line = recvline() ) { $line =~ s/^OK// ; debug "RECV\t$line\n" ; print O "$line\n" ; debug "SEND\tOK\n" ; sendline ( "OK" ) ; last if ( $line eq "AL~E" ) ; } closeport() ; close O ;