-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdr_power.php
29 lines (29 loc) · 950 Bytes
/
sdr_power.php
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
<?php
sleep(60);
exec('tail -1 /root/rtlamr.out',$result);
if (!empty(str_getcsv(implode($result))[7])) {
$prev = str_getcsv(implode($result))[7]; }
$curr = $prev;
while ( $prev == $curr) {
sleep(1);
$prev = $curr;
unset($result);
exec('tail -1 /root/rtlamr.out',$result);
# echo implode($result)."\n";
if (!empty(str_getcsv(implode($result))[7])) {
$curr = str_getcsv(implode($result))[7]; }
# echo $prev . " " . $curr . "\n";
}
exec("pkill -SIGHUP -f \"/usr/local/bin/power -g 13\"");
sleep(2);
$old = file_get_contents("/user1/power/power13.txt");
$curr = $curr + 100000;
file_put_contents("/user1/power/power13.txt", $curr."000");
exec("pkill -SIGUSR1 -f \"/usr/local/bin/power -g 13\"");
#exec("pkill -SIGTERM -x rtl_tpc");
$msg = "logger \"Wrote new house power: New = ".$curr."000, Old = ".$old."\"";
exec($msg);
$delta = ($curr * 1000) - $old;
$msg = "logger \"House Power delta: ".$delta."\"";
exec($msg);
?>