# because I have the 'power of perl' available that avoids me getting
# terminally bored sorting out other people's sloppyness.
#
# because I have the 'power of perl' available that avoids me getting
# terminally bored sorting out other people's sloppyness.
#
- dbg('err', "AGW initialising and connecting to $addr/$port ...");
- $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>15);
+
+ dbg("AGW initialising and connecting to $addr/$port ...");
+ $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>3);
+ $lastconnect = $main::systime;
Msg->sleep(2);
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
$sock->close;
Msg->sleep(2);
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
$sock->close;
}
push @outqueue, pack('C x3 a1 x1 C x1 a10 a10 V x4 a*', $port, $sort, $pid, $from, $to, $len, $data);
Msg::set_event_handler($sock, write=>\&_send);
}
push @outqueue, pack('C x3 a1 x1 C x1 a10 a10 V x4 a*', $port, $sort, $pid, $from, $to, $len, $data);
Msg::set_event_handler($sock, write=>\&_send);
$bytes_read = sysread ($sock, $msg, 1024, 0);
if (defined ($bytes_read)) {
if ($bytes_read > 0) {
$bytes_read = sysread ($sock, $msg, 1024, 0);
if (defined ($bytes_read)) {
if ($bytes_read > 0) {
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
$data = '' unless defined $data;
if ($sort eq 'D') {
my $d = unpack "Z*", $data;
$data = '' unless defined $data;
if ($sort eq 'D') {
my $d = unpack "Z*", $data;
my $conn = _find($from eq $main::mycall ? $to : $from);
if ($conn) {
if ($conn->{state} eq 'WC') {
if (exists $conn->{cmd}) {
if (@{$conn->{cmd}}) {
my $conn = _find($from eq $main::mycall ? $to : $from);
if ($conn) {
if ($conn->{state} eq 'WC') {
if (exists $conn->{cmd}) {
if (@{$conn->{cmd}}) {
- my @lines = split /\cM/, $data;
- if (@lines) {
- for (@lines) {
- &{$conn->{rproc}}($conn, "I$conn->{call}|$_");
- }
- } else {
- &{$conn->{rproc}}($conn, "I$conn->{call}|");
+ my @lines = split /\cM\cJ?/, $d;
+ push @lines, $d unless @lines;
+ for (@lines) {
+ &{$conn->{rproc}}($conn, "I$conn->{call}|$_");
}
} elsif ($sort eq 'I' || $sort eq 'S' || $sort eq 'U' || $sort eq 'M' || $sort eq 'T') {
my $d = unpack "Z*", $data;
}
} elsif ($sort eq 'I' || $sort eq 'S' || $sort eq 'U' || $sort eq 'M' || $sort eq 'T') {
my $d = unpack "Z*", $data;
- s/([\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
- dbg('agw', "AGW Monitor port: $port \"$_\"");
+# s/([\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
+ dbg("AGW Monitor port: $port \"$_\"") if isdbg('agw');
- if ($call =~ /^(\w+)-(\d\d?)$/) {
- my $c = $1;
- my $s = $2;
- $s = 15 - $s;
- if ($s <= 8 && $s > 0) {
- $call = "${c}-${s}";
- } else {
- $call = $c;
- }
+ if (my ($c, $s) = $call =~ /^(\w+)-(\d\d?)$/) {
+ $s = 15 - $s if $s > 8;
+ $call = $s > 0 ? "${c}-${s}" : $c;
}
$conn->to_connected($call, 'A', $conn->{csort} = 'ax25');
}
} elsif ($sort eq 'd') {
my $d = unpack "Z*", $data;
}
$conn->to_connected($call, 'A', $conn->{csort} = 'ax25');
}
} elsif ($sort eq 'd') {
my $d = unpack "Z*", $data;
my $conn = _find($from);
$conn->{oframes} = $frames if $conn;
} elsif ($sort eq 'Y') {
my ($frames) = unpack "V", $data;
my $conn = _find($from);
$conn->{oframes} = $frames if $conn;
} elsif ($sort eq 'Y') {
my ($frames) = unpack "V", $data;
my $conn = _find($from eq $main::mycall ? $to : $from);
$conn->{oframes} = $frames if $conn;
} elsif ($sort eq 'H') {
unless ($from =~ /^\s+$/) {
my $d = unpack "Z*", $data;
my $conn = _find($from eq $main::mycall ? $to : $from);
$conn->{oframes} = $frames if $conn;
} elsif ($sort eq 'H') {
unless ($from =~ /^\s+$/) {
my $d = unpack "Z*", $data;
}
} elsif ($sort eq 'X') {
my ($r) = unpack "C", $data;
$r = $r ? "Successful" : "Failed";
}
} elsif ($sort eq 'X') {
my ($r) = unpack "C", $data;
$r = $r ? "Successful" : "Failed";
} elsif ($sort eq 'G') {
my @ports = split /;/, $data;
$noports = shift @ports || '0';
} elsif ($sort eq 'G') {
my @ports = split /;/, $data;
$noports = shift @ports || '0';
}
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i);
}
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i);
# _sendf('Y', $main::mycall, $conn->{call}, $conn->{agwport}, $conn->{agwpid});
_sendf('D', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid}, $msg . $conn->{lineend});
my $len = length($msg) + 1;
# _sendf('Y', $main::mycall, $conn->{call}, $conn->{agwport}, $conn->{agwpid});
_sendf('D', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid}, $msg . $conn->{lineend});
my $len = length($msg) + 1;
if ($ypolltime && $main::systime - $lastytime >= $ypolltime) {
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i );
if ($ypolltime && $main::systime - $lastytime >= $ypolltime) {
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i );