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

implemented lwir16.php daemon mode, added ini file

parent fffd658c
Loading
Loading
Loading
Loading
+18 −2
Original line number Original line Diff line number Diff line
DOCUMENTROOT=$(DESTDIR)/www/pages/lwir16
DOCUMENTROOT=$(DESTDIR)/www/pages/lwir16
OWN = -o root -g root
OWN = -o root -g root
INSTDOCS = 0644
INSTDOCS = 0644
INSTEXE =  0755

SYSCONFDIR   =/etc
CONFDIR      = $(SYSCONFDIR)/elphel393


INSTALL = install
INSTALL = install
DOCS=       index.html \
DOCS=       index.html
            lwir16.php
            
PHP_SCRIPTS_EXE=lwir16.php \
            test_int.php \
            test_wpipe.php \
            test_ps.php
CONFIGS = lwir16.ini            
            
all:
all:
	@echo "make all in src"
	@echo "make all in src"


@@ -11,6 +23,10 @@ install:
	@echo "make install in src"
	@echo "make install in src"
	$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
	$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
	$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(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:
clean:
	@echo "make clean in src"
	@echo "make clean in src"

src/lwir16/lwir16.ini

0 → 100644
+10 −0
Original line number Original line Diff line number Diff line
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
+699 −234

File changed.

Preview size limit exceeded, changes collapsed.

+57 −0
Original line number Original line Diff line number Diff line
#!/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";
        }
     //
   }
?>

src/lwir16/test_ps.php

0 → 100644
+27 −0
Original line number Original line Diff line number Diff line
#!/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);
    
?>
Loading