Commit 0d78d42e authored by Andrey Filippov's avatar Andrey Filippov

porting nc353 php files

parent df39fd1f
TARGETDIR=$(DESTDIR)/www/pages
all:
@echo "make all"
install:
@echo "make install"
clean:
@echo "make clean"
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/php_top # src1
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS = $(SUBDIRS:%=clean-%)
#TARGETDIR=$(DESTDIR)/www/pages
all: $(SUBDIRS)
@echo "make all top"
$(SUBDIRS):
$(MAKE) -C $@
install: $(INSTALLDIRS)
@echo "make install top"
$(INSTALLDIRS):
$(MAKE) -C $(@:install-%=%) install
clean: $(CLEANDIRS)
@echo "make clean top"
$(CLEANDIRS):
$(MAKE) -C $(@:clean-%=%) clean
.PHONY: all install clean $(SUBDIRS) $(INSTALLDIRS) $(CLEANDIRS)
#!/bin/bash
args="$@"
while (( "$#" )); do
shift
done
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Launching bitbake $args"
cd $DIR/../../poky
. ./oe-init-build-env
bitbake $args | sed -u 's@| @@'
exit 0
DOCUMENTROOT=$(DESTDIR)/www/pages
OWN = -o root -g root
INSTDOCS = 0644
INSTALL = install
DOCS= favicon.ico \
robots.txt
PHP_SCRIPTS=camvars.php \
ccam.php \
diag_utils.php \
framepars.php \
parsedit.php \
phpinfo.php
all:
@echo "make all in src"
install:
@echo "make install in src"
$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHP_SCRIPTS) $(DOCUMENTROOT)
clean:
@echo "make clean in src"
include $(AXIS_TOP_DIR)/tools/build/Rules.axis
OWN = -o root -g root
ROOT = $(prefix)
DOCUMENTROOT = $(prefix)/usr/html
ATTICROOT = $(prefix)/usr/html/attic
INCLUDES = $(prefix)/usr/html/includes
INSTDOCS = 0644
INSTEXE = 0755
DOCS= LICENSE
PHPSHELL= phpshell.php \
phpshell.css \
valid-xhtml10.png \
vcss.png
HTMLFILES= 10364.html \
focus.html \
robots.txt
##ATTICFILES - files that are not ported (or even needed with 8.x software)
ATTICFILES= camera_demo.php \
compressor.php \
demo_focus.php \
init354.php \
senspars.php \
ccam.php \
framepars.php \
syncmaster354.php \
syncslave354.php \
whitebalance.php \
demo_aexp.php \
camvars.php \
jhead.php
PHPSCRIPTS= 10364.php \
103641.php \
103697.php \
coring_filter_setup.php \
fpga.php \
diag_utils.php \
focus.php \
init347.php \
webcam.php \
mshutter.php \
mjpeg.php \
raw.php \
raw_demo.php \
webcam_adv.php \
parsedit.php \
phpinfo.php \
power347.php \
readparameter_demo.php \
setparameters_demo.php \
snapfull.php \
sync.php \
sync_other2this.php \
trig.php \
i2c.php \
paramtool.php \
tuneseq.php \
launcher.php \
index.php
PHPEXE= bdetect.php \
usb10369a.php \
detect_ioboard.php
PHPINCLUDES=i2c.inc show_source.inc
all:
install:
$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
$(INSTALL) $(OWN) -d $(INCLUDES)
$(INSTALL) $(OWN) -d $(ATTICROOT)
#install files
tar -xzf phpshell.tar.gz
$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHPSHELL) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHPSCRIPTS) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTEXE) $(PHPEXE) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHPINCLUDES) $(INCLUDES)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(HTMLFILES) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(ROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(ATTICFILES) $(ATTICROOT)
<?php
/*!*******************************************************************************
*! FILE NAME : camvars.php
*! DESCRIPTION: read/write camera internal variables by name
*! Copyright (C) 2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: camvars.php,v $
*! Revision 1.1.1.1 2008/11/27 20:04:03 elphel
*!
*!
*! Revision 1.2 2008/11/22 05:58:24 elphel
*! modifying to match elphel_set_P_value()
*!
*! Revision 1.2 2008/04/17 22:37:57 elphel
*! bug fix
*!
*! Revision 1.1 2008/03/22 04:41:07 elphel
*! Script to set/get camera parameters with HTTP GET (result as XML)
*!
*!
*/
if (count($_GET)==0) {
echo <<<USAGE
<p>This script returns camera variables as XML file, it also allows you to set those variables. Usually those changes will not take effect immediately - please use ccam.php that both changes variables and programs the camera to use them.</p>
<p>The variable names to be read are specified without values (like camvar.php?WOI_WIDTH&WOI_HEIGHT ), the ones to be written - with the values (camvar.php?QUALITY=75). It is also possible to mix both types in the same request.</p>
USAGE;
exit (0);
}
$toRead=array();
$toWrite=array();
foreach($_GET as $key=>$value) {
if ($value==="") $toRead[$key]=$value;
else $toWrite[$key]=(integer) $value;
}
$npars=(count($toWrite)>0)?elphel_set_P_arr($toWrite):0;
if (count($toRead)>0) $toRead=elphel_get_P_arr($toRead);
if ($_GET["STATE"]!==NULL) $toRead["STATE"]=elphel_get_state();
$xml = new SimpleXMLElement("<?xml version='1.0' standalone='yes'?><camvars/>");
foreach ($toRead as $key=>$value) {
$xml->addChild ($key,$value);
}
if (count($toWrite)>0) {
$xml->addChild ('frame',$npars);
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
?>
<?php
/*!*******************************************************************************
*! FILE NAME : ccam.php
*! DESCRIPTION: Programs major sensor parameters similar (not exactly) to ccam.cgi,
*! returns xml OK
*! Copyright (C) 2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: ccam.php,v $
*! Revision 1.2 2009/12/28 06:24:17 elphel
*! 8.0.6.6 - added MakerNote to Exif, it icludes channels gains and gammas/black levels
*!
*! Revision 1.1.1.1 2008/11/27 20:04:03 elphel
*!
*!
*! Revision 1.4 2008/11/04 00:16:50 elphel
*! started porting
*!
*! Revision 1.3 2008/11/02 07:26:41 elphel
*! started porting ccam.php/camvc2
*!
*! Revision 1.2 2008/09/28 00:31:42 elphel
*! Some histogram related constants renamed from *AUTOEXP*, *AEXPWND* to *HISTWND*
*!
*! Revision 1.8 2008/04/24 18:20:40 elphel
*! added retrieval of circbuf structure
*!
*! Revision 1.4 2008/04/16 20:39:32 elphel
*! removed actions that are unneeded with the current drivers, limited number of retries to stop compressor in "mode=set", added "mode=force" that unconditionally reprograms camera without an attempt to nicely stop the compressor
*!
*! Revision 1.3 2008/03/25 07:38:43 elphel
*! just troubleshooting
*!
*! Revision 1.2 2008/03/22 04:43:03 elphel
*! few minor changes
*!
*! Revision 1.1 2008/03/20 22:32:12 elphel
*! sensor/compressor control, similar commands as ccam.cgi, but no images returned (use imgsrv - port 8081)
*!
*!
*/
function out1x1gif() {
header("Content-Type: image/gif");
header("Content-Length: 35\n");
echo "GIF87a\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00".
"\xff\xff\xff\x2c\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x4c".
"\x01\x00\x3b";
}
/*
$debugGetPars= var_export($_GET, true);
$debugFile=fopen('/var/html/ccam.php.log','a+');
fwrite($debugFile,"\n================================\n".$debugGetPars);
fclose($debugFile);
*/
//Default parameters to be written after sensor reset
$init_pars=array(
"FLIP"=>3, //!xy, +1 - flip-X, +2 - flipY
"COLOR"=>1, //! mono - 0, color mode - 1, 2- jp4, +256 - sensor test, 512 - FPGA test
"DCM_HOR" => 1, //! Decimation horizontal
"DCM_VERT" => 1, //! Decimation vertical
"BIN_HOR" => 1, //! Binning horizontal
"BIN_VERT" => 1, //! Binning vertical
"QUALITY" => 90, //! JPEG quality (%)
"COLOR_SATURATION_BLUE" => 200 , //! color saturation blue 200% (100% - only for gamma=1.0)
"COLOR_SATURATION_RED" => 200 , //! color saturation blue 200% (100% - only for gamma=1.0)
"BITS" => 8, //! 8-bit image mode (may be 16)
"GAMMA" => 57, //! Gamma=57%
"PIXEL_LOW" => 10, //! Balck level - 10 (sensor default "fat zero")
"PIXEL_HIGH" => 254, //! white level
"EXPOS" => 100, //! whatever? (in 100usec steps)
"WOI_LEFT" => 0, //! window left
"WOI_TOP" => 0, //! window top
"WOI_WIDTH" => 10000, //! window width (more than needed, will be truncated)
"WOI_HEIGHT" => 10000, //! window height (more than needed, will be truncated)
"RSCALE" => 256, //! red/green*256 (no auto - it is inside ccam.cgi)
"BSCALE" => 256, //! blue/green*256 (no auto - it is inside ccam.cgi)
"GAINR" => 512, //! Red analog gain 2.0*256
"GAING" => 512, //! Green1 (red row) analog gain 2.0*256
"GAINB" => 512, //! Red analog gain 2.0*256
"GAINGB" => 512, //! Green2 (blue row) analog gain 2.0*256
"BAYER" => 4 //! 0..3 - set, 4- use calcualted
);
$aexp_arr=array(
"AUTOEXP_ON"=>0,
"HISTWND_RWIDTH"=>0,
"HISTWND_RHEIGHT"=>0,
"HISTWND_RLEFT"=>0,
"HISTWND_RTOP"=>0,
"AUTOEXP_EXP_MAX"=>0,
"AUTOEXP_OVEREXP_MAX"=>0,
"AUTOEXP_S_PERCENT"=>0,
"AUTOEXP_S_INDEX"=>0,
"AUTOEXP_EXP"=>0,
"AUTOEXP_SKIP_PMIN"=>0,
"AUTOEXP_SKIP_PMAX"=>0,
"AUTOEXP_SKIP_T"=>0,
"HISTWND_WIDTH"=>0,
"HISTWND_HEIGHT"=>0,
"HISTWND_TOP"=>0,
"HISTWND_LEFT"=>0
);
$keep_pars=array(
"COLOR"=>0,
"TRIG"=>0
);
$wb_thrsh=0.98;
$wb_minfrac=0.01;
$wb_rscale=1.0;
$wb_bscale=1.0;
$white_balance=false;
$wbrslt=-1;
$autoexp_set=false; // change autoexposure settings
$sleep= ($_GET["sleep"]); if ($sleep>0) sleep($sleep); //missing sleep() in javaScript - sleeps before other actions
$usleep= ($_GET["usleep"]); if ($usleep>0) usleep($usleep);
$autoexp=elphel_get_P_value (ELPHEL_AUTOEXP_ON);
$pars=array();
$mode=$_GET["mode"];
$keep_pars=elphel_get_P_arr($keep_pars); // parameters, some bits of which should be preserved
$timeout=500; //miliseconds - how long to wait for compressor stop
$hist_in_thresh=0.0;
$hist_out_thresh=0.0;
$autoexp_get=false; // output autoexposure data
$streamer_get=false; // output streamer data
$show_written=false; // show parameters written
$exif_get=false;
$circbuf_get=false;
$debug_arr=array();
if ($mode=="reset") { // reset sensor
$pars=$init_pars;
$mode="set";
if (elphel_get_state()>7) { //! compressor is running
if ($keep_pars["TRIG"]& 4) { // no sense to check also elphel_get_P_value (ELPHEL_TRIG+ELPHEL_NUMBER) - written value
elphel_set_P_value(ELPHEL_TRIG,$keep_pars["TRIG"] & ~4);
elphel_program_sensor (0); /// will stop compressor also
}
}
elphel_reset_sensor();
} // reset sensor
$toRead=array(); // raw parameters to read by name
// now parse/add parameters to be programmed
foreach($_GET as $key=>$value) {
switch($key) {
/// _time - will look at FPGA time and program both FPGA and system, _stime - unconditionally program both
case "_time":
if (elphel_get_fpga_time() > 100000000) break; // time already set
case "_stime":
$a=((float) $value)/1000;
elphel_set_fpga_time ($a); // set FPGA time
exec("date -s ".date("mdHiY.s",(int)$a),$out,$ret); // set system time
break;
case "timeout":
$timeout=(int) ($value+0);
case "mode":
case "acquire":
case "out":
case "compressor":
case "imgsrv":
break; // not processed here
case "color":
switch ($value) {
case "jp4": $value=2; break;
case "color":$value=1; break;
case "mono": $value=0; break;
}
$keep_pars["COLOR"]=$pars["COLOR"]=((integer) $value) | ($keep_pars["COLOR"] & ~7); // 3 LSBs - for color mode
break;
case "test":
switch ($value) {
case "fpga": $value=2; break;
case "sensor":$value=1; break;
}
$keep_pars["COLOR"]=$pars["COLOR"]=(((integer) $value) << 8) | ($keep_pars["COLOR"] & ~0x700); // 3 LSBs - for color mode
break;
case "flip": $pars["FLIP"]= ((strpos($value,"x")===false)?0:1)+((strpos($value,"y")===false)?0:2); break;
case "trig":
switch ($value) {
case "sync": $value=0; break;
case "async": $value=4; break;
}
$keep_pars["TRIG"]=$pars["TRIG"]=($value? 4: 0) | ($keep_pars["TRIG"] & ~0x4); // only change bit 2
break;
// options "m,..." - not implemented
case "gam":
case "gamma":
$pars["GAMMA"]=(integer) $value;
break;
case "pxl":
case "pixel_low":
$pars["PIXEL_LOW"]=(integer) $value;
break;
case "pxh":
case "pixel_high":
$pars["PIXEL_HIGH"]=(integer) $value;
break;
case "iq":
case "quality":
$pars["QUALITY"]=(integer) $value;
break;
case "iq":
case "quality":
$pars["QUALITY"]=(integer) $value;
break;
case "byr":
case "bayer":
if ($value="auto") $value=4;
$pars["BAYER"]=(integer) $value;
break;
case "fpns":
case "fpn_sub":
$pars["FPNS"]=(integer) $value;
break;
case "fpnm":
case "fpn_mpy":
$pars["FPNM"]=(integer) $value;
break;
case "expos": // in seconds
case "exposure":
if (is_numeric($value)) $value=$value*10000; // now in 1/10000 sec)
case "e": //1/10000 sec, currently in ccam.cgi
switch ($value) {
case "auto":
if ($autoexp==0) {
$pars["AUTOEXP_ON"]=1;
$autoexp_set=true;
}
break;
case "manual":
if ($autoexp!=0) {
$pars["AUTOEXP_ON"]=0;
$autoexp_set=true;
}
break;
default:
$value=(integer) $value;
if ($value>0) {
$pars["EXPOS"]=$value;
if ($autoexp!=0) {
$pars["AUTOEXP_ON"]=0;
$autoexp_set=true;
}
}
}
break;
case "ve": // in scan lines - don't change autoexposure!
$pars["VEXPOS"]=(integer) $value;
break;
case "vw":
$pars["VIRT_WIDTH"]=(integer) $value;
break;
case "vh":
$pars["VIRT_HEIGHT"]=(integer) $value;
break;
case "wl":
case "left":
$pars["WOI_LEFT"]=(integer) $value;
break;
case "wt":
case "top":
$pars["WOI_TOP"]=(integer) $value;
break;
case "ww":
case "width":
$pars["WOI_WIDTH"]=(integer) $value;
break;
case "wh":
case "height":
$pars["WOI_HEIGHT"]=(integer) $value;
break;
case "pfh": // lower 16 bits - "pfh", higher bits - "ts<<16"
$pars["PF_HEIGHT"]=(integer) $value;
break;
case "fsd":
case "fsync_dly": // mostly debug - delay frame sync by $value lines
$pars["FRAMESYNC_DLY"]=(integer) $value;
break;
case "dh":
$pars["DCM_HOR"]=(integer) $value;
break;
case "dv":
$pars["DCM_VERT"]=(integer) $value;
break;
case "bh":
$pars["BIN_HOR"]=(integer) $value;
break;
case "bv":
$pars["BIN_VERT"]=(integer) $value;
break;
case "clk": // not used
case "shl": // not used
break;
case "bit":
case "bits":
$pars["BITS"]=(integer) $value;
break;
case "gr":
case "red":
$pars["GAINR"]=(integer) ($value*256);
break;
case "gg":
case "green":
$pars["GAING"]=(integer) ($value*256);
break;
case "gb":
case "blue":
$pars["GAINB"]=(integer) ($value*256);
break;
case "ggb":
case "gg2":
case "green2":
$pars["GAINGB"]=(integer) ($value*256);
break;
case "sens": // just set all gains together
case "gain":
$value= (integer) ($value*256);
$pars["GAINR"] = $value;
$pars["GAING"] = $value;
$pars["GAINB"] = $value;
$pars["GAINGB"]= $value;
break;
case "rscale":
$pars["RSCALE"]=(integer) ($value*256);
break;
case "bscale":
$pars["BSCALE"]=(integer) ($value*256);
break;
case "csb":
$pars["COLOR_SATURATION_BLUE"]=(integer) $value;
break;
case "saturation_blue":
$pars["COLOR_SATURATION_BLUE"]=(integer)(100*$value);
break;
case "csr":
$pars["COLOR_SATURATION_RED"]=(integer) $value;
break;
case "saturation_red":
$pars["COLOR_SATURATION_RED"]=(integer)(100*$value);
break;
case "eol": // probably not used
$pars["OVERLAP"]=(integer)(100*$value);
break;
case "vtrig": // probably not used
$pars["VIRTTRIG"]=(integer)(100*$value);
break;
case "fclk": // FPGA clock, MHz (likely will not work)
$pars["CLK_FPGA"]=(integer)(1000000*$value);
break;
case "sclk": // sensor clock, MHz (likely will not work )
$pars["CLK_SENSOR"]=(integer)(1000000*$value);
break;
case "xtra": // number of additional (to number of macroblocks*768) clock cycles needed to compress a frame
$pars["FPGA_XTRA"]=(integer) $value;
break;
//#define P_FP1000SLIM 9 // FPS limit, frames per 1000 sec
//#define P_FPSFLAGS 10 // FPS limit mode - bit 0 - limit fps (not higher than), bit 1 - maintain fps (not lower than)
case "fps":
$value=(integer) (1000 *$value);
$pars["FP1000SLIM"]=$value;
if ($_GET["fpslm"]!==NULL) $pars["FPSFLAGS"]=(integer) $_GET["fpslm"];
else $pars["FPSFLAGS"]= 1;// old behavior - just upper limit, if fps !=0
break;
case "fpslm":
if ($_GET["fps"]===NULL) $pars["FPSFLAGS"]=(integer) $_GET["fpslm"];
break;
//!white balance parameters - if calculated OK, they will overwrite manual rscale, bscale if any
case "wb_thrsh":
if (is_numeric ($value) && ($value > 0) && ($value <= 1)) $wb_thrsh=$value;
$white_balance=true;
break;
case "wb_minfrac":
if (is_numeric ($value) && ($value > 0) && ($value < 1)) $wb_minfrac=$value;
$white_balance=true;
break;
case "wb_rscale":
if (is_numeric ($value) && ($value >= 0.1) && ($value <= 10.1)) $wb_rscale=$value;
$white_balance=true;
break;
case "wb_bscale":
if (is_numeric ($value) && ($value >= 0.1) && ($value <= 10.1)) $wb_rscale=$value;
$white_balance=true;
break;
case "wbalance":
case "balance":
$white_balance=true;
break;
case "aexp_get":
$autoexp_get=true;
break;
//! additional autoexposure parameters. Support both integer values (same as internal) and fractions of 1.0, seconds, etc.
case "aexp_on": /// same as e=auto
$pars["AUTOEXP_ON"]=($value)?1:0;
$autoexp_set=true;
break;
case "aexp_width": //relative width of the autoexposure window (<1.0)
if ($value < 1) $value=100*$value; // now %
$pars["HISTWND_RWIDTH"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_height": //relative height of the autoexposure window (<1.0)
if ($value < 1) $value=100*$value; // now %
$pars["HISTWND_RHEIGHT"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_left": //relative left of the autoexposure window (<1.0)
if ($value < 1) $value=100*$value; // now %
$pars["HISTWND_RLEFT"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_top": //relative top of the autoexposure window (<1.0)
if ($value < 1) $value=100*$value; // now %
$pars["HISTWND_RTOP"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_exp_max": // maximal exposure in seconds (<20)
if ($value < 20) $value=1000*$value; // now in milliseconds
$pars["AUTOEXP_EXP_MAX"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_overexp": // maximal fraction of overexposed pixels (both fractions and integer 1/100%)
if ($value < 1) $value=10000*$value; // now in 0.01%
$pars["AUTOEXP_OVEREXP_MAX"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_below": // maximal fraction of pixels exposed less than the threshold (both fractions and integer 1/100%)
if ($value < 1) $value=10000*$value; // now in 0.01%
$pars["AUTOEXP_OVEREXP_MAX"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_threshold": // threshold, (0..0.999 or 1..255) used together with
case "aexp_thresh":
case "aexp_index":
if ($value < 1) $value=255.5*$value; // now in 0..255
$pars["AUTOEXP_S_INDEX"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_frac": // fraction of pixels below given threshold
case "aexp_fraction": // fraction of pixels below given threshold
if ($value < 1) $value=10000*$value; // now in 0..255
$pars["AUTOEXP_S_PERCENT"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_chng_min": // minimal realtive change in exposure to be applied (0..1.0 and in 0.001%)
if ($value < 1) $value=10000*$value; // now in 0.01%
$pars["AUTOEXP_SKIP_PMIN"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_chng_minabs": // minimal absoluteve change in exposure to be applied (in "ticks"=1/10000 s, default=2)
$pars["AUTOEXP_SKIP_T"]=(integer) $value;
$autoexp_set=true;
break;
case "aexp_chng_max": // maximal realtive change in exposure to be applied (0..1.0 and in 0.001%)
if ($value < 1) $value=10000*$value; // now in 0.01%
$pars["AUTOEXP_SKIP_PMAX"]=(integer) $value;
$autoexp_set=true;
break;
/*
case "hist_in_thresh": // calculate the input and output levels
$hist_in_thresh=$value+0.0;
break;
case "hist_out_thresh": // calculate the input and output levels
$hist_out_thresh=$value+0.0;
break;
*/
case "written": // show parameters written (accepted)
case "show_written":
$show_written=true;
break;
case "streamer_get":
$streamer_get=true;
break;
case "exif":
$exif_get=$value+0; //page number
break;
case "description":
if ( $value!==null) elphel_set_exif_field(0x10e, $value.chr(0));
break;
case "circbuf":
$circbuf_get=true;
break;
default: /// treat as parameter names
$toRead[$key]="";
if ($value!=="") $pars[$key]=(integer) $value+0;
}
}
$npars=elphel_set_P_arr($pars);
if ($white_balance) {
$wbrslt=elphel_white_balance ($wb_thrsh, $wb_minfrac, $wb_rscale, $wb_bscale); // remember result - if OK - needs to be updated
}
if ($autoexp_set) {
elphel_autoexposure_set();
}
///add mode=safe. "set" if not running, otherwise return error (not needed - mode=safe&STATE is enough)
$was_running=(elphel_get_state()>7);
if (($mode=="safe") && !$was_running) $mode=$set;
if (($npars>0) || ($wbrslt>=0) || ($mode=="skipbad") || ($mode=="set") || ($mode=="force")){
if (($mode=="skipbad") || ($mode=="set") || ($mode=="force")) {
if ($was_running && !($mode=="force")) elphel_compressor_stop(); //! stop it
if (!($mode=="force")) { /// Even if it was not running, compressor might be acquiring the (last) frame
for ($i=0; $i<=($timeout/50);$i++) // wait for some time (but not too long) trying to be nice and stop compressor gracefully
if (!elphel_is_compressor_idle()) usleep (50000) ; //0.05sec
else break;
$debug_arr["stopping_force"]=$i;
}
if ($mode=="skipbad") elphel_program_sensor (1); // will stop compressor if it was running
else elphel_program_sensor (0); // will stop compressor if it was running
} else {
$debug_arr["program_sensor"]=1;
// elphel_program_sensor (1); // nonstop, just update on the fly obsolete in 8.x
}
}
// now control compressor
// (Try to) Stop it if quality is specified and different from the current
if (($pars["QUALITY"] !==null) &&
($pars["QUALITY"] != elphel_get_P_value (ELPHEL_QUALITY))) {
if (elphel_get_state()>7) elphel_compressor_stop(); //! stop it
for ($i=0; $i<=($timeout/50);$i++) // wait for some time trying to stop compressor gracefully
if (!elphel_is_compressor_idle()) usleep (50000) ; //0.05sec
else break;
$debug_arr["stopping_quality"]=$i;
}
switch ($_GET["compressor"]) {
case "stop":
elphel_compressor_stop();
break;
case "wait":
while (elphel_get_state()>7) usleep (100000) ; //! just wait - will wait forever if async mode
break;
case "restore": // run if was running before programming
$debug_arr["was_running"]=$was_running;
$debug_arr["before_restore_state"]=elphel_get_state();
if ($was_running && (elphel_get_state() <=7)) elphel_compressor_run();
else elphel_fpga_write (4,5); /// restore acquisition for autoexposure to work
break;
case "run":
elphel_compressor_run();
break;
case "single":
elphel_compressor_frame();
break;
case "reset":
// try this.
// if running and async turn to sync, stop,reset,reset,turn back to sync
// if running and sync - just stop,reset,reset
if (elphel_get_state()>7) { //! compressor is running
if (elphel_get_P_value (ELPHEL_TRIG) & 4) { // keep_pars may have new value, not yet set - we use here current one
elphel_set_P_value(ELPHEL_TRIG,$keep_pars["TRIG"] & ~4);
elphel_program_sensor (0); // set internal trigger mode, frames might be broken
}
elphel_compressor_stop(); //! stop it
while (elphel_get_state()>7) usleep (100000) ; //! just wait - will wait forever if async mode
elphel_compressor_reset(); //! Maybe needed twice
elphel_compressor_reset(); //! Maybe needed twice
//!turn back to async if it was set
if ($keep_pars["TRIG"]& 4) { // no sense to check also elphel_get_P_value (ELPHEL_TRIG+ELPHEL_NUMBER) - written value
elphel_set_P_value(ELPHEL_TRIG,$keep_pars["TRIG"]);
elphel_program_sensor (0);
}
}
break;
}
if ($_GET["out"]=="gif") {
out1x1gif();
exit (0);
}
$xml = new SimpleXMLElement("<?xml version='1.0'?><pars/>");
if (count($toRead)>0) $toRead=elphel_get_P_arr($toRead);
if ($_GET["STATE"]!==NULL) $toRead["STATE"]=elphel_get_state();
if ($_GET["imgsrv"]!==NULL) $toRead["imgsrv"]='http://'.$_SERVER['HTTP_HOST'].':8081/';
foreach ($debug_arr as $key=>$value) {
$xml->addChild ($key,$value);
}
foreach ($toRead as $key=>$value) {
$xml->addChild ($key,$value);
}
if ($exif_get!==false) {
$exif_got=elphel_get_exif_elphel($exif_get);
if ($exif_got) {
$xml->addChild ('Exif');
$xml->Exif->addChild ("Exif_page",$exif_get);
foreach ($exif_got as $key=>$value) {
$xml->Exif->addChild ($key,$value);
}
}
}
/// Calculate and output histogram levels if requested (both input and output in the range of 0.0..1.0, inclusive)
/// here $hist_in_thresh corresponds to input signals as fractions of the full scale input data)
if ($hist_in_thresh) {
$xml->addChild ('hist_in');
$xml->hist_in->addChild ('hist_in_thresh',$hist_in_thresh);
$xml->hist_in->addChild ('hist_in_r', elphel_histogram(0,elphel_gamma(0,$hist_in_thresh)));
$xml->hist_in->addChild ('hist_in_g', elphel_histogram(1,elphel_gamma(1,$hist_in_thresh)));
$xml->hist_in->addChild ('hist_in_g2',elphel_histogram(2,elphel_gamma(2,$hist_in_thresh)));
$xml->hist_in->addChild ('hist_in_b', elphel_histogram(3,elphel_gamma(3,$hist_in_thresh)));
}
/// here $hist_out_thresh corresponds to output (8-bit) pixel values as fractions of the 8-bit full scale (255)
if ($hist_out_thresh) {
$xml->addChild ('hist_out');
$xml->hist_out->addChild ('hist_out_thresh',$hist_out_thresh);
$xml->hist_out->addChild ('hist_out_r', elphel_histogram(0,$hist_out_thresh));
$xml->hist_out->addChild ('hist_out_g', elphel_histogram(1,$hist_out_thresh));
$xml->hist_out->addChild ('hist_out_g2',elphel_histogram(2,$hist_out_thresh));
$xml->hist_out->addChild ('hist_out_b', elphel_histogram(3,$hist_out_thresh));
}
//! read autoexposure data
if ($autoexp_get) {
$xml->addChild ('autoexposure');
elphel_autoexposure_get();
$aexp_arr=elphel_get_P_arr ($aexp_arr);
foreach ($aexp_arr as $key=>$value) {
$xml->autoexposure->addChild ($key,$value);
}
}
if ($white_balance) {
$xml->addChild ('white_balance');
$xml->white_balance->addChild ('wb_thrsh', $wb_thrsh);
$xml->white_balance->addChild ('wb_minfrac',$wb_minfrac);
$xml->white_balance->addChild ('wb_rscale', $wb_rscale);
$xml->white_balance->addChild ('wb_bscale', $wb_bscale);
$xml->white_balance->addChild ('result',($rslt>=0)?"OK":"failure");
if ($wbrslt>=0) {
$xml->white_balance->addChild ('after');
$balance_pars=elphel_get_P_arr(array("RSCALE"=>0,"BSCALE"=>0,"GSCALE"=>0));
foreach ($balance_pars as $key=>$value) {
$xml->white_balance->after->addChild ($key,$value);
}
}
}
// Output streamer state
if ($streamer_get) {
$xml->addChild ('streamer');
$streamer_run=false;
///FIXME: for now just disable
/// if (($fd=fopen('/dev/stream','r'))) fclose ($fd) ; else $streamer_run=true;
$streamer_conf=file($streamer_run?'/var/state/streamer.conf':'/etc/streamer.conf');
foreach ($streamer_conf as $line) {
$conf_cmd=split('=',$line);
if (trim($conf_cmd[0])=='pid') {
exec ('kill -0 '.$conf_cmd[1], $outv,$retv);
$streamer_run=($retv==0);
} else {
$xml->streamer->addChild ('S_'.trim($conf_cmd[0]),trim($conf_cmd[1]));
}
}
$xml->streamer->addChild ('S_STREAM',$streamer_run?1:0);
}
///circbuf+exif pointres
if ($circbuf_get) {
$xml->addChild ('circbuf');
$circbuf=elphel_get_circbuf_pointers();
if (is_array ($circbuf)) {
$circbuf_count=count($circbuf);
$xml->circbuf->addChild ('circbuf_count',$circbuf_count);
for ($i=0;$i<$circbuf_count;$i++) {
$xml->circbuf->addChild ('frame'.$i);
$xml->circbuf->{'frame'.$i}->addChild ('circbuf_pointer',$circbuf[$i]['circbuf_pointer']);
$xml->circbuf->{'frame'.$i}->addChild ('exif_pointer' ,$circbuf[$i]['exif_pointer']);
}
}
}
switch ($_GET["out"]) { // Remove completely?
case "all":
$xml->addChild ('state',elphel_get_state());
$xml->addChild ('FRAME',elphel_get_P_value (ELPHEL_FRAME));
$xml->addChild ('TRIG',elphel_get_P_value (ELPHEL_TRIG));
break;
}
if (count($pars)) { // last item - what was written
$xml->addChild ('pars_written');
$xml->pars_written->addChild ('number_written',$npars);
if ($show_written) {
foreach ($pars as $key=>$value) {
$xml->pars_written->addChild ($key,$value);
}
}
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
?>
<?php
/*!*******************************************************************************
*! FILE NAME : diag_utils.php
*! DESCRIPTION: Provides development/diagnostic data
*! Copyright (C) 2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: diag_utils.php,v $
*! Revision 1.5 2010/04/30 21:09:00 elphel
*! added forced synchronization on/off links, parsedit.php link
*!
*! Revision 1.4 2008/11/30 21:56:39 elphel
*! Added enforcing limit on the overall gains in the color channels, storage of exposure and gains in the histograms cache (to be used with autoexposure/white balance)
*!
*! Revision 1.3 2008/11/30 06:41:43 elphel
*! changed default IP back to 192.168.0.9 (temporarily was 192.168.0.7)
*!
*! Revision 1.2 2008/11/30 05:02:27 elphel
*! wrong links
*!
*! Revision 1.1.1.1 2008/11/27 20:04:03 elphel
*!
*!
*! Revision 1.1 2008/11/27 09:29:22 elphel
*! new file - diag_utils.php that includes somewhat cleaned-up version of utilities from framepars.php. That file installation is moved to attic
*!
*!
*/
$imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081";
if (count($_GET)==0) {
showUsage();
exit (0);
}
//$_SERVER["SERVER_ADDR"] . ":8081
$elp_const=get_defined_constants(true);
$elp_const=$elp_const["elphel"];
foreach($_GET as $key=>$value) switch($key) {
case "profile": profileShow(myval($value)); break;
case "histogram_direct":
case "histogram_reverse":
case "gamma_direct":
case "gamma_reverse": showHistGamma ($key,floatval($value)); break;
case "jpegheader": showJpegHeader(); break;
case "constants": echo "<pre>\n";print_r($elp_const); echo "</pre>\n"; break;
case "frame": printRawFrame(myval($value)); break;
case "hist_raw": printRawHistogram(0xfff,myval($value)); break;
case "hist":
case "histogram": printHistogram(myval($value)); break;
case "gamma": printGammaStructure(); break;
case "gamma_page": printRawGamma(myval($value)); break;
default: showUsage();
}
exit (0);
///==========================================================================================================
function showUsage() {
global $imgsrv;
echo <<<USAGE
<p>This is a collection of tools for the 8.0 software development/testing, you can provide parameters in HTTP GET request.</p>
<p>Here are some of the current options</p>
<ul>
<li><a href="?constants">constants</a> - list all defined PHP constants related to Elphel camera</li>
<li><a href="?profile=50">profile=50</a> - show last 50 (up to ELPHEL_CONST_PASTPARS_SAVE_ENTRIES=2048) profile entries - recorded if profiling is enabled</li>
<li><a href="?histogram_direct=0.5">histogram_direct=0.5</a> - show part of the pixels below specified output value (on 0..1.0 scale - 0.5 in this example) for each color channel </li>
<li><a href="?histogram_reverse=0.5">histogram_reverse=0.5</a> - show pixel output value (on 0..1.0 scale) so that specified part of all pixels have output (after gamma conversion) valuebelow it, for each color channel </li>
<li><a href="?gamma_direct=0.5">gamma_direct=0.5</a> - show output pixel value (on 0..1.0 scale) for the specified (0..1.0 scale) sensor pixel value, for each color channel </li>
<li><a href="?gamma_reverse=0.5">gamma_reverse=0.5</a> - show what sensor pixel value would produce specified output (after gamma conversion) value (on 0..1.0 scale), for each color channel </li>
<li><a href="?jpegheader">jpegheader</a> - show data in the current JPEG header</li>
<li><a href="?frame=0">frame=0</a> - show raw data for the frame parameters internal data. There are 8 parameter pages used in sequence, so only the 3 least significant bits of the frame number are used</li>
<li><a href="?histogram=prev">histogram=prev</a> - Show histogram data for the specified frame - in addition to the absolute frame number you may specify prev1...prev6. Giving future or too long ago frame will result in an (uncaught) error</li>
<li><a href="?hist_raw=prev">hist_raw=prev</a> - Show raw histogram data for the specified frame - in addition to the absolute frame number you may specify prev1...prev6. Giving future or too long ago frame will result in an (uncaught) error. It shows the same data as <a href="?histogram=prev">histogram=prev</a> - just uses different access to the histogram arrays.</li>
<li><a href="?gamma">gamma</a> - show structure of the gamma tables cache. Among othe data it provides links to the individual gamma tables pages. This command takes morfe than 10 seconds to complete.</li>
<li><a href="?gamma_page=255">gamma_page=255</a> - contents of the gamma tables cache page (0 - index page, 1..255 - cache pages). Individual pages links are provided by the <a href="?gamma">?gamma</a> command. Some of the tables in the cache (reverse, FPGA) may be missing if they were never requested.</li>
</ul>
<p>There are additional development pages links available:</p>
<ul>
<li><a href="parsedit.php">parsedit.php</a> - this page includes links to multiple useful parameter controls as well as explanation how to create custom control pages by just modifying the URL line</li>
<li><a href="/tuneseq.php">tuneseq.php</a> - run-time tuning of sequencer latencies;</li>
<li><a href="$imgsrv">imgsrv</a> getting images from the camera internal buffer (you have to acquire them there first)</li>
<li><i>forced synchronization mode</i>: <a href="/fpga.php?a=0x4e&d=0x60">ON</a> and <a href="/fpga.php?a=0x4e&d=0x40">OFF</a> (default). When this mode is activated the camera will force re-synchronization between the sensor and the FPGA compressor at each frame start. Normally it is not needed and loosing synchronization is usually an indication of a software/fpga bug (there are some rare conditions when this is normal), this is why this mode is disabled by default so the problems would reveal themselves.</li>
<li><a href="/var/klog.txt">var/klog.txt</a> - read kernel messages (you first need to telnet to the camera and run "printk_mod &amp;" and enable some of the DEBUG bits)</li>
</ul>
<h4>Make sure to run "printk_mod &amp;" before enabling debug bits - some are from interrupt service routine, and default printk() output to console can really mess up things and make the camera &quot;freeze&quot;.</h4>
USAGE;
}
function showJpegHeader() {
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
$circbuf_file=fopen("/dev/circbuf","r");
fseek($circbuf_file,ELPHEL_LSEEK_CIRC_LAST,SEEK_END);
$jpeg_start=ftell($circbuf_file);
$xml->addChild ('circbuf_pointer',sprintf("0x%x (0x%x)",$jpeg_start,$jpeg_start>>2));
fclose($circbuf_file);
$header_file=fopen("/dev/jpeghead","r");
/// Now select right frame (different frames may have different header sizes)
fseek($header_file,$jpeg_start+1,SEEK_END); /// selects frame, creates header
fseek($header_file,0,SEEK_END); /// positions to the end
$header_size=ftell($header_file); ///
$xml->addChild ('header_size',$header_size);
fseek($header_file,0,SEEK_SET); /// positions to the beginning
$header=fread ($header_file,8192);
$xml->addChild ('header_read_length',strlen($header));
fclose($header_file);
$aheader=unpack('C*',$header);
for ($i=0; $i<count($aheader) ;$i+=16){
$d="";
for ($j=$i; ($j<$i+16) && ($j<count($aheader)); $j++) $d.=sprintf(" %02x",$aheader[$j+1]);
$xml->addChild (sprintf('header%03x',$i),$d);
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
}
function showHistGamma ($key,$value) {
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
switch($key) {
case "histogram_direct":
$xml->addChild ('histogram_direct_r', elphel_histogram(0,$value));
$xml->addChild ('histogram_direct_g', elphel_histogram(1,$value));
$xml->addChild ('histogram_direct_gb',elphel_histogram(2,$value));
$xml->addChild ('histogram_direct_b', elphel_histogram(3,$value));
break;
case "histogram_reverse":
$xml->addChild ('histogram_reverse_r', elphel_reverse_histogram(0,$value));
$xml->addChild ('histogram_reverse_g', elphel_reverse_histogram(1,$value));
$xml->addChild ('histogram_reverse_gb',elphel_reverse_histogram(2,$value));
$xml->addChild ('histogram_reverse_b', elphel_reverse_histogram(3,$value));
break;
case "gamma_direct":
$xml->addChild ('gamma_direct_r', elphel_gamma(0,$value));
$xml->addChild ('gamma_direct_g', elphel_gamma(1,$value));
$xml->addChild ('gamma_direct_gb',elphel_gamma(2,$value));
$xml->addChild ('gamma_direct_b', elphel_gamma(3,$value));
break;
case "gamma_reverse":
$xml->addChild ('gamma_reverse_r', elphel_reverse_gamma(0,$value));
$xml->addChild ('gamma_reverse_g', elphel_reverse_gamma(1,$value));
$xml->addChild ('gamma_reverse_gb',elphel_reverse_gamma(2,$value));
$xml->addChild ('gamma_reverse_b', elphel_reverse_gamma(3,$value));
break;
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
}
function profileShow($num_entries) {
//echo "<pre>";
//http://192.168.0.9/parsedit.php?PROFILING_EN=1
$prof_template=array(
"PROFILE00"=>0,"PROFILE01"=>0,
"PROFILE02"=>0,"PROFILE03"=>0,
"PROFILE04"=>0,"PROFILE05"=>0,
"PROFILE06"=>0,"PROFILE07"=>0,
"PROFILE08"=>0,"PROFILE09"=>0,
"PROFILE10"=>0,"PROFILE11"=>0,
"PROFILE12"=>0,"PROFILE13"=>0,
"PROFILE14"=>0,"PROFILE15"=>0
);
$now=elphel_get_frame()-2; /// data is available 2 frames behind
$time_start=elphel_get_fpga_time();
$prof_raw=array();
for ($i=$now-$num_entries-1;$i<=$now;$i++) {
$prof_raw[$i]=elphel_get_P_arr($prof_template,$i);
}
$time_end=elphel_get_fpga_time();
$prof=array();
for ($i=$now-$num_entries;$i<=$now;$i++) {
$prof[$i]=array ( "dt0"=>($prof_raw[$i]["PROFILE00"]-$prof_raw[$i-1]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE01"]-$prof_raw[$i-1]["PROFILE01"]),
"dt1"=>($prof_raw[$i]["PROFILE02"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE03"]-$prof_raw[$i]["PROFILE01"]),
"dt2"=>($prof_raw[$i]["PROFILE04"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE05"]-$prof_raw[$i]["PROFILE01"]),
"dt3"=>($prof_raw[$i]["PROFILE06"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE07"]-$prof_raw[$i]["PROFILE01"]),
"dt4"=>($prof_raw[$i]["PROFILE08"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE09"]-$prof_raw[$i]["PROFILE01"]),
"dt5"=>($prof_raw[$i]["PROFILE10"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE11"]-$prof_raw[$i]["PROFILE01"]),
"dt6"=>($prof_raw[$i]["PROFILE12"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE13"]-$prof_raw[$i]["PROFILE01"]),
"dt7"=>($prof_raw[$i]["PROFILE14"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE15"]-$prof_raw[$i]["PROFILE01"]));
foreach ($prof[$i] as $key=>$value) if ($prof[$i][$key]<0)$prof[$i][$key]="";
}
if (!elphel_get_P_value(ELPHEL_PROFILING_EN)) {
echo <<<PROFILE_ENABLE
<p><i>Interrupt service/tasklet profiling is currently disabled. You may enable it by following this link:
<a href="/parsedit.php?PROFILING_EN=1">/parsedit.php?PROFILING_EN=1</a>
</i></p>
PROFILE_ENABLE;
}
echo <<<CAPTION
<p>reading profile time start=$time_start </p>
<p>reading profile time end=$time_end </p>
<ol>Profiling interrupt/tasklet execution time in microseconds, starting from the start of the frame
<li>after updating frame pointers, Exif, parameters structures (IRQ service)</li>
<li>start of the tasklet</li>
<li>after Y histogram (G1) load from the FPGA (if enabled)</li>
<li>after processing parameters (actions triggered by the parameter changes), </li>
<li>after C histograms (R,G2,B) load from the FPGA (if enabled)</li>
<li>When parameters are started to be written by appliaction(s) - overwritten if several calls take place during the same frame</li>
<li>When parameters are finished to be written by appliaction(s) (may be overwritten)</li>
</oul>
<br/><br/>
CAPTION;
printf ("<table border='1'><tr><td>Frame</td><td>(hex)</td><td>Period</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>\n");
for ($i=$now-$num_entries;$i<=$now;$i++) {
printf("<tr style='align:right'><td>%d</td><td>%08x</td><td>%d</td>",$i,$i,$prof[$i]["dt0"]);
for ($j=1;$j<8;$j++) {
if ($prof[$i]["dt".$j]) printf("<td>%d</td>",$prof[$i]["dt".$j]);
else printf("<td>&nbsp;</td>");
}
printf("</tr>\n");
}
printf("</table>");
//echo "<pre>";print_r($prof_raw);echo"</pre>\n";
}
function printGammaStructure() {
$gammaStructure=getGammaStructure();
printf("<table \"border=1\">\n");
printf( "<tr><td>oldest_non_scaled</td><td><b>%d</b></td></tr>\n"
."<tr><td>newest_non_scaled</td><td><b>%d</b></td></tr>\n"
."<tr><td>oldest_all</td><td><b>%d</b></td></tr>\n"
."<tr><td>newest_all</td><td><b>%d</b></td></tr>\n"
."<tr><td>non_scaled_length</td><td><b>%d</b></td></tr>\n"
."<tr><td>num_locked</td><td><b>%d</b></td></tr>\n"
."<tr><td>locked_col 0</td><td><b>%d</b></td>\n"
."<tr><td>locked_col 1</td><td><b>%d</b></td>\n"
."<tr><td>locked_col 2</td><td><b>%d</b></td>\n"
."<tr><td>locked_col 3</td><td><b>%d</b></td>\n"
."</table>\n",
$gammaStructure["oldest_non_scaled"],
$gammaStructure["newest_non_scaled"],
$gammaStructure["oldest_all"],
$gammaStructure["newest_all"],
$gammaStructure["non_scaled_length"],
$gammaStructure["num_locked"],
$gammaStructure["locked_col"][0],
$gammaStructure["locked_col"][1],
$gammaStructure["locked_col"][2],
$gammaStructure["locked_col"][3]
);
printf("<br/><br/>\n");
printf("<table \"border=1\">\n");
// printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["index"]);printf("</tr>\n");
printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry)
printf ("<td><a href='?gamma_page=%d'><b>%d</b></a></td>",$entry["index"],$entry["index"]);printf("</tr>\n");
printf("<tr><td>hash32 </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%08x</b></td>",$entry["hash32"]);printf("</tr>\n");
printf("<tr><td>scale </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["scale"]);printf("</tr>\n");
printf("<tr><td>gamma </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["gamma"]);printf("</tr>\n");
printf("<tr><td>black </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["black"]);printf("</tr>\n");
printf("<tr><td>valid </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%x</b></td>",$entry["valid"]);printf("</tr>\n");
printf("<tr><td>locked </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%8x</b></td>",$entry["locked"]);printf("</tr>\n");
printf("<tr><td>this_non_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["this_non_scaled"]);printf("</tr>\n");
printf("<tr><td>newer_non_scaled</td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_non_scaled"]);printf("</tr>\n");
printf("<tr><td>older_non_scaled</td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_non_scaled"]);printf("</tr>\n");
printf("<tr><td>newer_all </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_all"]);printf("</tr>\n");
printf("<tr><td>older_all </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_all"]);printf("</tr>\n");
printf("<tr><td>oldest_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["oldest_scaled"]);printf("</tr>\n");
printf("<tr><td>newest_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newest_scaled"]);printf("</tr>\n");
printf("<tr><td>newer_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_scaled"]);printf("</tr>\n");
printf("<tr><td>older_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_scaled"]);printf("</tr>\n");
printf("</table>\n");
}
function getGammaStructure() {
$gammas_file=fopen("/dev/gamma_cache","r");
fseek($gammas_file,0,SEEK_END);
$numberOfEntries=ftell($gammas_file);
fclose($gammas_file);
$gammaStructure=array();
$g_raw=elphel_gamma_get_raw(0);
$g_raw_ul=unpack('V*',$g_raw);
$gammaStructure["oldest_non_scaled"]=$g_raw_ul[5];
$gammaStructure["newest_non_scaled"]=$g_raw_ul[6];
$gammaStructure["oldest_all"]= $g_raw_ul[7];
$gammaStructure["newest_all"]= $g_raw_ul[8];
$gammaStructure["non_scaled_length"]=$g_raw_ul[9];
$gammaStructure["num_locked"]= $g_raw_ul[10];
$gammaStructure["locked_col"]= array ($g_raw_ul[11],$g_raw_ul[12],$g_raw_ul[13],$g_raw_ul[14]);
$gammaStructure["entries"]= array ();
for ($i=1; $i<$numberOfEntries; $i++) {
$g_raw=elphel_gamma_get_raw($i);
$g_raw_ul=unpack('V*',$g_raw);
if ($g_raw_ul[ 4]>=0) { /// >=0 if ever used. This field seems to do nothing in the code.
$hash32= $g_raw_ul[1];
$gammaStructure["entries"][$i]= array (
"index" => $i,
"hash32"=> $hash32,
"scale" => ($hash32 & 0xffff)/1024.0,
"gamma" => (($hash32 >> 16) & 0xff)/100.0,
"black" => (($hash32 >> 24) & 0xff),
"valid" => $g_raw_ul[ 2], /// 0 - table invalid, 1 - table valid +2 for table locked (until sent to FPGA)
"locked" => $g_raw_ul[ 3], /// bit frame+ (color<<3) locked for color/frame
"this_non_scaled" => $g_raw_ul[ 4], /// 0 for non-scaled, others - (for scaled) - pointer to the corresponding non-scaled
/// This is non-scaled (gamma data is full 16-bit)
"newer_non_scaled" => $g_raw_ul[ 5], /// table type (non-scaled prototype) used later than this one
"older_non_scaled" => $g_raw_ul[ 6], /// table type (non-scaled prototype) used before this one
"newer_all" => $g_raw_ul[ 7], /// newer in a single chain of all scaled tables, regardless of the prototype
"older_all" => $g_raw_ul[ 8], /// older in a single chain of all scaled tables, regardless of the prototype
///Next two pairs are the same (union)
"oldest_scaled" => $g_raw_ul[ 9], /// oldest derivative of this prototype (scaled)
"newest_scaled" => $g_raw_ul[10], /// newest derivative of this prototype (scaled)
"newer_scaled" => $g_raw_ul[ 9], /// table type (non-scaled prototype) used later than this one
"older_scaled" => $g_raw_ul[10] /// table type (non-scaled prototype) used before this one
);
}
}
return $gammaStructure;
}
function printRawGamma($page=0) {
$g_raw=elphel_gamma_get_raw($page);
//var_dump()
$g_raw_ul=unpack('V*',$g_raw);
echo "<pre>\n";
printf ("Gamma cache page %d, length=%d\n",$page, strlen($g_raw));
$a=1; /// unpack started with index 1
$hash32= $g_raw_ul[$a++];
$scale= ($hash32 & 0xffff)/1024.0;
$gamma= (($hash32 >> 16) & 0xff)/100.0;
$black= (($hash32 >> 24) & 0xff);
printf ("hash32= %08x (scale=%f gamma=%f black=%d)\n",$hash32,$scale,$gamma,$black);
$valid= $g_raw_ul[$a++];
printf ("valid=%d, locked=%d\n",$valid & 1, $valid & 2);
$locked= $g_raw_ul[$a++];
printf ("locked= 0x%x (for frame=%d/color=%d)\n",$locked, $locked & 7, ($locked>>3) & 3);
$this_non_scaled=$g_raw_ul[$a++]; /// 0 for non-scaled
printf ("this_non_scaled=%d\n",$this_non_scaled);
if ($page==0) {
printf ("oldest_non_scaled=%d\n",$g_raw_ul[$a++]);
printf ("newest_non_scaled=%d\n",$g_raw_ul[$a++]);
} else {
printf ("newer_non_scaled=%d\n",$g_raw_ul[$a++]);
printf ("older_non_scaled=%d\n",$g_raw_ul[$a++]);
}
if ($page==0) {
printf ("oldest_all=%d\n",$g_raw_ul[$a++]);
printf ("newest_all=%d\n",$g_raw_ul[$a++]);
} else {
printf ("newer_all=%d\n",$g_raw_ul[$a++]);
printf ("older_all=%d\n",$g_raw_ul[$a++]);
}
if ($page==0) {
printf ("non_scaled_length=%d\n",$g_raw_ul[$a++]); /// current number of different hash values
printf ("num_locked=%d\n",$g_raw_ul[$a++]); /// number of nodes locked (until table sent to FPGA)
} else if ($this_non_scaled==0){
printf ("oldest_scaled=%d\n",$g_raw_ul[$a++]);
printf ("newest_scaled=%d\n",$g_raw_ul[$a++]);
} else {
printf ("newer_scaled=%d\n",$g_raw_ul[$a++]);
printf ("older_scaled=%d\n",$g_raw_ul[$a++]);
}
///data tables
if ($page==0) {
printf ("\nTable of locked indexes\n");
for ($color=0;$color<4; $color++) {
// for ($frame=0;$frame<8; $frame++) {
printf (" %4d",$g_raw_ul[$a++]);
// }
// printf ("\n");
}
printf ("\n");
/// no need to dump the rest - it is unused in the page 0
printf ("\n\nUnused area on page 0:");
// for ($i=0; $i<417; $i++) {
for ($i=0; $i<445; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$g_raw_ul[$a++];
printf (" %08x",$d);
}
} else {
printf ("\nGamma table (direct):");
for ($i=0; $i<129; $i++) {
if (($i & 0x07)==0) printf ("\n0x%03x:",$i*2);
$d=$g_raw_ul[$a++];
printf (" %04x %04x",$d & 0xffff, ($d>>16) & 0xffff );
}
printf ("\n\nGamma table (reverse):");
for ($i=0; $i<64; $i++) {
if (($i & 0x03)==0) printf ("\n0x%03x:",$i*4);
$d=$g_raw_ul[$a++];
printf (" %02x %02x %02x %02x",$d & 0xff, ($d>>8) & 0xff, ($d>>16) & 0xff, ($d>>24) & 0xff);
}
printf ("\n\nFPGA gamma data:");
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$g_raw_ul[$a++];
printf (" %05x",$d);
}
}
echo "</pre>\n";
}
function printHistogram($frame) {
if (!$frame) $frame=elphel_get_frame()-1;
$colors=array(0=>"R",1=>"G",2=>"GB",3=>"B");
$h_arr=elphel_histogram_get(0xfff,$frame);
$a=0;
$offset2sum=1024+255; /// last in cumulative histogram for the same color
echo "<pre>\n";
for ($color=0;$color<4;$color++) {
printf("\nhistogram for color #%d %s, Total number of pixels=%d (0x%x):",$color,$colors[$color],$h_arr[$a+$offset2sum],$h_arr[$a+$offset2sum]);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %05x",$h_arr[$a++]);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x",$h_arr[$a++]);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\npercentile for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i);
printf (" %02x",$h_arr[$a++]);
}
printf ("\n");
}
echo "</pre>\n";
}
function printRawHistogram($needed,$frame) {
if (!$frame) $frame=elphel_get_frame()-1;
///FIXME:
/// Use ELPHEL_CONST_HISTOGRAM_TABLE_OFFSET - byte offset of the first histogram table
// $percentile_start=8232;
// $percentile_start=8216;
$percentile_start=8192+ ELPHEL_CONST_HISTOGRAM_TABLE_OFFSET;
$colors=array(0=>"R",1=>"G",2=>"GB",3=>"B");
$h_raw=elphel_histogram_get_raw($needed,$frame);
//var_dump()
$h_raw_ul=unpack('V*',substr($h_raw,0,$percentile_start));
echo "<pre>\n";
$a=1; /// unpack started with index 1
$hframe= $h_raw_ul[$a++];
$gainr= $h_raw_ul[$a++];
$gaing= $h_raw_ul[$a++];
$gaingb= $h_raw_ul[$a++];
$gainb= $h_raw_ul[$a++];
$expos= $h_raw_ul[$a++];
$vexpos= $h_raw_ul[$a++];
$focus= $h_raw_ul[$a++];
$valid= $h_raw_ul[$a++];
$hash32_r= $h_raw_ul[$a++];
$hash32_g= $h_raw_ul[$a++];
$hash32_gb=$h_raw_ul[$a++];
$hash32_b= $h_raw_ul[$a++];
/// When not parsing all the data above - just skip ELPHEL_CONST_HISTOGRAM_TABLE_OFFSET bytes
printf ("Histogram for frame= %d (0x%x), valid mask=0x%x, requested=0x%x, data length=%d (0x%x)\n",$hframe,$hframe, $valid,$needed,strlen($h_raw),strlen($h_raw));
printf ("Exposure = %d (0x%x)usec, in scan lines (vexpos) =%d (0x%x)\n",$expos,$expos,$vexpos,$vexpos);
printf ("Gains: R:0x%x G:0x%x GB:0x%x B:0x%x)\n",$gainr,$gaing,$gaingb,$gainb);
printf ("Focus quality=%d (0x%x)\n",$focus,$focus);
printf ("hash32: R:0x%x G:0x%x GB:0x%x B:0x%x)\n",$hash32_r,$hash32_g,$hash32_gb,$hash32_b);
for ($color=0;$color<4;$color++) {
$sum=0;
for ($i=0; $i<256; $i++) $sum+=$h_raw_ul[$a+$i];
printf("\nhistogram for color #%d %s sum=%d (0x%x):",$color,$colors[$color],$sum,$sum);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$h_raw_ul[$a++];
printf (" %05x",$d);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$h_raw_ul[$a++];
printf (" %08x",$d);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\npercentile for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i);
printf (" %02x",ord($h_raw[$percentile_start+(256*$color)+$i]));
}
printf ("\n");
}
echo "</pre>\n";
}
function printRawFrame($frame) {
$fp_raw=elphel_framepars_get_raw($frame);
$fp_raw_ul=unpack('V*',$fp_raw);
echo "<pre>\n";
printf ("\nFrame= %d(%08x)\n",$frame,$frame);
$a=1; /// unpack started with index 1
echo ".pars:";
for ($i=0; $i<927; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.functions= %08x:",$fp_raw_ul[$a++]);
echo "\n.modsince:";
for ($i=0; $i<31; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.modsince32= %08x:",$fp_raw_ul[$a++]);
echo "\n.mod:";
for ($i=0; $i<31; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.mod32= %08x:",$fp_raw_ul[$a++]);
echo "\n.needproc:";
for ($i=0; $i<31; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.needproc32= %08x:",$fp_raw_ul[$a++]);
// var_dump($fp_raw_ul);
echo "</pre>\n";
}
function myval ($s) {
$current_frame=elphel_get_frame();
$s=trim($s,"\" ");
if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s));
else switch ($s) {
case "this": return elphel_get_frame();
break;
case "next":
case "next1": return elphel_get_frame()+1;
break;
case "next2": return elphel_get_frame()+2;
break;
case "next3": return elphel_get_frame()+3;
break;
case "next4": return elphel_get_frame()+4;
break;
case "next5": return elphel_get_frame()+5;
break;
case "next6": return elphel_get_frame()+6;
break;
break;
case "prev":
case "prev1": return elphel_get_frame()-1;
break;
case "prev2": return elphel_get_frame()-2;
break;
case "prev3": return elphel_get_frame()-3;
break;
case "prev4": return elphel_get_frame()-4;
break;
case "prev5": return elphel_get_frame()-5;
break;
case "prev6": return elphel_get_frame()-6;
break;
default:
return intval($s);
}
}
?>
<?php
/*!*******************************************************************************
*! FILE NAME : framepars.php
*! DESCRIPTION: Provides control of FPGA compressor/image acquisition
*! to the circular buffer (circbuf)
*! Copyright (C) 2007-2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: framepars.php,v $
*! Revision 1.3 2010/06/01 08:30:36 elphel
*! support for the FPGA code 03534022 with optional master time stamp over the inter-camera sync line(s)
*!
*! Revision 1.2 2010/05/13 03:35:28 elphel
*! updates to reflect current drivers
*!
*! Revision 1.1.1.1 2008/11/27 20:04:03 elphel
*!
*!
*! Revision 1.26 2008/11/27 09:29:22 elphel
*! new file - diag_utils.php that includes somewhat cleaned-up version of utilities from framepars.php. That file installation is moved to attic
*!
*! Revision 1.25 2008/11/17 23:42:04 elphel
*! changed myval() to accept numbers in ""
*!
*! Revision 1.24 2008/11/13 05:40:45 elphel
*! 8.0.alpha16 - modified histogram storage, profiling
*!
*! Revision 1.23 2008/11/04 17:45:08 elphel
*! added interface for testing new functions: elphel_gamma(), elphel_reverse_gamma(), elphel_histogram(), elphel_reverse_histogram(); links to individual gamma pages in the cache from "framepars.php?gamma_structure"
*!
*! Revision 1.22 2008/10/31 18:26:32 elphel
*! Adding support for constants like SENSOR_REGS32 (defined constant plus 32 to simplify referencing sensor registers from PHP
*!
*! Revision 1.21 2008/10/29 04:18:28 elphel
*! v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue)
*!
*! Revision 1.20 2008/10/28 07:03:03 elphel
*! reports error when wrong constant name is entered (before in silently used 0)
*!
*! Revision 1.19 2008/10/23 18:26:15 elphel
*! Fixed percentile calculations in histograms
*!
*! Revision 1.18 2008/10/23 08:11:58 elphel
*! support for histograms testing
*!
*! Revision 1.17 2008/10/22 03:47:45 elphel
*! minor
*!
*! Revision 1.16 2008/10/21 21:29:15 elphel
*! using support fro xml output in imgsrv
*!
*! Revision 1.15 2008/10/21 04:22:57 elphel
*! XTRA_FPGA=1000 is included in cmd=init
*!
*! Revision 1.14 2008/10/19 07:01:24 elphel
*! updated to use elphel_skip_frames();
*!
*! Revision 1.13 2008/10/18 06:16:49 elphel
*! changing test modes, init does not start compressor
*!
*! Revision 1.12 2008/10/15 22:28:56 elphel
*! snapshot 8.0.alpha2
*!
*! Revision 1.11 2008/10/13 16:57:18 elphel
*! switched to ELPHEL_* defined constants from locally defined ones
*!
*! Revision 1.10 2008/10/13 04:48:25 elphel
*! added sample gamma initialization to cmd=init
*!
*! Revision 1.8 2008/10/11 18:46:07 elphel
*! snapshot
*!
*! Revision 1.7 2008/10/10 17:06:59 elphel
*! just a snapshot
*!
*! Revision 1.6 2008/10/06 08:31:08 elphel
*! snapshot, first images
*!
*! Revision 1.5 2008/10/05 05:13:33 elphel
*! snapshot003
*!
*! Revision 1.4 2008/10/04 16:10:12 elphel
*! snapshot
*!
*! Revision 1.3 2008/09/28 00:31:57 elphel
*! snapshot
*!
*! Revision 1.2 2008/09/25 00:58:12 elphel
*! snapshot
*!
*! Revision 1.1 2008/09/22 22:55:50 elphel
*! snapshot
*!
*/
function myval ($s) {
$s=trim($s,"\" ");
if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s));
else return intval($s);
}
$imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081";
if (count($_GET)==0) {
echo <<<USAGE
<p>This is a collection of tools for the 8.0 software development/testing, you can provide parameters in HTTP GET request.</p>
<p>At this alpha stage very few programs/pages are working, among them:</p>
<ul>
<li><a href="tuneseq.php">tuneseq.php</a> - run-time tuning of sequencer latencies;</li>
<li><a href="$imgsrv">imgsrv</a> getting images from the camera internal buffer (you have to acquire them there first)</li>
<li><a href="var/klog.txt">var/klog.txt</a> - read kernel messages (you first need to telnet to the camera and run "printk_mod &amp;" and enable some of the DEBUG bits)</li>
</ul>
<h4>Make sure to run "printk_mod &amp;" before enabling debug bits - some are from interrupt service routine, and default printk() output to console can really mess up things.</h4>
<p>Here are some of the current options</p>
<ul>
<li><b>cmd=</b> - execute one of the following commands:
<ul>
<li><a href="?cmd=init">init</a> - initialize camera, detect sensor, put some gamma-table, start compressor. After that you may acquire image with
<a href="$imgsrv/img">$imgsrv/img</a></li>
<li><a href="?cmd=constants">constants</a> - list all Elphel-defined constants available in PHP scripts </li>
<li><a href="?cmd=gamma">gamma</a> - change gamma table (no gamma settings yet)</li>
<li><a href="?cmd=0">0</a> - show current frame (sensor frame - it is incrementead even if compressor is off), frame8 - hardware modulo 8 sequencer counter</li>
<li><a href="?cmd=jpegheader">jpegheader</a> - show current frame JPEG header</li>
</ul>
<p> There are some other options left out in the code, but they are not needed anymore - some others may be added
</li>
<li><b>a=A&amp;d=D&amp;=N[&amp;frame=F[&amp;flags=G]]</b> - Set parameter <b>A</b> with data<b>D</b> (hex data may be used).
Address can also use defined constant names (w/o "ELPHEL_" prefix). <b>F</b> - absolute frame number (most likely will fail) or one of
<b>this</b>, <b>next</b>, <b>next2</b>, <b>next3</b>, <b>next4</b>, <b>next5</b>, <b>next6</b> (next4 is usually safe to use). <G> - flags/modifiers - numeric value or "s" - static/not frame-related parameter or "n" - new parameter (force to be treated as new even if the value is the same as was before) </li>
<li><b>na=A&amp;d=D&amp;=N[&amp;frame=F[&amp;test=1]]</b> - shortcut for the previous command with the flag "n" (force new). test=1 - show a series of images around test command, i.e. <a href="?na=WOI_WIDTH&d=0xa20&frame=next3&test=1">na=WOI_WIDTH&amp;d=0xa20&amp;frame=next3&amp;test=1</a> would run compressor, skip 2 frames, change WOI_WIDTH 3 frames in the future, wait 4 frames and stop compressor. Then show last acquired images in a table.</li>
<li><b>sa=A&amp;d=D&amp;=N</b> - shortcut with the flag "s" (static), i.e. <a href="?sa=DEBUG&d=0">sa=DEBUG&amp;d=0</a> - turn debug logging off<br/></li>
<li><b>frame=F</b> - Print raw frame parameters data for frame <b>F</b>. Valid values 0..7 and -1 (that will show function triggers instead of the parameter values). Frame 0 also hold "static" parameters - when written with "s" flags they only go there other parameters propagate to the future frames during frame interrupts.</li>
<li><b>"gamma_structure</b> - show structure of the gamma tables cache. Gamma cache consists of 255 pages and index one, based on linked lists. It is designed to minimize floating point calcualions (made outside of the kernel) and facilitate scaling (integer) needed fro white balancing. So the "prototype" (non-scaled curves are cached in the top list with connected lists of scaled derivatives. For each table there are several sub-tables that can be requested (and cached after that) - reverse table (for histogram processing) and FPGA table (formatted to be written to the FPGA). Each gamma "type" is marked with a 16-bit hash, by default calculated as gamma value (in percents, 8 bits) and black level shift (fat zero), but it is possible to load arbitrary table and mark it with unique 16-bit hash16. When the curve is loaded it can be send to any of the 4 color channels with arbitrary 16-bit scale (0x400 is 1.0) by writing to one of GTAB_R, GTAB_G, GTAB_GB or GTAB_B registers (16 higher bits - hash16, lower 16 - scale, it is possible to change any set of bytes of the 32-bit word adding byte masks to the flags ELPHEL_CONST_FRAMEPAIR_BYTE0, ELPHEL_CONST_FRAMEPAIR_BYTE1, ELPHEL_CONST_FRAMEPAIR_BYTE2, ELPHEL_CONST_FRAMEPAIR_BYTE3, ELPHEL_CONST_FRAMEPAIR_WORD0,FRAMEPAIR_WORD1.</li>
<li><b>"gamma=G</b> - show raw data of the gamma page <b>G</b> (page 0 is a root)</li>
</ul>
USAGE;
exit (0);
}
//$_SERVER["SERVER_ADDR"] . ":8081
$address="";
$data="";
$frame="";
$gamma_page="";
$flags=0;
$elp_const=get_defined_constants(true);
$elp_const=$elp_const["elphel"];
$test=0;
$hist_needed=0;
foreach($_GET as $key=>$value) {
switch($key) {
case "profile":
$num_entries=myval($value);
//echo "<pre>";
$prof_template=array(
"PROFILE00"=>0,"PROFILE01"=>0,
"PROFILE02"=>0,"PROFILE03"=>0,
"PROFILE04"=>0,"PROFILE05"=>0,
"PROFILE06"=>0,"PROFILE07"=>0,
"PROFILE08"=>0,"PROFILE09"=>0,
"PROFILE10"=>0,"PROFILE11"=>0,
"PROFILE12"=>0,"PROFILE13"=>0,
"PROFILE14"=>0,"PROFILE15"=>0
);
$now=elphel_get_frame()-2; /// data is available 2 frames behind
$time_start=elphel_get_fpga_time();
$prof_raw=array();
for ($i=$now-$num_entries-1;$i<=$now;$i++) {
$prof_raw[$i]=elphel_get_P_arr($prof_template,$i);
}
$time_end=elphel_get_fpga_time();
$prof=array();
for ($i=$now-$num_entries;$i<=$now;$i++) {
$prof[$i]=array ( "dt0"=>($prof_raw[$i]["PROFILE00"]-$prof_raw[$i-1]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE01"]-$prof_raw[$i-1]["PROFILE01"]),
"dt1"=>($prof_raw[$i]["PROFILE02"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE03"]-$prof_raw[$i]["PROFILE01"]),
"dt2"=>($prof_raw[$i]["PROFILE04"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE05"]-$prof_raw[$i]["PROFILE01"]),
"dt3"=>($prof_raw[$i]["PROFILE06"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE07"]-$prof_raw[$i]["PROFILE01"]),
"dt4"=>($prof_raw[$i]["PROFILE08"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE09"]-$prof_raw[$i]["PROFILE01"]),
"dt5"=>($prof_raw[$i]["PROFILE10"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE11"]-$prof_raw[$i]["PROFILE01"]),
"dt6"=>($prof_raw[$i]["PROFILE12"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE13"]-$prof_raw[$i]["PROFILE01"]),
"dt7"=>($prof_raw[$i]["PROFILE14"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE15"]-$prof_raw[$i]["PROFILE01"]));
foreach ($prof[$i] as $key=>$value) if ($prof[$i][$key]<0)$prof[$i][$key]="";
}
echo <<<CAPTION
<p>reading profile time start=$time_start </p>
<p>reading profile time end=$time_end </p>
<ol>Profiling interrupt/tasklet execution time in microseconds, starting from the start of the frame
<li>after updating frame pointers, Exif, parameters structures (IRQ service)</li>
<li>start of the tasklet</li>
<li>after Y histogram (G1) load from the FPGA (if enabled)</li>
<li>after processing parameters (actions triggered by the parameter changes), </li>
<li>after C histograms (R,G2,B) load from the FPGA (if enabled)</li>
<li>When parameters are started to be written by appliaction(s) - overwritten if several calls take place during the same frame</li>
<li>When parameters are finished to be written by appliaction(s) (may be overwritten)</li>
</oul>
<br/><br/>
CAPTION;
printf ("<table border='1'><tr><td>Frame</td><td>(hex)</td><td>Period</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>\n");
for ($i=$now-$num_entries;$i<=$now;$i++) {
printf("<tr style='align:right'><td>%d</td><td>%08x</td><td>%d</td>",$i,$i,$prof[$i]["dt0"]);
for ($j=1;$j<8;$j++) {
if ($prof[$i]["dt".$j]) printf("<td>%d</td>",$prof[$i]["dt".$j]);
else printf("<td>&nbsp;</td>");
}
printf("</tr>\n");
}
printf("</table>");
//echo "<pre>";print_r($prof_raw);echo"</pre>\n";
exit (0);
case "histogram_direct":
case "histogram_reverse":
case "gamma_direct":
case "gamma_reverse":
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
$value=floatval($value);
switch($key) {
case "histogram_direct":
$xml->addChild ('histogram_direct_r', elphel_histogram(0,$value));
$xml->addChild ('histogram_direct_g', elphel_histogram(1,$value));
$xml->addChild ('histogram_direct_gb',elphel_histogram(2,$value));
$xml->addChild ('histogram_direct_b', elphel_histogram(3,$value));
break;
case "histogram_reverse":
$xml->addChild ('histogram_reverse_r', elphel_reverse_histogram(0,$value));
$xml->addChild ('histogram_reverse_g', elphel_reverse_histogram(1,$value));
$xml->addChild ('histogram_reverse_gb',elphel_reverse_histogram(2,$value));
$xml->addChild ('histogram_reverse_b', elphel_reverse_histogram(3,$value));
break;
case "gamma_direct":
$xml->addChild ('gamma_direct_r', elphel_gamma(0,$value));
$xml->addChild ('gamma_direct_g', elphel_gamma(1,$value));
$xml->addChild ('gamma_direct_gb',elphel_gamma(2,$value));
$xml->addChild ('gamma_direct_b', elphel_gamma(3,$value));
break;
case "gamma_reverse":
$xml->addChild ('gamma_reverse_r', elphel_reverse_gamma(0,$value));
$xml->addChild ('gamma_reverse_g', elphel_reverse_gamma(1,$value));
$xml->addChild ('gamma_reverse_gb',elphel_reverse_gamma(2,$value));
$xml->addChild ('gamma_reverse_b', elphel_reverse_gamma(3,$value));
break;
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
exit (0);
case "cmd":
case "seek":
case "fseek":
case "lseek":
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
if (!$value) {
$xml->addChild ('frame',elphel_get_frame());
$xml->addChild ('frame8',elphel_fpga_read(0x16) & 7);
} else if ($value=="time"){
$xml->addChild ('fpga_time',elphel_get_fpga_time());
} else if ($value=="irqoff"){
$framepars_file=fopen("/dev/frameparsall","r");
$xml->addChild ('irqoff_result',fseek($framepars_file,ELPHEL_LSEEK_INTERRUPT_OFF,SEEK_END)); //#define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts
fclose($framepars_file);
} else if ($value=="irqon"){
/// wait for frame8=0
while (elphel_fpga_read(0x16) & 7) usleep (1000); /// Maybe needed to wait for 7, then 0?
$framepars_file=fopen("/dev/frameparsall","r");
$xml->addChild ('irqon_result',fseek($framepars_file,ELPHEL_LSEEK_INTERRUPT_ON,SEEK_END)); //#define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
fclose($framepars_file);
} else if ($value=="init"){
$framepars_file=fopen("/dev/frameparsall","r");
$xml->addChild ('LSEEK_FRAMEPARS_INIT',fseek($framepars_file,ELPHEL_LSEEK_FRAMEPARS_INIT,SEEK_END));
$xml->addChild ('elphel_set_P_value', elphel_set_P_value(ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC));/// will start detection
$xml->addChild ('LSEEK_SENSORPROC', fseek($framepars_file,ELPHEL_LSEEK_SENSORPROC, SEEK_END));
$frame=0;
// gets half-frame
/*
elphel_set_P_value(ELPHEL_BITS, 8, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
*/
/*
//works
elphel_set_P_value(ELPHEL_BITS, 8, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
*/
/*
wrong
elphel_set_P_value(ELPHEL_BITS, 8, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_BITS, 8, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
*/
/*
elphel_set_P_value(ELPHEL_BITS, 8, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+5, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
*/
elphel_set_P_value(ELPHEL_MAXAHEAD, 2, 0, 8); /// When servicing interrupts, try programming up to 2 frames ahead of due time)
elphel_set_P_value(ELPHEL_FPGA_XTRA, 1000, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); ///compressor needs extra 1000 cycles to compress a frame (estimate)
elphel_set_P_value(ELPHEL_EXTERN_TIMESTAMP, 1, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); /// only used with async trigger
/// good (latency should be changed, but for now that will make a correct initialization - maybe obsolete)
elphel_set_P_value(ELPHEL_BITS, 8, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_BAYER, 0, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COMPRESSOR_RUN, 2, $frame+4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); /// run compressor
/*
elphel_set_P_value(ELPHEL_BITS, 8, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
*/
fclose($framepars_file);
/*
} else if ($value=="gamma1"){
*/
$gamma=57;
$black=10;
$scale_r= (int) (1.0 * 1024);
$scale_g= (int) (0.9 * 1024);
$scale_b= (int) (1.1 * 1024);
$scale_gb=(int) (0.9 * 1024);
elphel_gamma_add (0.01*$gamma, $black);
#define P_GTAB_R 138 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniqualy identify the table for applications
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff));
$frame=elphel_get_frame(); //0
elphel_set_P_arr ($gamma_pars, $frame+3,0);
} else if ($value=="gamma57"){
$gamma=57;
$black=10;
$scale_r= (int) (1.0 * 1024);
$scale_g= (int) (1.0 * 1024);
$scale_b= (int) (1.0 * 1024);
$scale_gb=(int) (1.0 * 1024);
elphel_gamma_add (0.01*$gamma, $black);
#define P_GTAB_R 138 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff));
$frame=elphel_get_frame(); //0
elphel_set_P_arr ($gamma_pars, $frame+3,0);
} else if ($value=="gamma"){
$gamma=60;
$black=10;
$scale_r= (int) (1.0 * 1024);
$scale_g= (int) (0.9 * 1024);
$scale_b= (int) (1.1 * 1024);
$scale_gb=(int) (0.9 * 1024);
elphel_gamma_add (0.01*$gamma, $black);
#define P_GTAB_R 138 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff));
$frame=elphel_get_frame(); //0
elphel_set_P_arr ($gamma_pars, $frame+3,0);
} else if ($value=="linear"){
$gamma=100;
$black=0;
$scale_r= (int) (1.0 * 1024);
$scale_g= (int) (1.0 * 1024);
$scale_b= (int) (1.0 * 1024);
$scale_gb=(int) (1.0 * 1024);
elphel_gamma_add (0.01*$gamma, $black);
#define P_GTAB_R 138 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff));
$frame=elphel_get_frame(); //0
elphel_set_P_arr ($gamma_pars, $frame+3,0);
} else if ($value=="initgamma"){
$gammas_file=fopen("/dev/gamma_cache","r");
$xml->addChild ('LSEEK_GAMMA_INIT',fseek($gammas_file,ELPHEL_LSEEK_GAMMA_INIT,SEEK_END));
fclose($gammas_file);
} else if ($value=="jpegheader"){
$circbuf_file=fopen("/dev/circbuf","r");
fseek($circbuf_file,ELPHEL_LSEEK_CIRC_LAST,SEEK_END);
$jpeg_start=ftell($circbuf_file);
$xml->addChild ('circbuf_pointer',sprintf("0x%x (0x%x)",$jpeg_start,$jpeg_start>>2));
fclose($circbuf_file);
$header_file=fopen("/dev/jpeghead","r");
/// Now select right frame (different frames may have different header sizes)
fseek($header_file,$jpeg_start+1,SEEK_END); /// selects frame, creates header
fseek($header_file,0,SEEK_END); /// positions to the end
$header_size=ftell($header_file); ///
$xml->addChild ('header_size',$header_size);
fseek($header_file,0,SEEK_SET); /// positions to the beginning
$header=fread ($header_file,8192);
$xml->addChild ('header_read_length',strlen($header));
fclose($header_file);
$aheader=unpack('C*',$header);
for ($i=0; $i<count($aheader) ;$i+=16){
$d="";
for ($j=$i; ($j<$i+16) && ($j<count($aheader)); $j++) $d.=sprintf(" %02x",$aheader[$j+1]);
$xml->addChild (sprintf('header%03x',$i),$d);
}
} else if ($value=="reset"){
$framepars_file=fopen("/dev/frameparsall","r");
$xml->addChild ('LSEEK_DMA_STOP', fseek($framepars_file,ELPHEL_LSEEK_DMA_STOP,SEEK_END));
$xml->addChild ('LSEEK_DMA_INIT', fseek($framepars_file,ELPHEL_LSEEK_DMA_INIT,SEEK_END));
$xml->addChild ('LSEEK_COMPRESSOR_RESET', fseek($framepars_file,ELPHEL_LSEEK_COMPRESSOR_RESET,SEEK_END));
fclose($framepars_file);
} else if ($value=="constants"){
echo "<pre>\n";
print_r($elp_const);
echo "</pre>\n";
exit(0);
} else {
$framepars_file=fopen("/dev/frameparsall","r");
$xml->addChild ('lseek_'.$value,fseek($framepars_file,$value,SEEK_END));
fclose($framepars_file);
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
exit (0);
case "a": /// Make it recognize P_* constants?
case "adr":
case "na": /// add flag "new"
case "sa": /// add flag "static"
$address=myval ($value);
if (($address==0) && (strlen($value)>3)) { // suspect constant
$address=$elp_const["ELPHEL_".$value];
}
switch ($key){
case "na": /// flags defined in upper half of 32-bit word and can be OR-ed with address. When provided as "flags=" 0x3 is the same as 0x30000 ( internally flags = (flags | (flags <<16)) & 0xffff0000)
$address |= ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC;;
break;
case "sa":
$address |= ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO;
break;
}
if (($address & 0xffff) ==0) { /// wrong address - probably mistyped constant name
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
$xml->addChild ('ERROR','"Wrong address==0, probably misspelled constant: \''.$value.'\'"' );
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
exit (0);
}
break;
case "d":
case "data":
$data=myval ($value);
break;
case "hist_raw":
$hist_needed++;
case "hist":
case "histogram":
$hist_needed++; /// and fall to "frame"
case "f":
case "frame":
$current_frame=elphel_get_frame();
switch ($value) {
case "this": $frame=$current_frame;
break;
case "next": $frame=$current_frame+1;
break;
case "next2": $frame=$current_frame+2;
break;
case "next3": $frame=$current_frame+3;
break;
case "next4": $frame=$current_frame+4;
break;
case "next5": $frame=$current_frame+5;
break;
case "next6": $frame=$current_frame+6;
break;
break;
case "prev": $frame=$current_frame-1;
break;
case "prev2": $frame=$current_frame-2;
break;
case "prev3": $frame=$current_frame-3;
break;
case "prev4": $frame=$current_frame-4;
break;
case "prev5": $frame=$current_frame-5;
break;
case "prev6": $frame=$current_frame-6;
break;
default:
$frame=myval ($value);
}
break;
case "flags": /// simple flags - "z(ero)"/"(s(tatic), "n(new)",+ constants
case "flag":
switch ($value) {
case "z":
case "zero":
case "s":
case "static":
$flags=ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO;
break;
case "n":
case "new":
$flags=ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC;
break;
default:
$flags=myval ($value);
}
break;
case "t":
case "test":
$test=myval ($value);
break;
case "gamma":
case "gamma_page":
$gamma_page=myval ($value);
break;
case "gamma_structure":
/// later add value - list of pages to process
printGammaStructure();
/* echo "<pre>\n";
var_dump(getGammaStructure());
echo "</pre>\n";*/
exit (0);
}
}
if ($address==="") {
if ($frame==="") {
if ($gamma_page==="") {
echo <<<USAGE
<p>read/fwrite frame parameters, execute commands</p>
<ul>
<li><b>framepars.php?cmd=<i>command number</i></b> - execute <i>register_address</i></li>
<li><b>framepars.php?a[dr]=<i>register_address</i>[&f[rame]=<i>frame_number</i>]</b> - read frame parameter <i>register_address</i> from <i>frame_number</i></li>
<li><b>framepars.php?a[dr]=<i>register_address</i>&d[ata]=<i>register_data</i>[&f[rame]=<i>frame_number</i>][&flag[s]=<i>flags</i>]</b> - write frame parameter <i>register_address</i> with data <i>register_data</i> to frame <i>frame_number</i>, optionally use <i>flags</i></li>
</ul>
USAGE;
exit (0);
} else {
///read raw gamma page
printRawGamma($gamma_page);
exit (0);
}
} else { ///$frame !== ""
switch ($hist_needed) {
case 2:
printRawHistogram(0xfff,$frame);
exit (0);
case 1:
printHistogram($frame);
exit (0);
default:
/// read raw framepars
printRawFrame($frame);
exit (0);
}
}
}
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
$xml->addChild ('frame',$frame);
$xml->addChild ('hex_frame',sprintf("0x%x",$frame));
$xml->addChild ('address',$address);
$xml->addChild ('hex_address',sprintf("0x%x",$address));
if ($data==="") {
if ($frame==='') $data=elphel_get_P_value($address);
else $data=elphel_get_P_value($address, $frame);
$xml->addChild ('read',$data);
$xml->addChild ('hex_read',sprintf("0x%x",$data));
} else {
if (($frame==='') && flags) $frame =0;
$xml->addChild ('frame_was',$frame);
///***************************************************************************
if ($test>0) {
ob_flush(); flush();
elphel_set_P_value(ELPHEL_COMPRESSOR_RUN | ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC, ELPHEL_CONST_COMPRESSOR_RUN_CONT, $current_frame+2);
$frame+=2;
$current_frame+=2;
elphel_skip_frames(2);
}
if ($frame==='') elphel_set_P_value($address, $data);
else elphel_set_P_value($address, $data, $frame, $flags);
if ($test>0) {
printf ("<p><a href=\"%s/prev/prev/prev/prev/prev/prev/prev/prev/meta/next/meta/next/meta/next/meta/next/meta/next/meta/next/meta/next/meta/next/meta\">meta data for the last 9 frames</a></p>\n", $imgsrv);
ob_flush(); flush(); ///OK here
$circbuf_file=fopen("/dev/circbuf","r");
$current_frame=$frame;
printf ("<p>frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
elphel_skip_frames(2);
printf ("<p>target frame=%d (0x%x) frame=%d(0x%x), time=%d </p>\n",$frame, $frame, elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
// printf ("<p>start_frame2=0x%x</p>\n",$current_frame);
elphel_set_P_value(ELPHEL_COMPRESSOR_RUN | ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC, ELPHEL_CONST_COMPRESSOR_RUN_STOP, $current_frame+4);
printf ("<p>frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
$current_frame+=6; /// to be sure - less is enough?
for ($i=0;$i<6;$i++) {
elphel_skip_frames(1);
printf ("<p>skipped 1 frame - frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
}
// elphel_skip_frames(6);
// printf ("<p>after skip 6 frames - frame=0x%x, time=%d </p>\n",elphel_get_frame(),time()); ob_flush(); flush();
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END);
///stuck before here?
printf ("<p>frame=%d (0x%x) time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
elphel_skip_frames(1);
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END);
printf ("<p>frame=%d (0x%x) time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
elphel_skip_frames(1);
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END);
printf ("<p>frame=%d (0x%x) time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
elphel_skip_frames(1);
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END);
printf ("<p>frame=%d (0x%x) time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush();
/// Strange - frame normal delay sometimes wrong images in the
// printf ("<p>end_frame2=0x%x</p>\n",elphel_get_frame());
fclose($circbuf_file);
image_table8 ();
exit (0);
$xml->addChild ('test',$test);
}
$xml->addChild ('frame',$frame);
$xml->addChild ('written',$data);
$xml->addChild ('hex_written',sprintf("0x%x",$data));
$xml->addChild ('flags',sprintf("0x%x",$flags));
}
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
exit (0);
function printGammaStructure() {
$gammaStructure=getGammaStructure();
printf("<table \"border=1\">\n");
printf( "<tr><td>oldest_non_scaled</td><td><b>%d</b></td></tr>\n"
."<tr><td>newest_non_scaled</td><td><b>%d</b></td></tr>\n"
."<tr><td>oldest_all</td><td><b>%d</b></td></tr>\n"
."<tr><td>newest_all</td><td><b>%d</b></td></tr>\n"
."<tr><td>non_scaled_length</td><td><b>%d</b></td></tr>\n"
."<tr><td>num_locked</td><td><b>%d</b></td></tr>\n"
."<tr><td>locked_col 0</td><td><b>%d</b></td>\n"
."<tr><td>locked_col 1</td><td><b>%d</b></td>\n"
."<tr><td>locked_col 2</td><td><b>%d</b></td>\n"
."<tr><td>locked_col 3</td><td><b>%d</b></td>\n"
."</table>\n",
$gammaStructure["oldest_non_scaled"],
$gammaStructure["newest_non_scaled"],
$gammaStructure["oldest_all"],
$gammaStructure["newest_all"],
$gammaStructure["non_scaled_length"],
$gammaStructure["num_locked"],
$gammaStructure["locked_col"][0],
$gammaStructure["locked_col"][1],
$gammaStructure["locked_col"][2],
$gammaStructure["locked_col"][3]
);
printf("<br/><br/>\n");
printf("<table \"border=1\">\n");
// printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["index"]);printf("</tr>\n");
printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry)
printf ("<td><a href='?gamma_page=%d'><b>%d</b></a></td>",$entry["index"],$entry["index"]);printf("</tr>\n");
printf("<tr><td>hash32 </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%08x</b></td>",$entry["hash32"]);printf("</tr>\n");
printf("<tr><td>scale </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["scale"]);printf("</tr>\n");
printf("<tr><td>gamma </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["gamma"]);printf("</tr>\n");
printf("<tr><td>black </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["black"]);printf("</tr>\n");
printf("<tr><td>valid </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%x</b></td>",$entry["valid"]);printf("</tr>\n");
printf("<tr><td>locked </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%8x</b></td>",$entry["locked"]);printf("</tr>\n");
printf("<tr><td>this_non_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["this_non_scaled"]);printf("</tr>\n");
printf("<tr><td>newer_non_scaled</td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_non_scaled"]);printf("</tr>\n");
printf("<tr><td>older_non_scaled</td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_non_scaled"]);printf("</tr>\n");
printf("<tr><td>newer_all </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_all"]);printf("</tr>\n");
printf("<tr><td>older_all </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_all"]);printf("</tr>\n");
printf("<tr><td>oldest_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["oldest_scaled"]);printf("</tr>\n");
printf("<tr><td>newest_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newest_scaled"]);printf("</tr>\n");
printf("<tr><td>newer_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_scaled"]);printf("</tr>\n");
printf("<tr><td>older_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_scaled"]);printf("</tr>\n");
printf("</table>\n");
}
function getGammaStructure() {
$gammas_file=fopen("/dev/gamma_cache","r");
fseek($gammas_file,0,SEEK_END);
$numberOfEntries=ftell($gammas_file);
fclose($gammas_file);
$gammaStructure=array();
$g_raw=elphel_gamma_get_raw(0);
$g_raw_ul=unpack('V*',$g_raw);
$gammaStructure["oldest_non_scaled"]=$g_raw_ul[5];
$gammaStructure["newest_non_scaled"]=$g_raw_ul[6];
$gammaStructure["oldest_all"]= $g_raw_ul[7];
$gammaStructure["newest_all"]= $g_raw_ul[8];
$gammaStructure["non_scaled_length"]=$g_raw_ul[9];
$gammaStructure["num_locked"]= $g_raw_ul[10];
$gammaStructure["locked_col"]= array ($g_raw_ul[11],$g_raw_ul[12],$g_raw_ul[13],$g_raw_ul[14]);
$gammaStructure["entries"]= array ();
for ($i=1; $i<$numberOfEntries; $i++) {
$g_raw=elphel_gamma_get_raw($i);
$g_raw_ul=unpack('V*',$g_raw);
if ($g_raw_ul[ 4]>=0) { /// >=0 if ever used. This field seems to do nothing in the code.
$hash32= $g_raw_ul[1];
$gammaStructure["entries"][$i]= array (
"index" => $i,
"hash32"=> $hash32,
"scale" => ($hash32 & 0xffff)/1024.0,
"gamma" => (($hash32 >> 16) & 0xff)/100.0,
"black" => (($hash32 >> 24) & 0xff),
"valid" => $g_raw_ul[ 2], /// 0 - table invalid, 1 - table valid +2 for table locked (until sent to FPGA)
"locked" => $g_raw_ul[ 3], /// bit frame+ (color<<3) locked for color/frame
"this_non_scaled" => $g_raw_ul[ 4], /// 0 for non-scaled, others - (for scaled) - pointer to the corresponding non-scaled
/// This is non-scaled (gamma data is full 16-bit)
"newer_non_scaled" => $g_raw_ul[ 5], /// table type (non-scaled prototype) used later than this one
"older_non_scaled" => $g_raw_ul[ 6], /// table type (non-scaled prototype) used before this one
"newer_all" => $g_raw_ul[ 7], /// newer in a single chain of all scaled tables, regardless of the prototype
"older_all" => $g_raw_ul[ 8], /// older in a single chain of all scaled tables, regardless of the prototype
///Next two pairs are the same (union)
"oldest_scaled" => $g_raw_ul[ 9], /// oldest derivative of this prototype (scaled)
"newest_scaled" => $g_raw_ul[10], /// newest derivative of this prototype (scaled)
"newer_scaled" => $g_raw_ul[ 9], /// table type (non-scaled prototype) used later than this one
"older_scaled" => $g_raw_ul[10] /// table type (non-scaled prototype) used before this one
);
}
}
return $gammaStructure;
}
function printRawGamma($page=0) {
$g_raw=elphel_gamma_get_raw($page);
//var_dump()
$g_raw_ul=unpack('V*',$g_raw);
echo "<pre>\n";
printf ("Gamma cache page %d, length=%d\n",$page, strlen($g_raw));
$a=1; /// unpack started with index 1
$hash32= $g_raw_ul[$a++];
$scale= ($hash32 & 0xffff)/1024.0;
$gamma= (($hash32 >> 16) & 0xff)/100.0;
$black= (($hash32 >> 24) & 0xff);
printf ("hash32= %08x (scale=%f gamma=%f black=%d)\n",$hash32,$scale,$gamma,$black);
$valid= $g_raw_ul[$a++];
printf ("valid=%d, locked=%d\n",$valid & 1, $valid & 2);
$locked= $g_raw_ul[$a++];
printf ("locked= 0x%x (for frame=%d/color=%d)\n",$locked, $locked & 7, ($locked>>3) & 3);
$this_non_scaled=$g_raw_ul[$a++]; /// 0 for non-scaled
printf ("this_non_scaled=%d\n",$this_non_scaled);
if ($page==0) {
printf ("oldest_non_scaled=%d\n",$g_raw_ul[$a++]);
printf ("newest_non_scaled=%d\n",$g_raw_ul[$a++]);
} else {
printf ("newer_non_scaled=%d\n",$g_raw_ul[$a++]);
printf ("older_non_scaled=%d\n",$g_raw_ul[$a++]);
}
if ($page==0) {
printf ("oldest_all=%d\n",$g_raw_ul[$a++]);
printf ("newest_all=%d\n",$g_raw_ul[$a++]);
} else {
printf ("newer_all=%d\n",$g_raw_ul[$a++]);
printf ("older_all=%d\n",$g_raw_ul[$a++]);
}
if ($page==0) {
printf ("non_scaled_length=%d\n",$g_raw_ul[$a++]); /// current number of different hash values
printf ("num_locked=%d\n",$g_raw_ul[$a++]); /// number of nodes locked (until table sent to FPGA)
} else if ($this_non_scaled==0){
printf ("oldest_scaled=%d\n",$g_raw_ul[$a++]);
printf ("newest_scaled=%d\n",$g_raw_ul[$a++]);
} else {
printf ("newer_scaled=%d\n",$g_raw_ul[$a++]);
printf ("older_scaled=%d\n",$g_raw_ul[$a++]);
}
///data tables
if ($page==0) {
printf ("\nTable of locked indexes\n");
for ($color=0;$color<4; $color++) {
// for ($frame=0;$frame<8; $frame++) {
printf (" %4d",$g_raw_ul[$a++]);
// }
// printf ("\n");
}
printf ("\n");
/// no need to dump the rest - it is unused in the page 0
printf ("\n\nUnused area on page 0:");
// for ($i=0; $i<417; $i++) {
for ($i=0; $i<445; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$g_raw_ul[$a++];
printf (" %08x",$d);
}
} else {
printf ("\nGamma table (direct):");
for ($i=0; $i<129; $i++) {
if (($i & 0x07)==0) printf ("\n0x%03x:",$i*2);
$d=$g_raw_ul[$a++];
printf (" %04x %04x",$d & 0xffff, ($d>>16) & 0xffff );
}
printf ("\n\nGamma table (reverse):");
for ($i=0; $i<64; $i++) {
if (($i & 0x03)==0) printf ("\n0x%03x:",$i*4);
$d=$g_raw_ul[$a++];
printf (" %02x %02x %02x %02x",$d & 0xff, ($d>>8) & 0xff, ($d>>16) & 0xff, ($d>>24) & 0xff);
}
printf ("\n\nFPGA gamma data:");
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$g_raw_ul[$a++];
printf (" %05x",$d);
}
}
echo "</pre>\n";
}
/*
struct histogram_stuct_t {
unsigned long frame; /// frame number correspoding to the current histogram
unsigned long valid; /// bit mask of valid arrays (0 - hist_r, ... ,4-cumul_hist_r, ..., 11 - percentile_b)
/// Direct histograms, loaded from the FPGA
union {
unsigned long hist[1024] ; /// All 4 histograms
struct {
unsigned long hist_r [256] ; /// Histogram for the red component
unsigned long hist_g [256] ; /// Histogram for the first green component (in the "red" line)
unsigned long hist_gb[256] ; /// Histogram for the second green component (in the "blue" line)
unsigned long hist_b [256] ; /// Histogram for blue component
};
};
/// Direct cumulative histograms, calculated from the loaded from the FPGA
union {
unsigned long cumul_hist[1024] ; /// All 4 cumulative histograms
struct {
unsigned long cumul_hist_r [256] ; /// Cumulative histogram for the red component
unsigned long cumul_hist_g [256] ; /// Cumulative histogram for the first green component (in the "red" line)
unsigned long cumul_hist_gb[256] ; /// Cumulative histogram for the second green component (in the "blue" line)
unsigned long cumul_hist_b [256] ; /// Cumulative histogram for blue component
};
};
/// Calculated reverse cumulative histograms (~percentiles) - for the given 1 byte input X (0 - 1/256 of all pixels, ..., 255 - all pixels)
/// returns threshold value P (0..255), so that number of pixels with value less than x is less or equal to (P/256)*total_number_of_pixels,
/// and number of pixels with value less than (x+1) is greater than (P/256)*total_number_of_pixels,
/// P(0)=0, P(256)=256 /not included in the table/
/// percentiles arrays are calculated without division for each element, interpolation (with division) will be done only for the value of interest
/// on demand, in the user space.
/// NOTE: - argument is _output_ value (after gamma-correction), reverse gamma table is needed to relate percentiles to amount of light (proportional to exposure)
union {
unsigned char percentile[1024] ; /// All 4 percentiles
struct {
unsigned char percentile_r [256] ; /// percentile for the red component
unsigned char percentile_g [256] ; /// percentile for the first green component (in the "red" line)
unsigned char percentile_gb[256] ; /// percentile for the second green component (in the "blue" line)
unsigned char percentile_b [256] ; /// percentile for the blue component
};
};
};
*/
function printHistogram($frame) {
$colors=array(0=>"R",1=>"G",2=>"GB",3=>"B");
$h_arr=elphel_histogram_get(0xfff,$frame);
$a=0;
$offset2sum=1024+255; /// last in cumulative histogram for the same color
echo "<pre>\n";
for ($color=0;$color<4;$color++) {
printf("\nhistogram for color #%d %s, Total number of pixels=%d (0x%x):",$color,$colors[$color],$h_arr[$a+$offset2sum],$h_arr[$a+$offset2sum]);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %05x",$h_arr[$a++]);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x",$h_arr[$a++]);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\npercentile for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i);
printf (" %02x",$h_arr[$a++]);
}
printf ("\n");
}
echo "</pre>\n";
}
function printRawHistogram($needed,$frame) {
$percentile_start=8232;
$colors=array(0=>"R",1=>"G",2=>"GB",3=>"B");
$h_raw=elphel_histogram_get_raw($needed,$frame);
//var_dump()
$h_raw_ul=unpack('V*',substr($h_raw,0,$percentile_start));
echo "<pre>\n";
$a=1; /// unpack started with index 1
$hframe= $h_raw_ul[$a++];
$valid= $h_raw_ul[$a++];
$hash32_r= $h_raw_ul[$a++];
$hash32_g= $h_raw_ul[$a++];
$hash32_gb=$h_raw_ul[$a++];
$hash32_b= $h_raw_ul[$a++];
printf ("Histogram for frame= %d (0x%x), valid mask=0x%x, requested=0x%x, data length=%d (0x%x)\n",$hframe,$hframe, $valid,$needed,strlen($h_raw),strlen($h_raw));
printf ("hash32: R:0x%x G:0x%x GB:0x%x B:0x%x)\n",$hash32_r,$hash32_g,$hash32_gb,$hash32_b);
for ($color=0;$color<4;$color++) {
$sum=0;
for ($i=0; $i<256; $i++) $sum+=$h_raw_ul[$a+$i];
printf("\nhistogram for color #%d %s sum=%d (0x%x):",$color,$colors[$color],$sum,$sum);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$h_raw_ul[$a++];
printf (" %05x",$d);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
$d=$h_raw_ul[$a++];
printf (" %08x",$d);
}
printf ("\n");
}
for ($color=0;$color<4;$color++) {
printf("\npercentile for color #%d %s:",$color,$colors[$color]);
for ($i=0; $i<256; $i++) {
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i);
printf (" %02x",ord($h_raw[$percentile_start+(256*$color)+$i]));
}
printf ("\n");
}
echo "</pre>\n";
}
function printRawFrame($frame) {
$fp_raw=elphel_framepars_get_raw($frame);
$fp_raw_ul=unpack('V*',$fp_raw);
echo "<pre>\n";
printf ("\nFrame= %d(%08x)\n",$frame,$frame);
$a=1; /// unpack started with index 1
echo ".pars:";
for ($i=0; $i<927; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.functions= %08x:",$fp_raw_ul[$a++]);
echo "\n.modsince:";
for ($i=0; $i<31; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.modsince32= %08x:",$fp_raw_ul[$a++]);
echo "\n.mod:";
for ($i=0; $i<31; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.mod32= %08x:",$fp_raw_ul[$a++]);
echo "\n.needproc:";
for ($i=0; $i<31; $i++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
printf (" %08x:",$fp_raw_ul[$a++]);
}
printf ("\n.needproc32= %08x:",$fp_raw_ul[$a++]);
// var_dump($fp_raw_ul);
echo "</pre>\n";
}
function image_table8 (){
global $imgsrv;
// $back=6;
// $min_back=1;
$back=8;
$min_back=0;
printf ("<table>\n");
$scale="100%";
$row_open=$false;
for ($hist=$back;$hist>=$min_back;$hist--) {
if (!(($back-$hist) % 3)) {
if ($row_open) printf ("</tr>\n");
printf ("<tr>");
$row_open=true;
}
$url=$imgsrv;
for ($i=0;$i<$hist;$i++) $url.='/prev';
// $url .= '/img';
printf ('<td><a href="%s"><img src="%s" width="%s" height="%s"/><br \>%d</a>&nbsp;&nbsp;<a href="%s">meta</a></td>',$url.'/img',$url.'/img',$scale,$scale,$hist,$url.'/meta');
}
if ($row_open) printf ("</tr>\n");
printf ("</table>\n");
}
?>
#!/usr/local/sbin/php -q
<?php
/*!
*! PHP script
*! FILE NAME : parsedit.php
*! DESCRIPTION:
*! AUTHOR : Elphel, Inc.
*! Copyright (C) 2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: parsedit.php,v $
*! Revision 1.12 2012/01/13 23:49:51 elphel
*! no waits in GET mode
*!
*! Revision 1.11 2012/01/12 08:22:47 elphel
*! removed final waiting in HTTP GET mode
*!
*! Revision 1.9 2010/06/08 19:40:22 elphel
*! using bimg instead of img in imgsrv (configurable)
*!
*! Revision 1.8 2010/06/01 08:30:36 elphel
*! support for the FPGA code 03534022 with optional master time stamp over the inter-camera sync line(s)
*!
*! Revision 1.7 2010/04/30 00:29:33 elphel
*! new urls, example with explanations
*!
*! Revision 1.6 2010/04/28 02:27:13 elphel
*! Added link to control "photofinish" (line scan) modes
*!
*! Revision 1.5 2010/02/20 20:34:50 elphel
*! Added color gains control panel, with nothing else
*!
*! Revision 1.4 2008/12/05 03:32:31 elphel
*! minor circbuf format change, support fro COMPRESSOR_SINGLE
*!
*! Revision 1.3 2008/11/30 05:32:59 elphel
*! Added WB_EN to be able to turn white balance on/off independently of the WB_MASK
*!
*! Revision 1.2 2008/11/30 05:01:03 elphel
*! Changing gains/scales behavior
*!
*! Revision 1.1.1.1 2008/11/27 20:04:03 elphel
*!
*!
*! Revision 1.20 2008/11/20 23:23:19 elphel
*! Now shows descriptions for composite names - bit selections and indexed
*!
*! Revision 1.19 2008/11/20 07:04:15 elphel
*! support for parameter descriptions
*!
*! Revision 1.18 2008/11/18 07:36:27 elphel
*! Added "Select All" button
*!
*! Revision 1.17 2008/11/17 23:42:04 elphel
*! changed myval() to accept numbers in ""
*!
*! Revision 1.16 2008/11/16 17:34:32 elphel
*! default settings
*!
*! Revision 1.15 2008/11/16 00:24:21 elphel
*! Added "Uncheck All" button
*!
*! Revision 1.14 2008/11/15 07:04:27 elphel
*! new parameters to modify analog gains while white balancing
*!
*! Revision 1.13 2008/11/15 03:10:13 elphel
*! Some parameters renamed, reassigned.
*!
*! Revision 1.12 2008/11/13 05:40:45 elphel
*! 8.0.alpha16 - modified histogram storage, profiling
*!
*! Revision 1.11 2008/11/08 05:53:33 elphel
*! removed commented out code
*!
*! Revision 1.10 2008/11/05 02:01:25 elphel
*! Added bit field manipulation in parameters
*!
*! Revision 1.9 2008/11/03 19:21:03 elphel
*! wrong value for TRIG_PERIOD (it is in pixel clocks, not usec)
*!
*! Revision 1.8 2008/11/02 00:55:10 elphel
*! added analog gain control (in white balance page)
*!
*! Revision 1.7 2008/11/02 00:34:55 elphel
*! added initialization of the camera, multiple demo links on default page
*!
*! Revision 1.6 2008/11/01 06:37:59 elphel
*! minor bug fix
*!
*! Revision 1.5 2008/11/01 06:26:12 elphel
*! added optional image to the control page
*!
*! Revision 1.4 2008/10/31 23:16:28 elphel
*! Now generates last acquired images, annotating them with sequencer commands
*!
*! Revision 1.3 2008/10/31 18:26:32 elphel
*! Adding support for constants like SENSOR_REGS32 (defined constant plus 32 to simplify referencing sensor registers from PHP
*!
*! Revision 1.2 2008/10/29 05:29:20 elphel
*! snapshot
*!
*! Revision 1.1 2008/10/29 04:29:29 elphel
*! started a new script to edit arbitrary camera parameters through web interface
*!
*/
//main()
///globals
$autocampars='/usr/html/autocampars.php';
$descriptions=getParDescriptions($autocampars);
$default_ahead=3;
$maxahead=6; /// maximal ahead of the current frame that tasks can currently be set to driver;
$minahead=4; /// skip to frame $minahead from the soonest next task before programming
$brief=true;
$ahead_separator='*';
$refreshSig="refresh";
$testMode=-1; /// don't even show
$showSeqMode=-1;/// don't even show
$testBefore=2;/// Start compressor $testBefore frames before first task
$testAfter=2; /// Stop compressor $testAfter frames after the last task
$framesBeforeStart=2; ///In test mode - compressor will be started theis frames after "now"
$imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081";
/// $imglink="img"; /// use this for faster output (and safer in simultaneous accesses from multiple hosts
$imglink="bimg"; ///It was "img" - faster, but image may get corrupted if buffer is overrun before it is trasferred (network congestion)
$defaultImgScale=0.2; /// 20% image size
$defaultImagesPerRow=3;
$defaultImagesNumber=9;
$isPost=$_SERVER["REQUEST_METHOD"]=="POST";
$ignoreVals=$isPost;
$imagesNumber=$defaultImagesNumber;
$imagesPerRow=$defaultImagesPerRow;
$imgScale=$defaultImgScale;
$embedImageScale=0;
$defaultEmbedImageScale=0.3;
$encoded_todo="";
if ($isPost) {
parsePost();
$todo=preparePost();
}
$page_title="Default control/test page for the NC353L camera";
if (count($_GET)==0) {
startPage($page_title, "");
printDefaultPage();
endPage();
exit (0);
}
$elp_const=get_defined_constants(true);
$elp_const=$elp_const["elphel"];
$immediateMode=parseGetNames();
if ($immediateMode){
convertImmediateMode();
$todo=preparePost();
if ($showSeqMode>0) { // use regular html page
startPage($page_title, "");
echo "<!--\n";
echo "global_params:\n";
var_dump($global_params);
echo "frame_params:\n";
var_dump($frame_params);
echo "posted_params:\n";
var_dump($posted_params);
echo "todo:\n";
var_dump($todo);
echo "\n-->\n";
showSequence($todo,0);
addGammas($todo);
applyPost($todo,true); // no final wait
showSequence($todo,$frame_zero);
endPage();
exit(0); // that's all
} else { // return XML page with specified parameters values
addGammas($todo);
$names=array_merge(extractNames($global_params),extractNames($frame_params));
$currentParameters=elphel_get_P_arr($names);
applyPost($todo,true); // no final wait
$msg="<?xml version=\"1.0\"?>\n<parameters>\n";
foreach ($currentParameters as $key=>$value) {
$msg.=sprintf(" <%s>%d</%s>\n",$key,$value,$key);
}
$msg.="</parameters>\n";
header("Content-Type: text/xml");
header("Content-Length: ".strlen($msg)."\n");
header("Pragma: no-cache\n");
printf($msg);
exit(0); // that's all
}
}
// startPage();
startPage($page_title, mainJavascript($refreshSig));
if ($isPost) {
if ($showSeqMode>0) showSequence($todo,0);
addGammas($todo);
applyPost($todo);
if ($showSeqMode>0) showSequence($todo,$frame_zero);
$encoded_todo=encodeTodo($todo,$frame_zero); /// do it in all modes
}
readCurrentParameterValues();
// echo "<pre>";
// print_r($frame_params);
// print_r($posted_params);
// print_r($global_params);
// var_dump($todo);
// echo "</pre>";
printPage($encoded_todo);
endPage();
exit (0);
/**
* @brief Print the default page that has some demo links
*/
function printDefaultPage() {
// $imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081";
$url_init= "embed&test&showseq&title=Camera+initialization+parameters"
."&TASKLET_CTL=0*0" /// at least ELPHEL_CONST_TASKLET_CTL_NOSAME bit should be 0 so initialization will not wait for the frame sync
."&MAXAHEAD=2" /// When servicing interrupts, try programming up to 2 frames ahead of the due to program time)
."&FPGA_XTRA=1000" /// Extra clock cycles needed to compress a frame (in addition to per macroblocs time)
."&EXTERN_TIMESTAMP=1" /// Use external timestamp when available
."&BITS=8" /// 8 bit data mode
."&QUALITY=80" /// 80 percent JPEG image quality
."&COLOR=1" /// regular color mode (not mono or JP4 flavors)
."&COLOR_SATURATION_BLUE=200"/// 2.0 (200% blue/green color saturation (to compensate for effect of non-unity gamma)
."&COLOR_SATURATION_RED=200" /// 2.0 (200% blue/green color saturation
."&BAYER=0" /// No bayer shift
."&SENSOR_RUN=". ELPHEL_CONST_SENSOR_RUN_CONT /// turn on sensor in continuous mode
."&COMPRESSOR_RUN=".ELPHEL_CONST_COMPRESSOR_RUN_CONT /// run compressor in continuous mode
."&GTAB_R=0x0a390400" /// red component: black level=10, gamma=0.57, scale=1.0 (will force calculation gamma table)
."&GTAB_G=0x0a390400" /// same for green (main one, red row)
."&GTAB_GB=0x0a390400" /// same for green (second, blue row)
."&GTAB_B=0x0a390400" /// same for blue
."&SENSOR=0*0" /// setting sensor to zero will initiate sensor detection attempt (should be frame 0)
;
$url_debug= "test&showseq&title=Debug control"
."&DEBUG=0x3fc"
."&TASKLET_CTL"
."&PROFILING_EN"
."&HISTMODE_C"
."&HISTMODE_Y"
."&HIST_LAST_INDEX=@"
."&THIS_FRAME=@"
."&HIST_Y_FRAME=@"
."&HIST_C_FRAME=@"
."&CIRCBUFWP=@"
;
$url_woi_control= "embed&test&showseq&title=Camera+WOI+Controls".
"&SENSOR_RUN&COMPRESSOR_RUN&WOI_LEFT&WOI_TOP&WOI_WIDTH&WOI_HEIGHT&FLIPH&FLIPV&DCM_HOR&DCM_VERT&THIS_FRAME=@&CIRCBUFWP=@";
$url_woi_control_test="embed=.4&test=1&showseq=1&title=Camera+WOI+Controls+(test+mode)".
"&SENSOR_RUN&COMPRESSOR_RUN&WOI_LEFT&WOI_TOP&WOI_WIDTH&WOI_HEIGHT&FLIPH=1*3&FLIPV=1*5&DCM_HOR&DCM_VERT&THIS_FRAME=@&CIRCBUFWP=@";
$url_images= "images=9:3:.2";
$url_aexp_all= "embed=0.1&title=Autoexposure/White+Balance/HDR+controls+(full)"
."&COMPRESSOR_RUN=".ELPHEL_CONST_COMPRESSOR_RUN_CONT /// run compressor in continuous mode
."&DAEMON_EN=1" /// Daemons are controlled by bits in this register. Autoexposure bit is 0 (1<<0 == 1)
."&AUTOEXP_ON=1" /// setting it to 0 will only disable autoexposure, but not HDR modes or white balancing
."&AEXP_FRACPIX=0xff80" /// Fraction of all pixels that should be below P_AEXP_LEVEL (16.16 - 0x10000 - all pixels)
."&AEXP_LEVEL=0xf800" /// Target output level: [AEXP_FRACPIX]/0x10000 of all pixels should have value below it (0x10000 - full output scale)
."&AE_PERIOD=4" /// Autoexposure period (will be increased if below the latency)
."&AE_THRESH=500" /// AE error (logariphmic exposures) is integrated between frame and corrections are scaled when error is below thershold (500)
."&THIS_FRAME=@" /// Current frame
."&NEXT_AE_FRAME=@" /// Next frame to be processed by autoexposure
."&NEXT_WB_FRAME=@" /// Next frame to be processed by the white balance
."&VEXPOS" /// exposure measured in sensor scanlines (autoexposure modifies number of exposure lines)
."&EXPOS" /// exposure in microseconds
."&NEXT_WB_FRAME=@" /// Next frame to be processed by the white balance
."&HIST_DIM_01=0x0a000a00" /// Percentiles measured for colors 0 (lower 16 bits) and 1 (high 16 bits) for VEXPOS=1 (darkest)
/// Setting it to 0xffffffff will initiate dark levels re-calibration (making 2 dark drames)
."&HIST_DIM_23=0x0a000a00" /// Same for colors 2 and 3
."&WB_EN=0x1" /// 1 - enable, 0 - disable white balance
."&WB_MASK=0xd" /// bitmask - which colors to correct (1 - correct, 0 - ignore).
."&WB_PERIOD=16" /// White balance period (will be increased if below the latency)
."&WB_WHITELEV=0xfae1" /// White balance level of white (16.16 - 0x10000 is full scale, 0xfae1 - 98%, default)
."&WB_WHITEFRAC=0x028f" /// White balance fraction (16.16) of all pixels that have level above [P_WB_WHITELEV] for the brightest color
/// locally [WB_WHITELEV] will be decreased if needed to satisfy [WB_WHITELEV]. default is 1% (0x028f)
."&WB_SCALE_R=0x10000" /// additional correction for R from calulated by white balance (16.16)
."&WB_SCALE_GB=0x10000" /// additional correction for GB (second green) from calulated by white balance (16.16)
."&WB_SCALE_B=0x10000" /// additional correction for B from calulated by white balance (16.16)
."&WB_THRESH=0" /// How many frames the white balance correction has to be the same sign before it
/// will be applied (<128,for each color independently)
."&GTAB_R" /// red component: black level=10, gamma=0.57, scale=1.0 (will force calculation gamma table)
."&GTAB_G" /// same for green (main one, red row)
."&GTAB_GB" /// same for green (second, blue row)
."&GTAB_B" /// same for blue
."&HDR_DUR=0" /// 0 - HDR 0ff, >1 - duration of same exposure (currently 1 or 2 - for free running)
."&HDR_VEXPOS=0x40000" /// if less than 0x10000 - number of lines of exposure, >=10000 - relative to "normal" exposure
."&EXP_AHEAD=3" /// How many frames ahead of the current frame write exposure to the sensor
."&AE_INTEGERR=@" /// current integrated error in the AE loop
."&HISTWND_RWIDTH" /// Relative histogram window width (0x10000 - 100%)
."&HISTWND_RHEIGHT" /// Relative histogram window height (0x10000 - 100%)
."&HISTWND_RLEFT" /// Relative histogram window left (0x10000 - 100%)
."&HISTWND_RTOP" /// Relative histogram window top (0x10000 - 100%)
."&HISTWND_WIDTH=@" /// Absolute (as written to FPGA) histogram window width
."&HISTWND_HEIGHT=@" /// Absolute (as written to FPGA) histogram window height
."&HISTWND_LEFT=@" /// Absolute (as written to FPGA) histogram window left (counted from the left of WOI margin)
."&HISTWND_TOP=@" /// Absolute (as written to FPGA) histogram window top (counted from the top of WOI)
;
$url_aexp_only= "embed=0.1&title=Autoexposure+controls"
."&COMPRESSOR_RUN=".ELPHEL_CONST_COMPRESSOR_RUN_CONT /// run compressor in continuous mode
."&DAEMON_EN=1" /// Daemons are controlled by bits in this register. Autoexposure bit is 0 (1<<0 == 1)
."&AUTOEXP_ON=1" /// setting it to 0 will only disable autoexposure, but not HDR modes or white balancing
."&AEXP_FRACPIX=0xff80" /// Fraction of all pixels that should be below P_AEXP_LEVEL (16.16 - 0x10000 - all pixels)
."&AEXP_LEVEL=0xf800" /// Target output level: [AEXP_FRACPIX]/0x10000 of all pixels should have value below it (0x10000 - full output scale)
."&AE_PERIOD=4" /// Autoexposure period (will be increased if below the latency)
."&AE_THRESH=500" /// AE error (logariphmic exposures) is integrated between frame and corrections are scaled when error is below thershold (500)
."&THIS_FRAME=@" /// Current frame
."&NEXT_AE_FRAME=@" /// Next frame to be processed by autoexposure
."&VEXPOS" /// exposure measured in sensor scanlines (autoexposure modifies number of exposure lines)
."&EXPOS" /// exposure in microseconds
."&HIST_DIM_01=0x0a000a00" /// Percentiles measured for colors 0 (lower 16 bits) and 1 (high 16 bits) for VEXPOS=1 (darkest)
/// Setting it to 0xffffffff will initiate dark levels re-calibration (making 2 dark drames)
."&HIST_DIM_23=0x0a000a00" /// Same for colors 2 and 3
."&EXP_AHEAD=3" /// How many frames ahead of the current frame write exposure to the sensor
."&HISTWND_RWIDTH" /// Relative histogram window width (0x10000 - 100%)
."&HISTWND_RHEIGHT" /// Relative histogram window height (0x10000 - 100%)
."&HISTWND_RLEFT" /// Relative histogram window left (0x10000 - 100%)
."&HISTWND_RTOP" /// Relative histogram window top (0x10000 - 100%)
."&HISTWND_WIDTH=@" /// Absolute (as written to FPGA) histogram window width
."&HISTWND_HEIGHT=@" /// Absolute (as written to FPGA) histogram window height
."&HISTWND_LEFT=@" /// Absolute (as written to FPGA) histogram window left (counted from the left of WOI margin)
."&HISTWND_TOP=@" /// Absolute (as written to FPGA) histogram window top (counted from the top of WOI)
."&AE_INTEGERR=@" /// Current integrated error in the AE loop
;
$url_wb_only= "embed=0.1&title=White+Balance+controls"
."&COMPRESSOR_RUN=".ELPHEL_CONST_COMPRESSOR_RUN_CONT /// run compressor in continuous mode
."&DAEMON_EN=1" /// Daemons are controlled by bits in this register. Autoexposure bit is 0 (1<<0 == 1)
."&THIS_FRAME=@" /// Current frame
."&NEXT_WB_FRAME=@" /// Next frame to be processed by the white balance
."&NEXT_WB_FRAME=@" /// Next frame to be processed by the white balance
."&WB_EN=0x1" /// 1 - enable, 0 - disable white balance
."&WB_MASK=0xd" /// bitmask - which colors to correct (1 - correct, 0 - ignore).
."&WB_PERIOD=16" /// White balance period (will be increased if below the latency)
."&WB_WHITELEV=0xfae1" /// White balance level of white (16.16 - 0x10000 is full scale, 0xfae1 - 98%, default)
."&WB_WHITEFRAC=0x028f" /// White balance fraction (16.16) of all pixels that have level above [P_WB_WHITELEV] for the brightest color
/// locally [WB_WHITELEV] will be decreased if needed to satisfy [WB_WHITELEV]. default is 1% (0x028f)
."&WB_SCALE_R=0x10000" /// additional correction for R from calulated by white balance (16.16)
."&WB_SCALE_GB=0x10000" /// additional correction for GB (second green) from calulated by white balance (16.16)
."&WB_SCALE_B=0x10000" /// additional correction for B from calulated by white balance (16.16)
."&WB_THRESH=500" /// WB errors are integrated between frame and corrections are scaled when error is below thershold (500)
."&GAIN_MIN=0x10000" /// minimal sensor analog gain (0x100 - 1.0)
."&GAIN_MAX=0xfc000" /// maximal sensor analog gain (0x100 - 1.0)
// ."&GAIN_STEP=0x20" /// minimal correction to be applied to the analog gain (should be set larger that sensor
// /// actual gain step to prevent oscillations (0x100 - 1.0, 0x40 - 1/8)
."&ANA_GAIN_ENABLE=1" /// Enable analog gain controls in white balancing
."&GTAB_R" /// red component: black level=10, gamma=0.57, scale=1.0 (will force calculation gamma table)
."&GTAB_G" /// same for green (main one, red row)
."&GTAB_GB" /// same for green (second, blue row)
."&GTAB_B" /// same for blue
/// Analog gains
."&GAINR=0x10000" /// R channel gain (mono gain) 8.8 0x100 - 1.0
."&GAING=0x10000" /// G channel gain (mono gain) 8.8 0x100 - 1.0
."&GAINGB=0x10000" /// GB channel gain (mono gain) 8.8 0x100 - 1.0
."&GAINB=0x10000" /// B channel gain (mono gain) 8.8 0x100 - 1.0
."&SENSOR_REGS45=@" /// Sensor register gain R
."&SENSOR_REGS43=@" /// Sensor register gain G
."&SENSOR_REGS46=@" /// Sensor register gain GB
."&SENSOR_REGS44=@" /// Sensor register gain B
."&WB_INTEGERR=@" /// current integrated error in the WB loop
;
$url_colors_only= "embed=0.1&title=Color+gains+controls"
/// Analog gains
."&GAINR=0x10000" /// R channel gain (mono gain) 8.8 0x100 - 1.0
."&GAING=0x10000" /// G channel gain (mono gain) 8.8 0x100 - 1.0
."&GAINGB=0x10000" /// GB channel gain (mono gain) 8.8 0x100 - 1.0
."&GAINB=0x10000" /// B channel gain (mono gain) 8.8 0x100 - 1.0
."&SENSOR_REGS45=@" /// Sensor register gain R
."&SENSOR_REGS43=@" /// Sensor register gain G
."&SENSOR_REGS46=@" /// Sensor register gain GB
."&SENSOR_REGS44=@" /// Sensor register gain B
;
$url_hdr_exp= "embed=0.1&title=HDR+exposure+controls"
."&COMPRESSOR_RUN=".ELPHEL_CONST_COMPRESSOR_RUN_CONT /// run compressor in continuous mode
."&DAEMON_EN=1" /// Daemons are controlled by bits in this register. Autoexposure bit is 0 (1<<0 == 1)
."&AUTOEXP_ON=1" /// setting it to 0 will only disable autoexposure, but not HDR modes or white balancing
."&VEXPOS" /// exposure measured in sensor scanlines (autoexposure modifies number of exposure lines)
."&EXPOS" /// exposure in microseconds
."&HDR_DUR=0" /// 0 - HDR 0ff, >1 - duration of same exposure (currently 1 or 2 - for free running)
."&HDR_VEXPOS=0x40000" /// if less than 0x10000 - number of lines of exposure, >=10000 - relative to "normal" exposure
."&THIS_FRAME=@" /// Current frame
;
$url_ext_trigger="embed=0.1&title=External+trigger+controls"
."&TRIG=4" /// External trigger mode
/// bit 0 - "old" external mode (0- internal, 1 - external )
/// bit 1 - enable(1) or disable(0) external trigger to stop clip
/// bit 2 - async (snapshot, ext trigger) mode, 0 - continuous NOTE: Only this bit is used now !
/// bit 3 - no overlap, single frames: program - acquire/compress same frame
."&TRIG_PERIOD=19200000"/// 0.2 sec @96MHz output sync period (32 bits, in pixel clocks)
/// >=256 repetitive with specified period.
/// NOTE: Currently there is no verification that period is longer than sensor/compressor can handle
."&TRIG_DELAY" /// trigger delay, 32 bits in pixel clocks (needed when multiple cameras are synchronized)
."&EXTERN_TIMESTAMP=1" /// Use external timestamp if available
."&TRIG_BITLENGTH=255" /// bit lengh minus 1 in pixel clocks (when sending timestamp over sync line)
."&XMIT_TIMESTAMP=1" /// transmit timestamp when sending sync
."&THIS_FRAME=@" /// Current frame
///Next parameters are non-zero only for external connections and should match particular I/O boards/connectors
."&TRIG_CONDITION=0" /// trigger condition, 0 - internal, else dibits ((use<<1) | level) for each GPIO[11:0] pin
."&TRIG_OUT=0" /// trigger output to GPIO, dibits ((use << 1) | level_when_active). Bit 24 - test mode,
/// when GPIO[11:10] are controlled by other internal signals
."&SENSOR_REGS30=@" /// Sensor register MODE1 (trigger bit)
;
$url_cable_delay="embed=0.3&title=Cable+delay+/+Sensor+phase+adjustment"
."&SENSOR_PHASE" /// Sensor phase - use | 0x80000 to reset DCM (needed if phase went too far)
."&DAEMON_EN=0" /// disable autoexposure/color balance
."&TESTSENSOR=0x10008" /// 0x10008 - color bars
;
$url_sample="embed=0.3&title=Sample+camera+control+page"
."&SENSOR_REGS32=@"
."&SENSOR_REGS32__0106"
."&SENSOR_REGS160=@"
."&SENSOR_REGS160__0403"
."&TESTSENSOR=0x10008"
."&FPGATEST"
;
$url_ext_photofinish="embed=0.2&&title=Photofinish+and+ oversize+controls"
."&WOI_TOP" /// WOI top - here used to adjust the acquisition line to the center of the screen
."&WOI_HEIGHT" /// Total WOI height (composite image),<16384
."&WOI_WIDTH" /// Just WOI width (image height in photofinish mode)
."&PF_HEIGHT" /// Photofinish stripe height - minimal 2. Set to zero to turn photofinish mode off
."&OVERSIZE" /// include black pixels in the output. WOI_WIDTH and WOI_HEIGHT are not verified in this mode
."&DAEMON_EN" /// bitwise enabling daemons (+1 - autoexposure, +2 - streamer)
."&EXPOS" /// exposure time in microseconds
."&GAINR" /// Red gain (0x10000 corresponds to unity gain)
."&GAING" /// Green in red line gain (0x10000 corresponds to unity gain)
."&GAINGB" /// Green in blue line gain (0x10000 corresponds to unity gain)
."&GAINB" /// Blue gain (0x10000 corresponds to unity gain)
."&VIRT_HEIGHT" /// height of the single photofinish strip (use to slow down line scanning rate - minimal is calculated automatically)
."&VIRT_KEEP" /// 1 - use specified value of VIRT_HEIGHT, 0 - use minimal possible
."&ACTUAL_HEIGHT=@" /// actual height of the composite image, readonly
."&SENSOR_REGS6=@" /// vertical blank in each strip, readonly
."&refresh"
;
$prefix_url='http://'.$_SERVER['SERVER_ADDR'].$_SERVER['SCRIPT_NAME'];
echo <<<USAGE
<h4> Control links:</h4>
<ul>
<li><a href="?$url_init">Initialization Parameters (i.e. after powerup)</a></li>
<li><a href="?$url_colors_only">Control of color channel gains</a></li>
<li><a href="?$url_woi_control">Demo to change image size, position and mirroring</a></li>
<li><a href="?$url_woi_control_test">Demo to change image size, position and mirroring - test mode</a></li>
<li><a href="?$url_aexp_only">Controls related to autoexposure</a></li>
<li><a href="?$url_wb_only">Controls related to white balance</a></li>
<li><a href="?$url_hdr_exp">Controls related to HDR exposure - all</a></li>
<li><a href="?$url_aexp_all">Controls related to autoexposure/white balance/HDR exposure - all</a></li>
<li><a href="?$url_ext_trigger">External trigger controls</a></li>
<li><a href="?$url_ext_photofinish">Photofinish and oversize (with black pixels around actiove pixels) modes controls</a></li>
<li><a href="?$url_cable_delay">Cable delay / sensor phase adjustment. low 16 bits - signed number of ~22ps steps, bits 17:16 - 90 degree steps. Add 0x80000 to reset delays (needed if small delay was set too far for the internal FPGA DCM - phase adjustment limits are frequency dependent, but less than +/-255).</a></li>
<li><a href="?$url_images">last 9 images, 3 per row, scale=0.2</a></li>
<li><a href="?$url_debug">Debug on/off control (usually requires to redirect printk() output with 'printk_mod &'</a></li>
</ul>
<br/>
<h2> You may construct custom URLs that combine parameters you need to control or monitor using the included links URLs as examples.</h2>
</p>Just including parameter (&SOME_PARAMETER) will create form to edit it, adding "&SOME_PARAMETER=1234" will put "1234" in the value filed, &SOME_PARAMETER=@" creates a read-only field to monitor parameter value. You may view/modify sensor registers using meta names SENSOR_REGS with the register number, you may also view edit particular bit fileds of the parameters, adding "__" (double underscore), then WW (two decimals specifying the bit width of the fields) followed by BB - (two decimal numbers specifying the lowest bit in the field (0..31) . In the following example</p>
<p><a href="?$url_sample">$prefix_url?$url_sample</a></p>
<ul>
<li><b>embed=0.3</b> - embedd the camera image scaled down to 30% of the original size</li>
<li<b>title=Sample+camera+control+page</b> - page title with spaces replaced by "+" signs</li>
<li<b>SENSOR_REGS32=@</b> - show sensor register 32 in read-only mode</li>
<li<b>SENSOR_REGS32__0106</b> - show sensor register 32 selected bit [6] (in MT9P031 it controls black level calibration, should be off for the test patterns), allow editing</li>
<li<b>SENSOR_REGS160=@</b> - show sensor register 160 in read-only mode</li>
<li<b>SENSOR_REGS160__0403</b> - show sensor register 160 selected bits [6:3] (in MT9P031 they control sensor test pattern), allow editing</li>
<li<b>TESTSENSOR=0x10008</b> - preffered (register-independent) way to select sensor test pattern, suggest particular value. 0x10000 turns the mode on, 8 selects color bars pattern.</li>
<li<b>FPGATEST</b> - Add field for FPGA internally generated image (currently just two values - 0 - off, 1 - gray gradient columns).</li>
</ul>
<p>Each parameter on a generated page has a "tooltip" - if you hover a mouse pointer over it's name it will show short description of the parameter.</p>
<h4> Changing parameters with the HTTP GET method</h4>
<p>If "&immediate" is added the the URL, the program will apply parameteres (those that have values specified) without opening any forms. If the parameter <b>showseq</b> is specified and positive, the HTML page will show the sequence of parameter application, if it is ommitted or less or equal to 0, the request will generate an XML response with the previous parameter values (before application of the new ones). You may specify different program-ahead values and/or multiple settings for the same parameters - program-ahead values are separated from the parameter values with "*", multiple value/program-ahead pairs for the same parameter are separated with ":". Non-specified program-ahead is currently set to 3.</p>
USAGE;
}
/// show table with last acquired images and meta data
/// TODO: show chnaged parameters for those frames? ***
function showImgData($meta,$skipped,$prev,$imgScale,$done) {
global $imgsrv,$imglink;
$width= $meta['meta']['width'];
$height=$meta['meta']['height'];
$title="";
$frame=$meta['Exif']['FrameNumber'];
foreach ($meta['Exif'] as $key=>$value) {
$title.=sprintf("%s=%s \n",$key,$value);
}
/*
echo "<pre>";
print_r($done);
echo "</pre>";
*/
printf ("<table border='1'>");
printf ("<tr>");
printf ("<td colspan=4>");
printf("<img src='$imgsrv/%d/$imglink' style='width:%dpx; height:%dpx;' title='%s'/>\n",
$meta['circbuf_pointer'],
floor($width*$imgScale),
floor($height*$imgScale),
$title);
printf ("</td>");
printf ("</tr>");
printf ("<tr>");
printf ("<td>%s</td><td>%d (0x%x)</td>",'FrameNumber',$frame,$frame);
printf ("<td>%s</td><td>%d (0x%x)</td>",'width',$meta['meta']['width'],$meta['meta']['width']);
printf ("</tr>");
printf ("<tr>");
$just_time=end(explode(" ", trim($meta['Exif']['DateTimeOriginal'])));
/// just seconds
$just_time=end(explode(":", $just_time));
if ($skipped)
printf ("<td><b>Skipped</b></td><td><b>%d</b></td>",$skipped);
else
printf ("<td>&nbsp;</td><td>&nbsp;</td>");
printf ("<td>%s</td><td>%d (0x%x)</td>",'height',$meta['meta']['height'],$meta['meta']['height']);
printf ("</tr>");
printf ("<tr>");
printf ("<td>%s</td><td>%s</td>",'TimeOriginal',$just_time);
printf ("<td>%s</td><td>%d (0x%x)</td>",'quality2',$meta['meta']['quality2'],$meta['meta']['quality2']);
printf ("</tr>");
printf ("<tr>");
printf ("<td>%s</td><td>%s</td>",'ExposureTime',trim($meta['Exif']['ExposureTime']));
printf ("<td>%s</td><td>%d</td>",'color',$meta['meta']['color']);
printf ("</tr>");
if ($done) {
printf ("<tr>");
printf ("<td colspan='4'>");
printf ("<table border='1' style='width:100%s'>\n",'%');
foreach ($done as $action_frame=>$actions) {
$firstRow=true;
printf("<tr><td rowspan='%d'>%s</td>",count($actions),($action_frame==$frame)?"now":("prev ".($frame-$action_frame)));
foreach ($actions as $key=>$value) {
if (!$firstRow) printf ("<tr>");
else $firstRow=false;
printf("<td>%s</td><td style='text-align:right'>%d</td><td>0x%x</td>",$key,$value,$value);
printf ("</tr>\n");
}
}
printf ("</table>");
//print_r($done);
printf ("</td>");
printf ("</tr>");
}
printf ("</table>");
// print_r($meta['Exif']);
}
///TODO:if $todo is provided in $_GET - try to find the correct images even if they are not the latest
function showLastImages($numImg,$imagesPerRow,$imgScale) {
$done= decodeTodo ($_GET['done']);
// $this_exif=elphel_get_exif_elphel(0);
$circbuf_pointers=elphel_get_circbuf_pointers(1);
$framesAgo=0;
//echo "<pre>\n";
end($circbuf_pointers);
if ($done) {
end($done);
$lastFrameNumber=key($done);
$cur_ptr=current($circbuf_pointers);
while($cur_ptr['frame'] > $lastFrameNumber) {
if (!prev($circbuf_pointers)) { /// failed to find the right frame in circbuf - probably overwritten
end($circbuf_pointers);
break;
}
$cur_ptr=current($circbuf_pointers);
$framesAgo++;
}
}
///TODO: If all changes were later than the images shown - disregard $todo
//print_r($circbuf_pointers);
//print_r($done);
//echo "</pre>\n";
$meta=array();
// end($circbuf_pointers);
$lastFrameIndex=key($circbuf_pointers);
for ($i=0; $i<=min(($numImg-1),$lastFrameIndex);$i++) {
$meta[$i]=array('circbuf_pointer'=>$circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['circbuf_pointer'],
'meta'=>elphel_get_interframe_meta($circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['circbuf_pointer']),
'Exif'=>elphel_get_exif_elphel ($circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['exif_pointer']));
$lastFrameNumber=$circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['frame'];
}
$running=(elphel_get_P_value(ELPHEL_COMPRESSOR_RUN)==ELPHEL_CONST_COMPRESSOR_RUN_CONT) &&
(elphel_get_P_value(ELPHEL_SENSOR_RUN)==ELPHEL_CONST_SENSOR_RUN_CONT);
$page_title=sprintf("%s %d images acquired to the circular buffer (circbuf). Acquisition is %s. Last frame is %d"
,$framesAgo?"$framesAgo frames (stored) ago":"Latest"
,$numImg
,$running?"on - these frames are/will be overwritten in the camera memory":"off"
,$lastFrameNumber);
/*
$page_title=sprintf("%d: %s %d images acquired to the circular buffer (circbuf). Acquisition is %s"
,$lastFrameNumber
,$framesAgo?"$framesAgo frames ago":"Latest"
,$numImg
,$running?"on - these frames are/will be overwritten in the camera memory":"off"
);
*/
startPage($page_title, "");
printf("<h4>%s</h4>\n",$page_title);
printf ("<table>\n");
$rowOpen=$false;
$lastFrame=0;
$done_left=count($done);
reset($done);
$slice_start=0;
$slice_count=0;
for ($i=0;$i<$numImg;$i++) {
$slice_start+=$slice_count;
$slice_count=0;
$frame=$meta[$i]['Exif']['FrameNumber'];
while($done_left && (key($done) <= $frame)) {
$slice_count++;
$done_left--;
next($done);
}
///$done per image
$this_done=array_slice($done,$slice_start,$slice_count,true);
if (!($i % $imagesPerRow)) {
if ($rowOpen) {
printf ("</tr>\n");
}
printf ("<tr>\n");
$rowOpen=true;
}
printf("<td style='vertical-align: top;'>");
$skipped=($i>0)?($frame-$lastFrame-1):0;
$lastFrame=$frame;
showImgData($meta[$i],$skipped,$numImg-$i-1,$imgScale,$this_done);
printf("</td>\n");
}
while ($i++ % $imagesPerRow) {
printf ("<td>&nbsp;</td>\n");
}
printf ("</tr>\n");
printf ("</table>\n");
endPage();
}
/**
* @brief Encode $todo to a string that can be passed in GET HTTP request
* @param $todo - array of arrays of parameter chnages
* @param $frame_zero - sequence start frame number that should be added to keys in $todo to get absolute frame numbers
* @return string representation of $todo
*/
function encodeTodo($todo,$frame_zero) {
$result="";
foreach ($todo as $frame=>$actions) {
$result.=sprintf("%d/",$frame+$frame_zero);
foreach ($actions as $par=>$value) {
$result.=sprintf("%s:%d/",$par,$value);
}
}
return $result;
}
/**
* @brief Reverse endodeTodo() - create $todo array from the encoded string
* @param $encoded_todo - string representation of todo array
* @return array representation of $encoded_todo
*/
function decodeTodo ($encoded_todo) {
$todo=array();
$frame=0;
if (!$encoded_todo) return $todo;
$done=explode("/",rtrim($encoded_todo,'/'));
foreach ($done as $term) {
$term=explode(":",$term);
if (count($term)==1) {
$frame=$term[0];
$todo[$frame]=array();
} else {
$todo[$frame][$term[0]]=(int)$term[1];
}
}
return $todo;
}
function showSequence($todo,$frame_zero) {
printf("<h4>Command Sequence (%s)</h4>\n",$frame_zero?"absolute frame numbers":"relative frame numbers");
printf ("<table border='1' style='font-family: Courier, monospace;'>\n");
printf ("<tr style='text-align:center'>".
"<td colspan=2>Frame</td>".
"<td rowspan=2>Parameter name</td>".
"<td colspan=2>Value</td>".
"</tr>\n");
printf ("<tr style='text-align:center'>".
"<td>dec</td>".
"<td>hex</td>".
"<td>dec</td>".
"<td>hex</td>".
"</tr>\n");
foreach ($todo as $frame=>$actions) {
$first_act=true;
printf ("<tr style='text-align:right'>\n");
foreach ($actions as $name=>$value) {
if ($first_act) {
printf ("<td rowspan=%d>%d</td><td rowspan=%d>0x%x</td>",count($actions),($frame+$frame_zero),count($actions),($frame+$frame_zero));
}
printf ("<td style='text-align:left'>%s</td>".
"<td>%d</td>".
"<td>0x%x</td>".
"</tr>\n",$name,$value,$value);
$first_act=false;
}
}
printf ("</table>\n");
}
function applyPost($todo,$noFinalWait=false) {
global $maxahead,$minahead,$frame_zero,$showSeqMode;
if ($showSeqMode>0) {
printf("<h4>Running sequence...</h4>\n");
echo "<pre>";
}
// print_r($_POST);
// print_r($posted_params);
// var_dump($todo);
// print_r($todo);
/// Skip to the next frame (so more deterministic phase - maximal time till next frame)
$waitingEnabled=true;
foreach ($todo as $pars) if (array_key_exists('SENSOR', $pars)) {
$waitingEnabled=false;
break;
}
if (elphel_get_frame()<8) $waitingEnabled=false; /// or is "==0" enough?
if ($waitingEnabled && !$noFinalWait) elphel_skip_frames(1); // in GET mode, do not skip any frames
/// store the current frame number as reference for all actions delays
$frame_zero=elphel_get_frame();
$frame_since=0;
$frame_now=$frame_zero;
///Iterate through $todo array, programming the parameter changes
foreach ($todo as $since=>$pgmpars) {
if (($since-$maxahead) >$frame_since ) { /// too early to program, need to wait
$frame_since=$since-$minahead;
$frame_now=$frame_since+$frame_zero;
if ($waitingEnabled) {
if ($showSeqMode>0) {printf ("waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();}
elphel_wait_frame_abs($frame_now);
if ($showSeqMode>0) {printf ("done\n"); ob_flush(); flush();}
}
}
elphel_set_P_arr ($pgmpars, $frame_zero+$since,ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); /// Are these flags needed?
}
if (!$noFinalWait) {
$frame_now=$since+$frame_zero+1; /// wait just 1 frame longer that the target of the last command in $todo
// echo "since=$since\n"; ob_flush(); flush();
if ($showSeqMode>0) {printf ("waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();}
if ($waitingEnabled) {
elphel_wait_frame_abs($frame_now);
} else {
$timeout_step= 100000; /// 0.1 sec
$timeout= 3000000; /// 3.0sec
for ($i=0 ; $i < $timeout; $i+=$timeout_step) {
if (elphel_get_frame()>=$frame_now) break;
usleep($timeout_step);
}
}
}
if ($showSeqMode>0) {printf ("done\n"); ob_flush(); flush();}
if ($showSeqMode>0) echo "</pre>";
// exit (0);
}
function parsePost() {
global $_POST,$testMode,$showSeqMode,$posted_params;
$posted_params=array();
/// parse to an array of parameters/changes
$testMode=$_POST['test_mode'];
$showSeqMode=$_POST['show_seq'];
foreach ($_POST as $post=>$value) {
if (($post=="test_mode") || ($post=="show_seq")) {
// nop;
} else {
list ($name,$index)=explode('_',$post);
$index = (int) $index;
if (!$posted_params[$index]) $posted_params[$index]=array();
$posted_params[$index][$name]=$value;
}
}
}
/// Simulate POST from URL parameters if 'immediate' is present in the URL
function convertImmediateMode(){
global $posted_params,$global_params,$frame_params;
$posted_params=array();
$index=0;
foreach ($global_params as $param) {
$posted_params[$index++]=array(
'name' => $param['name'],
'oldval' => $param['cur_value'],
'paramdec' => $param['value'], /// 'paramhex' is not used
'delay'=> $param['ahead'],
'apply' => $param['write_en'] && $param['modified']
);
}
foreach ($frame_params as $param) {
$posted_params[$index++]=array(
'name' => $param['name'],
'oldval' => $param['cur_value'],
'paramdec' => $param['value'], /// 'paramhex' is not used
'delay'=> $param['ahead'],
'apply' => $param['write_en'] && $param['modified']
);
}
}
function extractNames($arr){
$names=array();
foreach ($arr as $element) $names[$element['name']]=0; // values will not be used;
return $names;
}
function preparePost() {
global $testMode,$testBefore,$testAfter,$framesBeforeStart,$posted_params;
$todo=array();
/// Now need to find minimal index in $todo and add compressor stop/copmpressor start
/// Extract data about actual actions, organize them in frames ahead (all globals will have ahead=0)
foreach ($posted_params as $par) if ($par['apply']){
if (array_key_exists('delay',$par)) {
$delay = (int) $par['delay'] + (($testMode>0)?($testBefore+$framesBeforeStart):0);
} else $delay=0;
if (!$todo[$delay]) $todo[$delay]=array();
$todo[$delay][$par['name']]=(int) $par['paramdec'];
}
/// sort $todo using time (key)
ksort($todo); /// needed to process parameters in temporal sequence
if ($testMode>0) {
end($todo);
$todo[key($todo)+$testAfter]=array("COMPRESSOR_RUN"=>ELPHEL_CONST_COMPRESSOR_RUN_STOP);
$todo[$framesBeforeStart]=array("COMPRESSOR_RUN"=>ELPHEL_CONST_COMPRESSOR_RUN_CONT);
ksort($todo); /// re-sort it after adding start/stop
}
return $todo;
}
// global $_POST,$testMode,$showSeqMode,$testBefore,$testAfter,$framesBeforeStart,$posted_params;
/**
* @brief Scan commands for possible changing gamma tables, calculate them in advance
* (driver can only scale gamma, not calculate prototypes)
* @param todo - array of arrays of parameter chnages
*/
function addGammas($todo) {
global $showSeqMode;
$gammas=array();
foreach ($todo as $pars) {
if (array_key_exists('GTAB_R', $pars)) $gammas[$pars['GTAB_R' ]>>16]=1; /// duplicates will be eliminated
if (array_key_exists('GTAB_G', $pars)) $gammas[$pars['GTAB_G' ]>>16]=1;
if (array_key_exists('GTAB_GB',$pars)) $gammas[$pars['GTAB_GB']>>16]=1;
if (array_key_exists('GTAB_B', $pars)) $gammas[$pars['GTAB_B' ]>>16]=1;
}
// var_dump($gammas);
foreach ($gammas as $gamma_black=>$whatever) {
$black=($gamma_black>>8) & 0xff;
$gamma=($gamma_black & 0xff)*0.01;
if ($showSeqMode>0) printf("<pre>Adding gamma table (gamma=%f, black level=%d)\n</pre>\n",$gamma,$black);
elphel_gamma_add ($gamma, $black);
}
}
function myval ($s) {
$s=trim($s,"\" ");
if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s));
else return intval($s);
}
function parseGetNames() {
global $_GET,$_POST,$isPost,$elp_const,$frame_params,$global_params,
$page_title,$default_ahead,$maxahead,$brief,$ahead_separator,
$refreshSig,$ignoreVals,$testMode,$showSeqMode,$posted_params,$defaultImgScale,$defaultImagesPerRow,$defaultImagesNumber,
$imagesNumber,$imagesPerRow,$imgScale,$embedImageScale, $defaultEmbedImageScale;
$index=0;
$frame_params=array();
$global_params=array();
$immediateMode=false; /// if true - no dialog, just apply parameters from the URL
foreach ($_GET as $key=>$value) {
if ($key=="immediate") {
$immediateMode=true;
} else if ($key=="title") {
$page_title=$value;
} else if ($key=="shownumbers") {
$brief=false;
} else if ($key==$refreshSig) {
$ignoreVals=true;
} else if ($key=='test') {
$testMode= myval($isPost?$_POST['test_mode']:$value);
} else if ($key=='showseq') {
$showSeqMode=myval($isPost?$_POST['show_seq']:$value);
} else if (($key=='images') || ($key=='link_images')) {
if ($value) $value=explode(':',$value);
else $value=array();
$imagesNumber=$value[0]?$value[0]:$defaultImagesNumber;
$imagesPerRow=$value[1]?$value[1]:$defaultImagesPerRow;
$imgScale= $value[2]?$value[2]:$defaultImgScale;
if ($key=='images') {
showLastImages($imagesNumber,$imagesPerRow,$imgScale);
exit(0);
}
} else if ($key=='embed') {
$embedImageScale= $value;
if (!$embedImageScale) $embedImageScale=$defaultEmbedImageScale;
} else if ($key=='_time') {
} else {
/// locate $key among constants, accept numeric values also
$address=myval ($key);
if (($address==0) && (strlen($key)>3)) { /// suspect constant
$address=elphel_parse_P_name($key);
}
if ($address==0) {
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
$xml->addChild ('ERROR','"Wrong address==0, probably misspelled constant: \''.$key.'\'"' );
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
exit (0);
}
$write_en=(!($value[0]=="@"));
if (!$write_en) {
if (strlen($value)==1) $value="";
else $value=substr($value,1);
}
$values=explode(":", $value);
foreach ($values as $value) {
$modified=false;
$value=explode($ahead_separator,$value);
if (count($value)>1) {
$ahead=myval($value[1]);
if ($ahead<0) $ahead=0;
} else {
$ahead=$default_ahead;
}
$modified=(strlen($value[0])>0);
$value=myval($value[0]);
if ($isPost) {
$ahead=$posted_params[$index]['delay'];
}
if (elphel_is_global_par($address)) {
$global_params[$index++]=array("number"=>$address,
"name"=>$key,
"value"=>$value,
"write_en"=>$write_en,
"cur_value"=>"",
'modified'=>$modified,
'ahead'=>$ahead);
} else {
$frame_params [$index++]=array("number"=>$address,
"name"=>$key,
"value"=>$value,
"write_en"=>$write_en,
"cur_value"=>"",
'modified'=>$modified,
'ahead'=>$ahead);
}
}
}
}
return $immediateMode;
}
function readCurrentParameterValues() {
global $frame_params,$global_params,$page_title,$ignoreVals;
$pars=array();
foreach ($frame_params as $par) {
$pars[$par['name']]=0; /// may be duplicates (they will use the same $pars[] element
}
foreach ($global_params as $par) {
$pars[$par['name']]=0;
}
// echo "<pre>";
//print_r($pars);
$pars=elphel_get_P_arr($pars); /// next2 frame/globals
//print_r($pars);
foreach ($frame_params as $key=>$par) {
$frame_params[$key]['cur_value']=$pars[$par['name']];
$par['cur_value']=$pars[$par['name']];
if (!$par['modified'] || $ignoreVals) $frame_params[$key]['value']=$par['cur_value'];
//echo "pars[par['name']]=".$pars[$par['name']]."\n";
//print_r($par);
}
foreach ($global_params as $key=>$par) {
$global_params[$key]['cur_value']=$pars[$par['name']];
$par['cur_value']=$pars[$par['name']];
if (!$par['modified'] || $ignoreVals) $global_params[$key]['value']=$par['cur_value'];
//print_r($par);
}
}
///============
function mainJavascript($refreshSig) {
global $refreshSig,$frame_params,$global_params;
$checkboxNumbers="";
foreach ($frame_params as $num=>$par) {
$checkboxNumbers.=$num.",";
}
foreach ($global_params as $num=>$par) {
$checkboxNumbers.=$num.",";
}
$checkboxNumbers=rtrim ($checkboxNumbers,",");
return <<<JAVASCRIPT
function hex2dec(h) {
var dec=0;
var d;
h=h.toUpperCase();
while (h.length>0) {
d=h.charCodeAt(0)-"0".charCodeAt(0);
if (d>9) d= (h.charCodeAt(0))-("A".charCodeAt(0))+10;
dec=dec*16+d;
h=h.substring(1,h.length);
}
return dec;
}
function dec2hex(d) {
var hex="";
var d0,d1;
if (d<0) d+=4294967296;
if ((d<0) || ( d>4294967296)) return "NaN";
while (d>0) {
d1=Math.floor(d/16);
d0=d-16*d1;
d=d1;
hex=("0123456789abcdef".charAt(d0))+hex;
}
return hex;
}
function onchangeDec(elem,id_hex,id_apply) {
// alert ("onchangeDec("+elem.id+","+id_hex+","+id_apply+")");
document.getElementById(id_hex).value=dec2hex(document.getElementById(elem.id).value);
document.getElementById(id_apply).checked=true;
}
function onchangeHex(elem,id_dec,id_apply) {
// alert ("onchangeHex("+elem.id+","+id_dec+","+id_apply+")");
document.getElementById(id_dec).value=hex2dec(document.getElementById(elem.id).value);
document.getElementById(id_apply).checked=true;
}
function onchangeDelay(elem,id_apply) {
// alert ("onchangeDelay("+elem.id+","+id_apply+")");
var d=document.getElementById(elem.id).value;
if (d<0) document.getElementById(elem.id).value=0;
document.getElementById(id_apply).checked=true;
}
function refreshPage(mode) {
var url=window.location.href;
var refreshSign="&"+"$refreshSig";
var refIndex,index1;
///remove &$refreshSig from the url (if any)
while (url.indexOf(refreshSign)>=0) {
refIndex=url.indexOf(refreshSign);
url=url.substr(0,refIndex)+url.substr(refIndex+refreshSign.length);
}
if (mode) url+=refreshSign;
///Preserve test_mode through GET
var testModeName="test";
refIndex=url.indexOf("&"+testModeName);
if (refIndex<0)refIndex=url.indexOf("?"+testModeName);
if (refIndex>=0){ // test should be in the URL or it will not be shown on a page
index1=url.indexOf("&",refIndex+testModeName.length);
if (index1<0) index1= url.length;
refIndex+=testModeName.length+1;
url=url.substr(0,refIndex)+"="+(document.getElementById("id_test_mode").checked?1:0)+url.substr(index1);
}
// alert ("url="+url);
///Preserve show sequence through GET
var showSeqName="showseq";
refIndex=url.indexOf("&"+showSeqName);
if (refIndex<0)refIndex=url.indexOf("?"+showSeqName);
if (refIndex>=0){ // test should be in the URL or it will not be shown on a page
index1=url.indexOf("&",refIndex+showSeqName.length);
if (index1<0) index1= url.length;
refIndex+=showSeqName.length+1;
url=url.substr(0,refIndex)+"="+(document.getElementById("id_show_seq").checked?1:0)+url.substr(index1);
}
// alert ("url="+url);
window.location.href=url;
}
function unCheckAll() {
checkboxes=Array($checkboxNumbers);
for (i in checkboxes) {
if (((cb=document.getElementById('id_apply_'+checkboxes[i])))) {
cb.checked=false;
}
}
}
function checkAll() {
checkboxes=Array($checkboxNumbers);
for (i in checkboxes) {
if (((cb=document.getElementById('id_apply_'+checkboxes[i])))) {
cb.checked=true;
}
}
}
JAVASCRIPT;
}
function startPage($page_title, $javascript) {
echo <<<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>$page_title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript"><!--
$javascript
//-->
</script>
</head>
<body>
HEAD;
}
function endPage(){
echo "\n</body></html>\n";
}
/// Called twice from printPage($encoded_todo)
function showControlButtonsRow($table_width,$readonly,$testMode,$showSeqMode,$encoded_todo,$imagesNumber,$imagesPerRow,$imgScale,$checkNotUncheck) {
printf ("<tr style=''><td colspan=%d>",$table_width-($readonly?0:1));
if (!$readonly) {
if ($testMode>=0) {
printf ("<label style='border: 1px solid #000;' for='id_test_mode' title='Add compressor start (before) and compressor stop (after) the sequence'>".
"Test".
"<input type='checkbox' name='test_mode' id='id_test_mode' value='1' %s".
" />".
"</label>",
($testMode>0)?'checked':'');
}
if ($showSeqMode>=0) {
printf ("<label style='border: 1px solid #000;' for='id_show_seq' title='Show command sequence and the sequence progress'>".
"ShowSeq".
"<input type='checkbox' name='show_seq' id='id_show_seq' value='1' %s".
" />".
"</label>",
($showSeqMode>0)?'checked':'');
}
printf ("<input type='submit' value='Apply' title='Program the parameters (selected by \"Apply\" checkboxes) to the camera'/>\n");
}
printf ("<input type='button' value='Refresh'onclick='refreshPage(1);' title='Reload the page, keep camera parameters (does not preserve delays yet)'/>\n");
printf ("<input type='button' value='Restart'onclick= 'refreshPage(0);' title='Reload the page, keep URL parameters'/>\n");
if ($encoded_todo) { // show link to last images
printf ("<a href='?images=%d:%d:%f&done=%s' target='new'>Last acquired images</a>\n",$imagesNumber,$imagesPerRow,$imgScale,$encoded_todo);
}
if (!$readonly) {
if ($checkNotUncheck)
printf ("</td><td style='text-align:center'><input type='button' value='&nbsp;Select&nbsp;\nAll'onclick='checkAll();' title='Check all \"Apply\" the checkboxes'/>\n");
else
printf ("</td><td style='text-align:center'><input type='button' value='Deselect\nAll'onclick='unCheckAll();' title='Uncheck all \"Apply\" the checkboxes'/>\n");
}
printf ("</td></tr>\n");
}
function printPage($encoded_todo) {
global $frame_params,$global_params,$page_title,$brief,$testMode,$showSeqMode,
$imagesNumber,$imagesPerRow,$imgScale,$embedImageScale,$imgsrv,$imglink,$descriptions;
$readonly=true;
foreach ($frame_params as $par) if ($par['write_en']) {
$readonly=false;
break;
}
if ($readonly) foreach ($global_params as $par) if ($par['write_en']) {
$readonly=false;
break;
}
$table_width=$readonly?5:9;
if ($brief) $table_width-=2;
// printf ("<center><h3>$page_title</h3></center>\n");
/// printf ("<h3>$page_title</h3>\n");
printf ("<form action=\"$self\" method=\"post\">");
printf ("<table border='1' style='font-family: Courier, monospace;'>\n");
if ($embedImageScale) {
$fd_circ=fopen("/dev/circbuf","r");
fseek($fd_circ, ELPHEL_LSEEK_CIRC_LAST,SEEK_END);
$circbuf_pointer=ftell($fd_circ);
fclose($fd_circ);
// echo "circbuf_pointer=$circbuf_pointer";
if ($circbuf_pointer>=0) {
$meta=elphel_get_interframe_meta($circbuf_pointer);
$width= floor($meta['width']*$embedImageScale);
$height=floor($meta['height']*$embedImageScale);
//echo "width=$width, height=$height, embedImageScale=$embedImageScale<br />\n";
printf ("<tr style='text-align:center'>".
"<td colspan=$table_width>");
/// printf ("<a href='$imgsrv/%d/$imglink'><img src='$imgsrv/%d/$imglink' style='width:%dpx; height:%dpx;' /></a>",$circbuf_pointer,$circbuf_pointer, $width,$height);
printf ("<a href='$imgsrv/$imglink' target='new'><img src='$imgsrv/%d/$imglink' style='width:%dpx; height:%dpx;' title='Click on the image to open the last acquired one - it may be different than this one (if acquisition is going on)' /></a>",$circbuf_pointer, $width,$height);
printf ("</td></tr>\n");
}
}
showControlButtonsRow($table_width,$readonly,$testMode,$showSeqMode,$encoded_todo,$imagesNumber,$imagesPerRow,$imgScale,true);
printf ("<tr style='text-align:center'>".
"<td rowspan=2>Parameter name</td>");
if (!$brief) {printf (
"<td colspan=2>Number</td>");
}
printf ("<td colspan=2>Current value</td>");
if (!$readonly) {printf (
"<td colspan=2>New value</td>".
"<td rowspan=2>Program<br/>ahead</td>".
"<td rowspan=2>Apply</td></tr>");
}
printf ("</tr>");
printf ("<tr style='text-align:center'>");
if (!$brief) {printf (
"<td>&nbsp;dec&nbsp;</td>".
"<td>&nbsp;hex&nbsp;</td>");
}
printf ("<td>&nbsp;&nbsp;&nbsp;dec&nbsp;&nbsp;&nbsp;&nbsp;</td>".
"<td>&nbsp;&nbsp;&nbsp;hex&nbsp;&nbsp;&nbsp;&nbsp;</td>");
if (!$readonly) {printf (
"<td>&nbsp;&nbsp;&nbsp;dec&nbsp;&nbsp;&nbsp;&nbsp;</td>".
"<td>&nbsp;&nbsp;&nbsp;hex&nbsp;&nbsp;&nbsp;&nbsp;</td>");
}
printf ("</tr>");
if (count($frame_params)) {
printf ("<tr><td colspan='$table_width' style='text-align:center'>Frame-related parameters</td></tr>\n");
foreach ($frame_params as $num=>$par) {
// printf ("<tr title='%s'>",$descriptions[$par['name']]);
printf ("<tr title='%s'>",getDescription ($par['name'],$descriptions));
printf ("<td>%s</td>",$par['name']);
if (!$brief) {
printf ("<td style='text-align:right'>%d</td>",$num);
printf ("<td style='text-align:right'>0x%x</td>",$num);
}
printf ("<td style='text-align:right'>%d</td>",$par['cur_value']);
printf ("<td style='text-align:right'>0x%x".
"<input type='hidden' name='oldval_%d' value='%d'>".
"<input type='hidden' name='name_%d' value='%s'>".
"</td>",$par['cur_value'],$num,$par['cur_value'],$num,$par['name']);
if ($par['write_en']) {
printf ("<td><input name='paramdec_%d' type='text' size='8' value='%d' id='id_dec_%d' style='text-align:right'".
" onchange='onchangeDec(this,\"id_hex_%d\",\"id_apply_%d\");'/></td>",$num,$par['value'],$num,$num,$num);
printf ("<td style='white-space:nowrap'>0x<input name='paramhex_%d' type='text' size='8' value='%x' id='id_hex_%d' style='text-align:left'".
" onchange='onchangeHex(this,\"id_dec_%d\",\"id_apply_%d\");'/></td>",$num,$par['value'],$num,$num,$num);
printf ("<td style='text-align:center'><input name='delay_%d' type='text' size='4' value='%d' id='id_delay_%d' style='text-align:right'".
" onchange='onchangeDelay(this,\"id_apply_%d\");'/></td>",$num,$par['ahead'],$num,$num);
printf ("<td style='text-align:center'><input type='checkbox' name='apply_%d' value='1' %s id='id_apply_%d'/></td>",$num,$par['modified']?'checked':'',$num);
}else {
if (!$readonly) printf ("<td colspan='4'>&nbsp;</td>");
}
printf ("</tr>\n");
}
}
if (count($global_params)) {
if ($table_width<5) printf ("<tr><td colspan='$table_width' style='text-align:center'>Global parameters</td></tr>\n");
else printf ("<tr><td colspan='$table_width' style='text-align:center'>Global (not related to particular frames) parameters</td></tr>\n");
foreach ($global_params as $num=>$par) {
// printf ("<tr title='%s'>",$descriptions[$par['name']]);
printf ("<tr title='%s'>",getDescription ($par['name'],$descriptions));
printf ("<td>%s</td>",$par['name']);
if (!$brief) {
printf ("<td style='text-align:right'>%d</td>",$num);
printf ("<td style='text-align:right'>0x%x</td>",$num);
}
printf ("<td style='text-align:right'>%d</td>",$par['cur_value']);
printf ("<td style='text-align:right'>0x%x".
"<input type='hidden' name='oldval_%d' value='%d'>".
"<input type='hidden' name='name_%d' value='%s'>".
"</td>",$par['cur_value'],$num,$par['cur_value'],$num,$par['name']);
if ($par['write_en']) {
printf ("<td><input name='paramdec_%d' type='text' size='8' value='%d' id='id_dec_%d' style='text-align:right'".
" onchange='onchangeDec(this,\"id_hex_%d\",\"id_apply_%d\");'/></td>",$num,$par['value'],$num,$num,$num);
printf ("<td colspan='2' style='white-space:nowrap'>0x<input name='paramhex_%d' type='text' size='8' value='%x' id='id_hex_%d' style='text-align:left'".
" onchange='onchangeHex(this,\"id_dec_%d\",\"id_apply_%d\");'/></td>",$num,$par['value'],$num,$num,$num);
printf ("<td style='text-align:center'><input type=\"checkbox\" name=\"apply_%d\" value=\"1\" %s id='id_apply_%d'/></td>",$num,$par['modified']?'checked':'',$num);
}else {
if (!$readonly) printf ("<td colspan='4'>&nbsp;</td>");
}
printf ("</tr>\n");
}
}
showControlButtonsRow($table_width,$readonly,$testMode,$showSeqMode,$encoded_todo,$imagesNumber,$imagesPerRow,$imgScale,false);
printf ("</table>\n");
printf ("</form>\n");
}
function getDescription ($compositeName,$descriptions){
if (array_key_exists($compositeName,$descriptions)) return $descriptions[$compositeName];
/// try to find a parent name
$number=elphel_parse_P_name($compositeName);
if (!$number) return "Unknown name";
$prefix="";
// is it a bit field?
$width= ($number >> 21) & 0x1f;
$bit= ($number >> 16) & 0x1f;
$name=$compositeName;
if ($bit || $width) {
$name=substr($compositeName,0,strlen($compositeName)-strlen('__XXYY'));
if ($width==1) $prefix.= sprintf("This is the bit %d of %s - ",$bit,$name);
else $prefix.= sprintf("This is a bit selection - bits %d through %d of %s - ",$bit,($bit+$width-1),$name);
$number=elphel_parse_P_name($name);
if (!$number) {
echo "Internal error in parsedit.php:Unknown name $name of $compositeName";
exit (1);
}
}
if (array_key_exists($name,$descriptions)) return $prefix.$descriptions[$name];
$index="";
/// see if it has displacement from a known name
while ($name && strpos (" 0123456789", $name[strlen($name)-1])) {
$index= $name[strlen($name)-1].$index;
$name=substr($name, 0, strlen($name)-1);
}
if ($prefix) $prefix.="offset ".$index." of ".$name." - ";
else $prefix.="This is the parameter at offset ".$index." of ".$name." - ";
if (array_key_exists($name,$descriptions)) return $name.": ".$prefix."++".$descriptions[$name];
return $prefix."no description available";
}
/*
/// compose bit fields to be OR-ed to the parameter number bit 16..25: b - start bit (0..31), w - width 1..32
#define FRAMEPAIR_FRAME_BITS(w,b) ((((w) & 0x1f)<<21) | (((b) & 0x1f)<<16))
/// Shift new data (nd), apply mask and combine with old data (od), taking shift/width information from bits 16..25 of (a)
#define FRAMEPAIR_FRAME_MASK_NEW(a,od,nd) ((((od) ^ ((nd) << (((a)>>16) & 0x1f))) & (((1 << (((a)>>21) & 0x1f))-1) << (((a)>>16) & 0x1f))) ^ (od))
*/
function getParDescriptions($autocampars) {
$file=file($autocampars);
$path="";
foreach ($file as $line) if (strpos($line,'$configPath')!==false ){
$name= strtok ($line,'"');
if (strpos ($name,'//')===false) {
$path=strtok ('"');
break;
}
}
$xml = simplexml_load_file($path);
$descriptions=array();
foreach ($xml->descriptions->children() as $entry) {
$descriptions[$entry->getName()]=str_replace('`',"\n",trim((string)$entry,"\""));
}
return $descriptions;
}
///============
?>
<?php
phpinfo();
?>
User-agent: *
Noindex: /
Disallow: /
Allow: /camvc.html
Allow: /webcam.php
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