[Dxspider-support] DX-Spider & CLX
Bill Shell
n6ws at charter.net
Tue Jun 25 05:23:44 BST 2002
Filip,
I got home a little late to try this tonight. I had to re-edit the file
since it had a line-wrap problem being transmitted as text. The file is at:
http://webpages.charter.net/n6ws/files/ct_server.pl
I have to add the password since I have security turned on for the DX-Spider
node. I'll have time to add the login and password for the telnet tomorrow
night.
Thanks again,
Bill
-----Original Message-----
From: dxspider-support-admin at dxcluster.org
[mailto:dxspider-support-admin at dxcluster.org]On Behalf Of Filip Jonckers
Sent: Monday, June 24, 2002 12:10 PM
To: dxspider-support at dxcluster.org
Subject: RE: [Dxspider-support] DX-Spider & CLX
As promised...
here is the modified script we use
it's the original CLX script but slightly modified for spider use
hope this works.. it's not coming from the cluster but
from my development archive
(cannot access the cluster at this time)
you should check the IP broadcast address used and the port numbers
the CT user can open a packet window and type cluster commands...
Filip
on1afn
------------------
#!/usr/bin/perl
#
use strict;
use IO::Socket;
use IPC::Open2;
use constant VERBOSE => 1; ### DEBUGGING SWITCH ###
use constant BUFLEN => 2048;
# defaults
my $node = shift || 'xx0xx'; # cluster node callsign
- first parameter when called by clx
my $mycall = shift || 'xx0xx'; # user callsign
my $bcaddr = shift || '192.168.254.255'; # CT network udp
broadcast address
my $port = shift || 9870; # CT network udp port
my $station = shift || 15; # CT network station id
(1-15)
# open a bidirectional pipe to net_usr
my $in = 0;
my $out = 0;
my $pid = open2(*in,*out,"telnet 127.0.0.1 9000") || die "Cannot open2()
$!";
# open UDP socket to CT clients
my $sock = IO::Socket::INET->new(Proto=>'udp',
Type=>SOCK_DGRAM,
LocalPort=>$port,
PeerAddr=>"$bcaddr:$port")
or die $@;
# fork child process
my $child = fork();
die "can't fork child process: $!" unless defined $child;
tx_data(*in,$sock,$child) unless $child;
rx_data(*out,$sock) if $child;
sub tx_data {
# parse params
my ($in,$sock,$child) = @_;
print "TX started\n" if VERBOSE;
# wait for data coming from net_usr process
while(<$in>) {
chomp;
# create CT udp packet
my $ct = 'B' . chr($station + 48) . $_;
# add checksum byte
my $checksum = unpack("%32C*",$ct);
$checksum |= 0x80;
$checksum &= 0xFF;
$ct .= chr($checksum) . "\n";
# send CT udp packet
$sock->send($ct) || die "send(): $!";
print "CT msg broadcast:$ct\n" if VERBOSE;
}
kill 'TERM',$child;
}
sub rx_data {
# parse params
my ($out,$sock) = @_;
print "RX started\n" if VERBOSE;
# wait for data coming from CT clients
my $buffer='';
while(1) {
my $from = recv($sock,$buffer,BUFLEN,0) or next;
chomp($buffer);
# check checksum if packet is valid
my $checksum = ord(substr($buffer,-1));
my $chkdata = substr($buffer,0,-1);
my $calc = unpack("%32C*",$chkdata);
$calc |= 0x80;
$calc &= 0xFF;
my $chk = ($calc ne $checksum) ? 'nok' : 'ok';
# extract additional data
my $type = substr($buffer,0,1);
my $stn = ord(substr($buffer,1,1))-48;
my $data = substr($buffer,2,-1);
if (VERBOSE) {
my ($port,$ip) = unpack_sockaddr_in($from);
$ip = inet_ntoa($ip);
print "$ip:$port type=$type station=$stn [$data]
checksum=$chk\n";
}
# send data if CT packet is for cluster (type A)
if ($type eq 'A' && $calc eq $checksum) {
print $out "$data\n";
print "** data send to cluster **\n" if VERBOSE;
}
}
}
_______________________________________________
Dxspider-support mailing list
Dxspider-support at dxcluster.org
http://www.tobit.co.uk/mailman/listinfo/dxspider-support
More information about the Dxspider-support
mailing list