-
Notifications
You must be signed in to change notification settings - Fork 2
/
alaskanets
executable file
·350 lines (287 loc) · 11.4 KB
/
alaskanets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
#!/usr/bin/perl
# (c) 2023 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/alaskanets
#
use POSIX qw(strftime);
use Getopt::Long;
my $HAMLIB="/usr/local/src/HamRadio/Hamlib";
my $RIGCTLp="$HAMLIB/tests/.libs/rigctl";
my $LDP="LD_PRELOAD=$HAMLIB/src/.libs/libhamlib.so.4";
my $RIGCTL="$LDP $RIGCTLp";
my $PROG=$0;
my %nets;
my %rigs;
my $verbose, $help, $usage, $arg;
## The rigs we can use => hamlib rig number, device to use, optional args for rigctl
%{$rigs{"FTdx10"}} = ( "model" => 1042, "dev" => "/dev/ftdx10" );
%{$rigs{"FT-817"}} = ( "model" => 1020, "dev" => "/dev/digirig", "opts" => "-P RTS" );
## The 'Nets we can access
%{$nets{"akerc"}} = ( "rig" => "FTdx10", # The name of the rig that can use this 'Net
"freq" => 14292000, # The Frequency of the 'Net
"mode" => "USB", # Which modulation mode to use
"pbf" => 0, # the passband filter width for the mode, 0 uses mode default
"nb" => 0, # Noise Blanker depth (0=off, range dependent on rig)
"nr" => 0.1, # (Digital) Noise Reduction depth (0=off, range dependent on rig)
"rfil" => 2, # Roofing filter width to use (values rig dependent)
"preamp" => 10, # What preamp level to use (values rig dependent)
"starts" => "0830", # 24h clock, aka military time
"days" => "MTWRF", # s'U'nday, M, T, W, thu'R'sday, F, S
"desc" => "Alaska Pacific Emergency Preparedness Net (ERC)", # The description of the 'Net
);
%{$nets{"oldtime"}} = ( "rig" => "FTdx10", "freq" => 3920000, "mode" => "LSB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "1200", "days" => "MTWRF",
"desc" => "Old Timers ragchew net" );
%{$nets{"snipers"}} = ( "rig" => "FTdx10", "freq" => 3920000, "mode" => "LSB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "1800", "days" => "UMTWRFS",
"desc" => "Alaska Snipers Net" );
%{$nets{"pacsea"}} = ( "rig" => "FTdx10", "freq" => 14300000, "mode" => "USB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "1800", "days" => "UMTWRFS",
"desc" => "Pacific Seafarers Net" );
%{$nets{"bush"}} = ( "rig" => "FTdx10", "freq" => 7093000, "mode" => "LSB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "2000", "days" => "UMTWRFS",
"desc" => "Alaska Bush Net" );
%{$nets{"motley"}} = ( "rig" => "FTdx10", "freq" => 3933000, "mode" => "LSB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "2100", "days" => "UMTWRFS",
"desc" => "Alaska Motley Net, by KL7G" );
%{$nets{"swap"}} = ( "rig" => "FTdx10", "freq" => 3920000, "mode" => "LSB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "1000", "days" => "S",
"desc" => "Alaska Swap Net- WL7PM" );
%{$nets{"erc-hf"}} = ( "rig" => "FTdx10", "freq" => 3880000, "mode" => "LSB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "2030", "days" => "U",
"desc" => "ERC on 80m" );
%{$nets{"emergency"}} = ( "rig" => "FTdx10", "freq" => 5167500, "mode" => "USB", "pbf" => 0,
"nb" => 0, "nr" => 0.1, "rfil" => 2, "preamp" => 10,
"starts" => "1000", "days" => "S",
"desc" => "AK emergency band - testing net on last saturday of month" );
## FT-817
%{$nets{"morning"}} = ( "rig" => "FT-817", "freq" => 145500000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "0", "tone" => 0,
"starts" => "1000", "days" => "UMTWRFS",
"desc" => "Alaska Morning Net" );
%{$nets{"erc-vhf"}} = ( "rig" => "FT-817", "freq" => 147330000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "+", "tone" => 103.5,
"starts" => "1930", "days" => "U",
"desc" => "ERC Net" );
%{$nets{"noname"}} = ( "rig" => "FT-817", "freq" => 146430000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "simplex", "tone" => 0,
"starts" => "2000", "days" => "U",
"desc" => "NoName Net, also MatSu Elmers" );
%{$nets{"vnnet1"}} = ( "rig" => "FT-817", "freq" => 146580000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "simplex", "tone" => 0,
"starts" => "2000", "days" => "M",
"desc" => "Valley North Net (simplex)" );
%{$nets{"vnnet2"}} = ( "rig" => "FT-817", "freq" => 147120000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "+", "tone" => 0,
"starts" => "2000", "days" => "M",
"desc" => "Valley North Net (repeater)" );
%{$nets{"grand"}} = ( "rig" => "FT-817", "freq" => 144200000, "mode" => "USB", "pbf" => 0,
"starts" => "0800", "days" => "M",
"preamp" => 10, "desc" => "Grandson of Sideband Net (NL7SK)" );
%{$nets{"south"}} = ( "rig" => "FT-817", "freq" => 146520000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "simplex", "tone" => 0,
"starts" => "1900", "days" => "W",
"desc" => "SouthCentral simplex" );
%{$nets{"parka"}} = ( "rig" => "FT-817", "freq" => 147300000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "+", "tone" => 141.3,
"starts" => "1900", "days" => "R",
"desc" => "Parka Net (repeater)" );
%{$nets{"ares"}} = ( "rig" => "FT-817", "freq" => 147340000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "+", "tone" => 103.5,
"starts" => "1900", "days" => "R",
"desc" => "Ares Net (repeater)" );
%{$nets{"vhfup"}} = ( "rig" => "FT-817", "freq" => 144200000, "mode" => "USB", "pbf" => 0,
"starts" => "0930", "days" => "R",
"preamp" => 10, "desc" => "VHF Up Net (net control KL7H)" );
%{$nets{"tech"}} = ( "rig" => "FT-817", "freq" => 146790000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "-", "tone" => 100.0,
"starts" => "1730", "days" => "F",
"desc" => "Tech Net (ends 1930)" );
%{$nets{"swap-vhf"}} = ( "rig" => "FT-817", "freq" => 146790000, "mode" => "FM", "pbf" => 0,
"preamp" => 10, shift => "-", "tone" => 100.0,
"starts" => "1930", "days" => "F",
"desc" => "Swap Net" );
##########################################################################
sub set_net {
my $n=shift;
my $cmdlist;
# Set the Mode and bandwidth first
$cmdlist.=qq|M $nets{$n}{"mode"} $nets{$n}{"pbf"}\n|;
# Set the frequency after mode, so we don't run into offsetting
$cmdlist.=qq|F $nets{$n}{"freq"}\n|;
# next set repeater offset frequencies, if applicable
if ($nets{$n}{"mode"} eq "FM" || $nets{$n}{"mode"} eq "WFM") {
my $sf=0; my $sp=0; my $rshift="simplex";
if (defined($nets{$n}{"shift"})) {
$rshift = $nets{$n}{"shift"};
if ($rshift eq "simplex") {
$sf=0; $sp="0";
} elsif ( m/\+/,$rshift ) {
$sf = s/\+//,$rshift;
$sp = "+";
} elsif ( m/-/,$rshift ) {
$sf = s/-//,$rshift;
$sp = "-";
} else {
$sf=0; $sp="0"; # dunno what they wanted, but it wasn't clear
}
}
if ( $sp ne "0" && $sf == 0 ) {
# Automatic repeater offsets as follows
if ($nets{$n}{"freq"} >= 29500000 && $nets{$n}{"freq"} <= 29700000 ) {
$sf = 100000; $sp = "-";
} elsif ($nets{$n}{"freq"} >= 51620000 && $nets{$n}{"freq"} <= 539800000 ) {
$sf = 500000; $sp = "-";
} elsif ($nets{$n}{"freq"} >= 145200000 && $nets{$n}{"freq"} <= 146970000 ) {
$sf = 600000; $sp = "-";
} elsif ($nets{$n}{"freq"} >= 147000000 && $nets{$n}{"freq"} <= 147390000 ) {
$sf = 600000; $sp = "+";
} elsif ($nets{$n}{"freq"} >= 223850000 && $nets{$n}{"freq"} <= 224980000 ) {
$sf = 1600000; $sp = "-";
} elsif ($nets{$n}{"freq"} >= 440000000 && $nets{$n}{"freq"} <= 445000000 ) {
$sf = 5000000; $sp = "+";
} elsif ($nets{$n}{"freq"} >= 447000000 && $nets{$n}{"freq"} <= 450000000 ) {
$sf = 5000000; $sp = "-";
} elsif ($nets{$n}{"freq"} >= 1282000000 && $nets{$n}{"freq"} <= 12940000000 ) {
$sf = 12000000; $sp = "-";
} else {
$sf = 0; $sp = "0";
}
}
$cmdlist.=qq|O $sf\n|;
$cmdlist.=qq|R $sp\n|;
}
# Next we set the CTCSS tone
if (defined($nets{$n}{"tone"})) {
my $hz = $nets{$n}{"tone"} * 10;
$cmdlist.=qq|C $hz\n|;
}
if (defined($nets{$n}{"rfil"})) {
# Set the bandpass filter to 3khz
$cmdlist.=qq|L ROOFINGFILTER $nets{$n}{"rfil"}\n|;
# Set the preamp to "amp1"
$cmdlist.=qq|L PREAMP $nets{$n}{"preamp"}\n|;
}
if (defined($nets{$n}{"nb"})) {
# Check for noise blanking
if ($nets{$n}{"nb"} > 0) {
# Set the noise blanker level NB(1..10/1)
$cmdlist.=qq|L NB $nets{$n}{"nb"}\n|;
} else {
# Disable the noise blanker
$cmdlist.=qq|L NB 0\n|;
}
}
if (defined($nets{$n}{"nr"})) {
# Check for noise reduction
if ($nets{$n}{"nr"} > 0) {
# Set the DNR to level 1 ( NR(0..1/ 0, .1, .15, .2 ...)
$cmdlist.=qq|L NB $nets{$n}{"nr"}\n|;
$cmdlist.=qq|U NR 1\n|;
} else {
# Disable the digital noise reducer
$cmdlist.=qq|U NR 0\n|;
}
}
# Lastly, figure out which rig to send it to, and push the configs!
my $r=$nets{$n}{"rig"};
# print( qq^bash -c "$RIGCTL -r $rigs{$r}{'dev'} -m $rigs{$r}{'model'} $rigs{$r}{"opts"} <(($cmdlist)) \n" ^ );
system( qq^bash -c "echo '$cmdlist' | $RIGCTL -r $rigs{$r}{'dev'} -m $rigs{$r}{'model'} $rigs{$r}{"opts"} - \n" ^ );
}
sub pweek {
$_ = shift;
my $s;
if (m/U/) { $s = "U"; } else {$s = ".";}
if (m/M/) { $s .= "M"; } else {$s .= ".";}
if (m/T/) { $s .= "T"; } else {$s .= ".";}
if (m/W/) { $s .= "W"; } else {$s .= ".";}
if (m/R/) { $s .= "R"; } else {$s .= ".";}
if (m/F/) { $s .= "F"; } else {$s .= ".";}
if (m/S/) { $s .= "S"; } else {$s .= ".";}
return $s;
}
sub dsum {
$_ = shift;
my $s=0;
if (m/U/) { $s += 7**7; }
if (m/M/) { $s .= 7**6; }
if (m/T/) { $s .= 7**5; }
if (m/W/) { $s .= 7**4; }
if (m/R/) { $s .= 7**3; }
if (m/F/) { $s .= 7**2; }
if (m/S/) { $s .= 7**1; }
# print "dbg: $s\n";
return ($s * 10000);
}
sub istoday {
$_ = shift;
my $dow = (localtime)[6];
my $ret = 0;
if ( $dow == 0 && m/U/ ) { $ret = 1; }
if ( $dow == 1 && m/M/ ) { $ret = 1; }
if ( $dow == 2 && m/T/ ) { $ret = 1; }
if ( $dow == 3 && m/W/ ) { $ret = 1; }
if ( $dow == 4 && m/R/ ) { $ret = 1; }
if ( $dow == 5 && m/F/ ) { $ret = 1; }
if ( $dow == 6 && m/S/ ) { $ret = 1; }
return $ret;
}
sub usage {
printf("usage: ${PROG} [-v] [-h] [net]\n");
print "\t -v verbosely show all nets, instead of just for today\n";
print "\t -h this help\n";
}
sub displaynets {
if ($verbose) {
printf(" net can be:\n");
} else {
printf(" net for today can be:\n");
}
foreach my $rig (sort keys %rigs) {
if ( -e $rigs{$rig}{"dev"} && -R _ ) {
printf("\n\t%s:\n", $rig );
foreach my $net (sort {
(
dsum($nets{$b}{"days"}) + (2400 - $nets{$b}{"starts"})
<=>
dsum($nets{$a}{"days"}) + (2400 - $nets{$a}{"starts"})
)
} keys %nets) {
printf("\t%10s (%8.04f MHz %3.3s) - %0.04d (%s) - %s\n", $net, $nets{$net}{"freq"} / 1000000, $nets{$net}{"mode"},
$nets{$net}{"starts"}, pweek($nets{$net}{"days"}), $nets{$net}{"desc"} )
if ( $nets{$net}{"rig"} eq $rig && ($verbose || istoday($nets{$net}{"days"}))) ;
}
}
}
printf("\n");
}
############################################################
#Get the options from the command line.
GetOptions(
"v!" => \$verbose,
"h!" => \$help,
);
$arg = $ARGV[0];
if ( $help ) {
usage;
exit 1;
}
if ( ! $arg ) {
displaynets;
exit 0;
}
# print STDERR (join("|",@ARGV),"\n");
if (defined($nets{$arg})) {
set_net($arg);
} else {
print "ERROR: no such net\n";
}
printf("\n");