-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsa818-controller
52 lines (43 loc) · 1.08 KB
/
sa818-controller
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
#!/usr/bin/perl
#
use Time::HiRes qw(usleep);
use IO::File;
`/usr/local/bin/sa818 --port /dev/ttyAMA0 filters --emphasis yes --highpass yes --lowpass yes > /dev/null 2>&1`;
$ptt_port = "/tmp/ptt";
$logfile = "/var/log/trx.log";
$PTT = openPtty("$ptt_port"); # ptt port from SvxLink
while (1) {
# receive and send ptt state
$PTT->read($p, 1);
if ($p gt ' ') {
$message = $p;
if ($p eq "T") {
`/usr/bin/gpioset --bias=pull-down gpiochip0 16=0`;
&writelog("SA8x8 TX");
}
if ($p eq "R") {
`/usr/bin/gpioset --bias=pull-down gpiochip0 16=1`;
&writelog("SA8x8 RX");
`/usr/local/bin/sa818 --port /dev/ttyAMA0 filters --emphasis yes --highpass yes --lowpass yes > /dev/null 2>&1`;
&writelog("SA8x8 RESET FILTERS");
}
undef $p;
}
usleep(1000);
}
close($PTT);
exit;
sub openPtty {
my $fh = IO::File->new($_[0], O_NONBLOCK|O_RDWR);
if (!(defined $fh)) {
&writelog("Can not open $_[0]");
print "Can not open $_[0]\n";
return 0;
}
$fh->autoflush(1);
&writelog("opening $_[0] OK");
return $fh;
}
sub writelog {
print $_[0],"\n";
}