1
|
#!/usr/bin/perl
|
2
|
|
3
|
use Data::Dumper;
|
4
|
use Config::Tiny;
|
5
|
|
6
|
use strict;
|
7
|
use warnings;
|
8
|
|
9
|
my $config = Config::Tiny->read('./astra_28.2e.ini');
|
10
|
my @data;
|
11
|
|
12
|
foreach my $section (keys %{$config}) {
|
13
|
next until $section eq 'DVB';
|
14
|
foreach my $parameter (keys %{$config->{$section}}) {
|
15
|
my ($frequency, $polarisation, $symbolrate, $fec, $standard, $modulation) = split(',', $config->{$section}->{$parameter});
|
16
|
next if not defined($modulation);
|
17
|
push @data, { frequency => $frequency, polarisation => $polarisation, symbolrate => $symbolrate, fec => $fec, standard => $standard, modulation => $modulation };
|
18
|
}
|
19
|
}
|
20
|
|
21
|
my @sorteddata = sort { $a->{frequency} <=> $b->{frequency} } @data;
|
22
|
|
23
|
# Use our sorteddata to write out a line that looks like this for each entry: S2 10891250 H 22000000 3/4 AUTO 8PSK
|
24
|
|
25
|
foreach my $entry (@sorteddata) {
|
26
|
# chomp the 'DVB-' from the standard
|
27
|
(my $standard = $entry->{standard}) =~ s/DVB-//g;
|
28
|
# multiply the frequency by 1000
|
29
|
my $frequency = $entry->{frequency} * 1000;
|
30
|
my $polarisation = $entry->{polarisation};
|
31
|
# multiply the symbolrate by 1000
|
32
|
my $symbolrate = $entry->{symbolrate} * 1000;
|
33
|
# split the fec into it's two parts unless it's auto
|
34
|
my $fec;
|
35
|
if ($entry->{fec} =~ m/Auto/) {
|
36
|
$fec = 'AUTO';
|
37
|
} else {
|
38
|
$entry->{fec} =~ m/(\d)(\d)/;
|
39
|
$fec = join('/',$1,$2);
|
40
|
}
|
41
|
# strip anything we don't want from the modulation
|
42
|
$entry->{modulation} =~ m/([\w\d]*).*/;
|
43
|
my $modulation = $1;
|
44
|
|
45
|
print "$standard $frequency $polarisation $symbolrate $fec\n";
|
46
|
}
|