Commit 620a1357 authored by Andrey Filippov's avatar Andrey Filippov

implemented lwir16.php daemon mode, added ini file

parent fffd658c
DOCUMENTROOT=$(DESTDIR)/www/pages/lwir16
OWN = -o root -g root
INSTDOCS = 0644
INSTEXE = 0755
SYSCONFDIR =/etc
CONFDIR = $(SYSCONFDIR)/elphel393
INSTALL = install
DOCS= index.html \
lwir16.php
DOCS= index.html
PHP_SCRIPTS_EXE=lwir16.php \
test_int.php \
test_wpipe.php \
test_ps.php
CONFIGS = lwir16.ini
all:
@echo "make all in src"
......@@ -11,6 +23,10 @@ install:
@echo "make install in src"
$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTEXE) $(PHP_SCRIPTS_EXE) $(DOCUMENTROOT)
$(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)
$(INSTALL) -d $(DESTDIR)$(CONFDIR)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(CONFIGS) $(DESTDIR)$(CONFDIR)
clean:
@echo "make clean in src"
ips = "192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45"
duration = 100
pre_delay = 5.0
ffc_period = 300.0
ffc_groups = 2
ffc_frames = 8
ffc = 1
debug = 1
# no spaces around commas!
CMD = INIT,START
\ No newline at end of file
This diff is collapsed.
#!/usr/bin/php
<?php
set_include_path ( get_include_path () . PATH_SEPARATOR . '/www/pages/include' );
include 'show_source_include.php';
include "elphel_functions_include.php"; // includes curl functions
$pipe_cmd="/tmp/pipe_cmd";
$pipe_response="/tmp/pipe_response";
$mode=0600;
declare(ticks = 1);
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
function signal_handler($signal) {
switch($signal) {
case SIGTERM:
print "Caught SIGTERM\n";
exit;
case SIGKILL:
print "Caught SIGKILL\n";
exit;
case SIGINT:
print "Caught SIGINT\n";
exit;
}
}
if(file_exists($pipe_cmd)){
unlink($pipe_cmd); //delete pipe if it was already there - waiting prevents signal handling!
}
while(1) {
if(file_exists($pipe_cmd)) {
//block and read from the pipe
$f = fopen($pipe_cmd,"r");
echo "(r) opened cmd\n";
$l = fgets($f);
fclose ($f);
echo "(r) closed cmd\n";
unlink($pipe_cmd); //delete pipe
echo "(r) deleted cmd\n";
if(!file_exists($pipe_response)) {
// create the pipe
umask(0);
posix_mkfifo($pipe_response,$mode);
}
$fr = fopen($pipe_response,"w");
fwrite($fr,"response1: ".$l);
fwrite($fr,"response2: ".$l);
fwrite($fr,"response3: ".$l);
echo "(r) sent responses\n";
sleep(1);
fclose ($fr);
echo "(r) closed response pipe\n";
}
//
}
?>
#!/usr/bin/php
<?php
print_r($argv);
set_include_path ( get_include_path () . PATH_SEPARATOR . '/www/pages/include' );
include 'show_source_include.php';
include "elphel_functions_include.php"; // includes curl functions
$name = 'test_ps.php'; // int.php';
$interpreter='php';
echo "\n--------- interpreter=$interpreter, name = $name ----------\n";
$arr = getPIDByName($name, $interpreter, $active_only=false);
// var_dump($arr);
print_r($arr);
$name = 'test_ps.php'; // 'php-cgi';
$interpreter='';
echo "\n--------- interpreter=$interpreter, name = $name ----------\n";
$arr = getPIDByName($name, $interpreter, $active_only=false);
// var_dump($arr);
print_r($arr);
$interpreter='python';
$name = 'tempmon.py';
echo "\n--------- interpreter=$interpreter, name = $name ----------\n";
$arr = getPIDByName($name, $interpreter, $active_only=false);
// var_dump($arr);
print_r($arr);
?>
#!/usr/bin/php
<?php
define('PIPE_CMD', '/tmp/pipe_cmd');
define('PIPE_RESPONSE', '/tmp/pipe_response');
define('PIPE_MODE', 0600);
set_include_path ( get_include_path () . PATH_SEPARATOR . '/www/pages/include' );
include 'show_source_include.php';
include "elphel_functions_include.php"; // includes curl functions
$cmd = 'STATUS';
$kw = 'CMD';
if (count($argv) > 2){
$kw = $argv[1];
$cmd = $argv[2];
} else if (count($argv) > 1){
$cmd = $argv[1];
}
$mode=0600;
if(!file_exists(PIPE_CMD)) {
// create the pipe
umask(0);
posix_mkfifo(PIPE_CMD,$mode);
}
if (file_exists(PIPE_RESPONSE)){
unlink(PIPE_RESPONSE); //delete old pipe
}
$f = fopen(PIPE_CMD,"w");
// sleep(1);
$cmds = $kw.' = '.$cmd."\n";
fwrite($f,$cmds);
// sleep (1);
echo "(w) sent commands:\n".$cmds."\n";
fclose ($f);
// sleep(1);
echo "(w) closed\n";
if ($cmd == 'STATUS') {
while (!file_exists(PIPE_RESPONSE)); // just wait
echo "(w) got PIPE_RESPONSE\n";
$fl = file(PIPE_RESPONSE);
var_dump($fl);
unlink(PIPE_RESPONSE); //delete pipe
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment