forked from timleland/rfoutlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathledCtrl.pl
More file actions
executable file
·35 lines (32 loc) · 876 Bytes
/
Copy pathledCtrl.pl
File metadata and controls
executable file
·35 lines (32 loc) · 876 Bytes
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
#!/usr/bin/perl
$sndir = "/var/www/rfoutlet";
$bldir = "/home/matsushi/IoT/Etekcity/wiringPi/examples";
$rfs = "$sndir/RFSniffer";
$bl = "$bldir/blinkRGB";
$led = 0;
$brPid;
while (1) {
open(SN, "$rfs 1 2>&1 |") or die "Cannot start $rfs: $?";
while (<SN>) {
printf("%d: %s", SN, $_);
if (m/275715/) {
if ($led == 0) {
if ($brPid = fork()) {
# parent process
printf("blinkRGB(pid=%d) is started.\n", $brPid);
$led++;
} else {
# child process
exec("$bl");
}
}
}
if (m/275724/) {
if ($led == 1) {
printf("blinkRGB (pid=%d) stopped.\n", $brPid);
kill(9,$brPid);
$led = 0;
}
}
}
}