Commit 41401431 authored by Andrey Filippov's avatar Andrey Filippov

Added python test code

parent 3c863b6f
# Runs 'make', 'make install', and 'make clean' in specified subdirectories # Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/php_top # src1 SUBDIRS := src/php_top src/python_tests # src1
INSTALLDIRS = $(SUBDIRS:%=install-%) INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS = $(SUBDIRS:%=clean-%) CLEANDIRS = $(SUBDIRS:%=clean-%)
......
...@@ -106,13 +106,15 @@ ...@@ -106,13 +106,15 @@
*! *!
*/ */
function myval ($s) { function myval($s) {
$s=trim($s,"\" "); $s = trim ( $s, "\" " );
if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s)); if (strtoupper ( substr ( $s, 0, 2 ) ) == "0X")
else return intval($s); return intval ( hexdec ( $s ) );
else
return intval ( $s );
} }
$imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081"; $imgsrv = "http://" . $_SERVER ['SERVER_ADDR'] . ":8081";
if (count($_GET)==0) { if (count ( $_GET ) == 0) {
echo <<<USAGE 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>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> <p>At this alpha stage very few programs/pages are working, among them:</p>
...@@ -145,52 +147,77 @@ function myval ($s) { ...@@ -145,52 +147,77 @@ function myval ($s) {
<li><b>"gamma=G</b> - show raw data of the gamma page <b>G</b> (page 0 is a root)</li> <li><b>"gamma=G</b> - show raw data of the gamma page <b>G</b> (page 0 is a root)</li>
</ul> </ul>
USAGE; USAGE;
exit (0); exit ( 0 );
} }
//$_SERVER["SERVER_ADDR"] . ":8081 // $_SERVER["SERVER_ADDR"] . ":8081
$sensor_port=0; /// TODO: NC393 - add sensor port control, initially will use $sensor_port=0 for all php functions that require it $sensor_port = 0; // / TODO: NC393 - add sensor port control, initially will use $sensor_port=0 for all php functions that require it
$address=""; $sensor_subchn = 0; // / TODO: NC393 - add sensor port control, initially will use $sensor_port=0 for all php functions that require it
$data=""; $address = "";
$frame=""; $data = "";
$gamma_page=""; $frame = "";
$flags=0; $gamma_page = "";
$elp_const=get_defined_constants(true); $flags = 0;
$elp_const=$elp_const["elphel"]; $elp_const = get_defined_constants ( true );
$test=0; $elp_const = $elp_const ["elphel"];
$hist_needed=0; $test = 0;
foreach($_GET as $key=>$value) { $hist_needed = 0;
switch($key) { $framepars_paths = array ("/dev/frameparsall0",
case "profile": "/dev/frameparsall1",
$num_entries=myval($value); "/dev/frameparsall2",
//echo "<pre>"; "/dev/frameparsall3");
$prof_template=array(
"PROFILE00"=>0,"PROFILE01"=>0, if (array_key_exists ( 'sensor_port', $_GET )) {
"PROFILE02"=>0,"PROFILE03"=>0, $sensor_port = (myval($_GET ['sensor_port'])) & 3;
"PROFILE04"=>0,"PROFILE05"=>0, }
"PROFILE06"=>0,"PROFILE07"=>0, if (array_key_exists ( 'sensor_subchn', $_GET )) {
"PROFILE08"=>0,"PROFILE09"=>0, $sensor_port = (myval($_GET ['sensor_subchn'])) & 3;
"PROFILE10"=>0,"PROFILE11"=>0, }
"PROFILE12"=>0,"PROFILE13"=>0, $framepars_path = $framepars_paths[$sensor_port];
"PROFILE14"=>0,"PROFILE15"=>0 foreach ( $_GET as $key => $value ) {
); switch ($key) {
$now=elphel_get_frame()-2; /// data is available 2 frames behind case "profile" :
$time_start=elphel_get_fpga_time(); $num_entries = myval ( $value );
$prof_raw=array(); // echo "<pre>";
for ($i=$now-$num_entries-1;$i<=$now;$i++) { $prof_template = array (
$prof_raw[$i]=elphel_get_P_arr($prof_template,$i); "PROFILE00" => 0,
} "PROFILE01" => 0,
$time_end=elphel_get_fpga_time(); "PROFILE02" => 0,
$prof=array(); "PROFILE03" => 0,
for ($i=$now-$num_entries;$i<=$now;$i++) { "PROFILE04" => 0,
$prof[$i]=array ( "dt0"=>($prof_raw[$i]["PROFILE00"]-$prof_raw[$i-1]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE01"]-$prof_raw[$i-1]["PROFILE01"]), "PROFILE05" => 0,
"dt1"=>($prof_raw[$i]["PROFILE02"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE03"]-$prof_raw[$i]["PROFILE01"]), "PROFILE06" => 0,
"dt2"=>($prof_raw[$i]["PROFILE04"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE05"]-$prof_raw[$i]["PROFILE01"]), "PROFILE07" => 0,
"dt3"=>($prof_raw[$i]["PROFILE06"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE07"]-$prof_raw[$i]["PROFILE01"]), "PROFILE08" => 0,
"dt4"=>($prof_raw[$i]["PROFILE08"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE09"]-$prof_raw[$i]["PROFILE01"]), "PROFILE09" => 0,
"dt5"=>($prof_raw[$i]["PROFILE10"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE11"]-$prof_raw[$i]["PROFILE01"]), "PROFILE10" => 0,
"dt6"=>($prof_raw[$i]["PROFILE12"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE13"]-$prof_raw[$i]["PROFILE01"]), "PROFILE11" => 0,
"dt7"=>($prof_raw[$i]["PROFILE14"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE15"]-$prof_raw[$i]["PROFILE01"])); "PROFILE12" => 0,
foreach ($prof[$i] as $key=>$value) if ($prof[$i][$key]<0)$prof[$i][$key]=""; "PROFILE13" => 0,
"PROFILE14" => 0,
"PROFILE15" => 0
);
$now = elphel_get_frame ($GLOBALS['sensor_port']) - 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 ($GLOBALS['sensor_port'], $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 echo <<<CAPTION
...@@ -207,336 +234,350 @@ $time_end=elphel_get_fpga_time(); ...@@ -207,336 +234,350 @@ $time_end=elphel_get_fpga_time();
</oul> </oul>
<br/><br/> <br/><br/>
CAPTION; 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" );
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 ++) {
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"] );
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 ++) {
for ($j=1;$j<8;$j++) { if ($prof [$i] ["dt" . $j])
if ($prof[$i]["dt".$j]) printf("<td>%d</td>",$prof[$i]["dt".$j]); printf ( "<td>%d</td>", $prof [$i] ["dt" . $j] );
else printf("<td>&nbsp;</td>"); else
printf ( "<td>&nbsp;</td>" );
} }
printf("</tr>\n"); printf ( "</tr>\n" );
} }
printf("</table>"); printf ( "</table>" );
//echo "<pre>";print_r($prof_raw);echo"</pre>\n"; // echo "<pre>";print_r($prof_raw);echo"</pre>\n";
exit (0); exit ( 0 );
case "histogram_direct": case "histogram_direct" :
case "histogram_reverse": case "histogram_reverse" :
case "gamma_direct": case "gamma_direct" :
case "gamma_reverse": case "gamma_reverse" :
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>"); $xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
$value=floatval($value); $value = floatval ( $value );
switch($key) { switch ($key) {
case "histogram_direct": case "histogram_direct" :
$xml->addChild ('histogram_direct_r', elphel_histogram(0,$value)); $xml->addChild ( 'histogram_direct_r', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('histogram_direct_g', elphel_histogram(1,$value)); $xml->addChild ( 'histogram_direct_g', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('histogram_direct_gb',elphel_histogram(2,$value)); $xml->addChild ( 'histogram_direct_gb', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ('histogram_direct_b', elphel_histogram(3,$value)); $xml->addChild ( 'histogram_direct_b', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
break; break;
case "histogram_reverse": case "histogram_reverse" :
$xml->addChild ('histogram_reverse_r', elphel_reverse_histogram(0,$value)); $xml->addChild ( 'histogram_reverse_r', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('histogram_reverse_g', elphel_reverse_histogram(1,$value)); $xml->addChild ( 'histogram_reverse_g', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('histogram_reverse_gb',elphel_reverse_histogram(2,$value)); $xml->addChild ( 'histogram_reverse_gb', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ('histogram_reverse_b', elphel_reverse_histogram(3,$value)); $xml->addChild ( 'histogram_reverse_b', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
break; break;
case "gamma_direct": case "gamma_direct" :
$xml->addChild ('gamma_direct_r', elphel_gamma(0,$value)); $xml->addChild ( 'gamma_direct_r', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('gamma_direct_g', elphel_gamma(1,$value)); $xml->addChild ( 'gamma_direct_g', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('gamma_direct_gb',elphel_gamma(2,$value)); $xml->addChild ( 'gamma_direct_gb', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ('gamma_direct_b', elphel_gamma(3,$value)); $xml->addChild ( 'gamma_direct_b', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
break; break;
case "gamma_reverse": case "gamma_reverse" :
$xml->addChild ('gamma_reverse_r', elphel_reverse_gamma(0,$value)); $xml->addChild ( 'gamma_reverse_r', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('gamma_reverse_g', elphel_reverse_gamma(1,$value)); $xml->addChild ( 'gamma_reverse_g', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('gamma_reverse_gb',elphel_reverse_gamma(2,$value)); $xml->addChild ( 'gamma_reverse_gb', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ('gamma_reverse_b', elphel_reverse_gamma(3,$value)); $xml->addChild ( 'gamma_reverse_b', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
break; break;
} }
$rslt=$xml->asXML(); $rslt = $xml->asXML ();
header("Content-Type: text/xml"); header ( "Content-Type: text/xml" );
header("Content-Length: ".strlen($rslt)."\n"); header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
header("Pragma: no-cache\n"); header ( "Pragma: no-cache\n" );
printf($rslt); printf ( $rslt );
exit (0); exit ( 0 );
case "cmd": case "cmd" :
case "seek": case "seek" :
case "fseek": case "fseek" :
case "lseek": case "lseek" :
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>"); $xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
if (!$value) { if (! $value) {
$xml->addChild ('frame',elphel_get_frame()); $xml->addChild ( 'frame', elphel_get_frame ($GLOBALS['sensor_port']) );
$xml->addChild ('frame8',elphel_fpga_read(0x16) & 7); // $xml->addChild ( 'frame8', elphel_fpga_read ( 0x16 ) & 7 );
} else if ($value=="time"){ } else if ($value == "time") {
$xml->addChild ('fpga_time',elphel_get_fpga_time()); $xml->addChild ( 'fpga_time', elphel_get_fpga_time ($GLOBALS['sensor_port']) );
} else if ($value=="irqoff"){ } else if ($value == "irqoff") {
$framepars_file=fopen("/dev/frameparsall","r"); $framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ('irqoff_result',fseek($framepars_file,ELPHEL_LSEEK_INTERRUPT_OFF,SEEK_END)); //#define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts $xml->addChild ( 'irqoff_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_OFF, SEEK_END ) ); // #define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts
fclose($framepars_file); fclose ( $framepars_file );
} else if ($value=="irqon"){ } else if ($value == "irqon") {
/// wait for frame8=0 // / wait for frame8=0
while (elphel_fpga_read(0x16) & 7) usleep (1000); /// Maybe needed to wait for 7, then 0? // while ( elphel_fpga_read ( 0x16 ) & 7 )
$framepars_file=fopen("/dev/frameparsall","r"); // usleep ( 1000 ); // / Maybe needed to wait for 7, then 0?
$xml->addChild ('irqon_result',fseek($framepars_file,ELPHEL_LSEEK_INTERRUPT_ON,SEEK_END)); //#define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts $framepars_file = fopen ( $framepars_path, "r" );
fclose($framepars_file); $xml->addChild ( 'irqon_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
} else if ($value=="init"){ fclose ( $framepars_file );
$framepars_file=fopen("/dev/frameparsall","r"); } else if ($value == "init") {
$xml->addChild ('LSEEK_FRAMEPARS_INIT',fseek($framepars_file,ELPHEL_LSEEK_FRAMEPARS_INIT,SEEK_END)); $framepars_file = fopen ( $framepars_path, "r" );
$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_FRAMEPARS_INIT', fseek ( $framepars_file, ELPHEL_LSEEK_FRAMEPARS_INIT, SEEK_END ) );
$xml->addChild ('LSEEK_SENSORPROC', fseek($framepars_file,ELPHEL_LSEEK_SENSORPROC, SEEK_END)); $xml->addChild ( 'elphel_set_P_value', elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ) ); // / will start detection
$frame=0; $xml->addChild ( 'LSEEK_SENSORPROC', fseek ( $framepars_file, ELPHEL_LSEEK_SENSORPROC, SEEK_END ) );
// gets half-frame $frame = 0;
// gets half-frame
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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 elphel_set_P_value ($GLOBALS['sensor_port'], 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) // / 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], 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 ($GLOBALS['sensor_port'], ELPHEL_COMPRESSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / run compressor
/* fclose ( $framepars_file );
elphel_set_P_value(ELPHEL_BITS, 8, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $gamma = 57;
elphel_set_P_value(ELPHEL_QUALITY, 80, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $black = 10;
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $scale_r = ( int ) (1.0 * 1024);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $scale_g = ( int ) (0.9 * 1024);
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $scale_b = ( int ) (1.1 * 1024);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $scale_gb = ( int ) (0.9 * 1024);
*/ elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
// 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.
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 // 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), $gamma_pars = array (
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$frame=elphel_get_frame(); //0 "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
elphel_set_P_arr ($gamma_pars, $frame+3,0); );
} else if ($value=="gamma57"){ $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
$gamma=57; elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
$black=10; } else if ($value == "gamma57") {
$scale_r= (int) (1.0 * 1024); $gamma = 57;
$scale_g= (int) (1.0 * 1024); $black = 10;
$scale_b= (int) (1.0 * 1024); $scale_r = ( int ) (1.0 * 1024);
$scale_gb=(int) (1.0 * 1024); $scale_g = ( int ) (1.0 * 1024);
elphel_gamma_add (0.01*$gamma, $black); $scale_b = ( int ) (1.0 * 1024);
#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. $scale_gb = ( int ) (1.0 * 1024);
elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
// 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 // 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), $gamma_pars = array (
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$frame=elphel_get_frame(); //0 "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
elphel_set_P_arr ($gamma_pars, $frame+3,0); );
} else if ($value=="gamma"){ $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
$gamma=60; elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
$black=10; } else if ($value == "gamma") {
$scale_r= (int) (1.0 * 1024); $gamma = 60;
$scale_g= (int) (0.9 * 1024); $black = 10;
$scale_b= (int) (1.1 * 1024); $scale_r = ( int ) (1.0 * 1024);
$scale_gb=(int) (0.9 * 1024); $scale_g = ( int ) (0.9 * 1024);
elphel_gamma_add (0.01*$gamma, $black); $scale_b = ( int ) (1.1 * 1024);
#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. $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 // 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), $gamma_pars = array (
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$frame=elphel_get_frame(); //0 "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
elphel_set_P_arr ($gamma_pars, $frame+3,0); );
} else if ($value=="linear"){ $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
$gamma=100; elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
$black=0; } else if ($value == "linear") {
$scale_r= (int) (1.0 * 1024); $gamma = 100;
$scale_g= (int) (1.0 * 1024); $black = 0;
$scale_b= (int) (1.0 * 1024); $scale_r = ( int ) (1.0 * 1024);
$scale_gb=(int) (1.0 * 1024); $scale_g = ( int ) (1.0 * 1024);
elphel_gamma_add (0.01*$gamma, $black); $scale_b = ( int ) (1.0 * 1024);
#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. $scale_gb = ( int ) (1.0 * 1024);
elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
// 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 // 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), $gamma_pars = array (
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$frame=elphel_get_frame(); //0 "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
elphel_set_P_arr ($gamma_pars, $frame+3,0); );
} else if ($value=="initgamma"){ $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
$gammas_file=fopen("/dev/gamma_cache","r"); elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
$xml->addChild ('LSEEK_GAMMA_INIT',fseek($gammas_file,ELPHEL_LSEEK_GAMMA_INIT,SEEK_END)); } else if ($value == "initgamma") {
fclose($gammas_file); $gammas_file = fopen ( "/dev/gamma_cache", "r" );
} else if ($value=="jpegheader"){ $xml->addChild ( 'LSEEK_GAMMA_INIT', fseek ( $gammas_file, ELPHEL_LSEEK_GAMMA_INIT, SEEK_END ) );
$circbuf_file=fopen("/dev/circbuf","r"); fclose ( $gammas_file );
fseek($circbuf_file,ELPHEL_LSEEK_CIRC_LAST,SEEK_END); } else if ($value == "jpegheader") {
$jpeg_start=ftell($circbuf_file); $circbuf_file = fopen ( "/dev/circbuf", "r" );
$xml->addChild ('circbuf_pointer',sprintf("0x%x (0x%x)",$jpeg_start,$jpeg_start>>2)); fseek ( $circbuf_file, ELPHEL_LSEEK_CIRC_LAST, SEEK_END );
fclose($circbuf_file); $jpeg_start = ftell ( $circbuf_file );
$header_file=fopen("/dev/jpeghead","r"); $xml->addChild ( 'circbuf_pointer', sprintf ( "0x%x (0x%x)", $jpeg_start, $jpeg_start >> 2 ) );
/// Now select right frame (different frames may have different header sizes) fclose ( $circbuf_file );
fseek($header_file,$jpeg_start+1,SEEK_END); /// selects frame, creates header $header_file = fopen ( "/dev/jpeghead", "r" );
fseek($header_file,0,SEEK_END); /// positions to the end // / Now select right frame (different frames may have different header sizes)
$header_size=ftell($header_file); /// fseek ( $header_file, $jpeg_start + 1, SEEK_END ); // / selects frame, creates header
$xml->addChild ('header_size',$header_size); fseek ( $header_file, 0, SEEK_END ); // / positions to the end
fseek($header_file,0,SEEK_SET); /// positions to the beginning $header_size = ftell ( $header_file ); // /
$header=fread ($header_file,8192); $xml->addChild ( 'header_size', $header_size );
$xml->addChild ('header_read_length',strlen($header)); fseek ( $header_file, 0, SEEK_SET ); // / positions to the beginning
fclose($header_file); $header = fread ( $header_file, 8192 );
$aheader=unpack('C*',$header); $xml->addChild ( 'header_read_length', strlen ( $header ) );
for ($i=0; $i<count($aheader) ;$i+=16){ fclose ( $header_file );
$d=""; $aheader = unpack ( 'C*', $header );
for ($j=$i; ($j<$i+16) && ($j<count($aheader)); $j++) $d.=sprintf(" %02x",$aheader[$j+1]); for($i = 0; $i < count ( $aheader ); $i += 16) {
$xml->addChild (sprintf('header%03x',$i),$d); $d = "";
} for($j = $i; ($j < $i + 16) && ($j < count ( $aheader )); $j ++)
} else if ($value=="reset"){ $d .= sprintf ( " %02x", $aheader [$j + 1] );
$framepars_file=fopen("/dev/frameparsall","r"); $xml->addChild ( sprintf ( 'header%03x', $i ), $d );
$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)); } else if ($value == "reset") {
$xml->addChild ('LSEEK_COMPRESSOR_RESET', fseek($framepars_file,ELPHEL_LSEEK_COMPRESSOR_RESET,SEEK_END)); $framepars_file = fopen ( $framepars_path, "r" );
fclose($framepars_file); $xml->addChild ( 'LSEEK_DMA_STOP', fseek ( $framepars_file, ELPHEL_LSEEK_DMA_STOP, SEEK_END ) );
} else if ($value=="constants"){ $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"; echo "<pre>\n";
print_r($elp_const); print_r ( $elp_const );
echo "</pre>\n"; echo "</pre>\n";
exit(0); exit ( 0 );
} else { } else {
$framepars_file=fopen("/dev/frameparsall","r"); $framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ('lseek_'.$value,fseek($framepars_file,$value,SEEK_END)); $xml->addChild ( 'lseek_' . $value, fseek ( $framepars_file, $value, SEEK_END ) );
fclose($framepars_file); fclose ( $framepars_file );
} }
$rslt = $xml->asXML ();
$rslt=$xml->asXML(); header ( "Content-Type: text/xml" );
header("Content-Type: text/xml"); header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
header("Content-Length: ".strlen($rslt)."\n"); header ( "Pragma: no-cache\n" );
header("Pragma: no-cache\n"); printf ( $rslt );
printf($rslt); exit ( 0 );
exit (0); case "a" : // / Make it recognize P_* constants?
case "a": /// Make it recognize P_* constants? case "adr" :
case "adr": case "na" : // / add flag "new"
case "na": /// add flag "new" case "sa" : // / add flag "static"
case "sa": /// add flag "static" $address = myval ( $value );
$address=myval ($value); if (($address == 0) && (strlen ( $value ) > 3)) { // suspect constant
if (($address==0) && (strlen($value)>3)) { // suspect constant $address = $elp_const ["ELPHEL_" . $value];
$address=$elp_const["ELPHEL_".$value]; }
} switch ($key) {
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)
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;
$address |= ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC;; ;
break; break;
case "sa": case "sa" :
$address |= ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO; $address |= ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO;
break; break;
} }
if (($address & 0xffff) ==0) { /// wrong address - probably mistyped constant name if (($address & 0xffff) == 0) { // / wrong address - probably mistyped constant name
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>"); $xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
$xml->addChild ('ERROR','"Wrong address==0, probably misspelled constant: \''.$value.'\'"' ); $xml->addChild ( 'ERROR', '"Wrong address==0, probably misspelled constant: \'' . $value . '\'"' );
$rslt=$xml->asXML(); $rslt = $xml->asXML ();
header("Content-Type: text/xml"); header ( "Content-Type: text/xml" );
header("Content-Length: ".strlen($rslt)."\n"); header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
header("Pragma: no-cache\n"); header ( "Pragma: no-cache\n" );
printf($rslt); printf ( $rslt );
exit (0); exit ( 0 );
} }
break; break;
case "d": case "d" :
case "data": case "data" :
$data=myval ($value); $data = myval ( $value );
break; break;
case "hist_raw": case "hist_raw" :
$hist_needed++; $hist_needed ++;
case "hist": case "hist" :
case "histogram": case "histogram" :
$hist_needed++; /// and fall to "frame" $hist_needed ++; // / and fall to "frame"
case "f": case "f" :
case "frame": case "frame" :
$current_frame=elphel_get_frame(); $current_frame = elphel_get_frame ($GLOBALS['sensor_port']);
switch ($value) { switch ($value) {
case "this": $frame=$current_frame; case "this" :
$frame = $current_frame;
break; break;
case "next": $frame=$current_frame+1; case "next" :
$frame = $current_frame + 1;
break; break;
case "next2": $frame=$current_frame+2; case "next2" :
$frame = $current_frame + 2;
break; break;
case "next3": $frame=$current_frame+3; case "next3" :
$frame = $current_frame + 3;
break; break;
case "next4": $frame=$current_frame+4; case "next4" :
$frame = $current_frame + 4;
break; break;
case "next5": $frame=$current_frame+5; case "next5" :
$frame = $current_frame + 5;
break; break;
case "next6": $frame=$current_frame+6; case "next6" :
$frame = $current_frame + 6;
break; break;
break; break;
case "prev": $frame=$current_frame-1; case "prev" :
$frame = $current_frame - 1;
break; break;
case "prev2": $frame=$current_frame-2; case "prev2" :
$frame = $current_frame - 2;
break; break;
case "prev3": $frame=$current_frame-3; case "prev3" :
$frame = $current_frame - 3;
break; break;
case "prev4": $frame=$current_frame-4; case "prev4" :
$frame = $current_frame - 4;
break; break;
case "prev5": $frame=$current_frame-5; case "prev5" :
$frame = $current_frame - 5;
break; break;
case "prev6": $frame=$current_frame-6; case "prev6" :
$frame = $current_frame - 6;
break; break;
default: default :
$frame=myval ($value); $frame = myval ( $value );
} }
break; break;
case "flags": /// simple flags - "z(ero)"/"(s(tatic), "n(new)",+ constants case "flags" : // / simple flags - "z(ero)"/"(s(tatic), "n(new)",+ constants
case "flag": case "flag" :
switch ($value) { switch ($value) {
case "z": case "z" :
case "zero": case "zero" :
case "s": case "s" :
case "static": case "static" :
$flags=ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO; $flags = ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO;
break; break;
case "n": case "n" :
case "new": case "new" :
$flags=ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC; $flags = ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC;
break; break;
default: default :
$flags=myval ($value); $flags = myval ( $value );
} }
break; break;
case "t": case "t" :
case "test": case "test" :
$test=myval ($value); $test = myval ( $value );
break; break;
case "gamma": case "gamma" :
case "gamma_page": case "gamma_page" :
$gamma_page=myval ($value); $gamma_page = myval ( $value );
break; break;
case "gamma_structure": case "gamma_structure" :
/// later add value - list of pages to process // / later add value - list of pages to process
printGammaStructure(); printGammaStructure ();
/* echo "<pre>\n"; /*
var_dump(getGammaStructure()); * echo "<pre>\n";
echo "</pre>\n";*/ * var_dump(getGammaStructure());
exit (0); * echo "</pre>\n";
} */
} exit ( 0 );
if ($address==="") { }
if ($frame==="") { }
if ($gamma_page==="") { if ($address === "") {
if ($frame === "") {
if ($gamma_page === "") {
echo <<<USAGE echo <<<USAGE
<p>read/fwrite frame parameters, execute commands</p> <p>read/fwrite frame parameters, execute commands</p>
<ul> <ul>
...@@ -545,468 +586,543 @@ CAPTION; ...@@ -545,468 +586,543 @@ CAPTION;
<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> <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> </ul>
USAGE; USAGE;
exit (0); exit ( 0 );
} else { } else {
///read raw gamma page // /read raw gamma page
printRawGamma($gamma_page); printRawGamma ( $gamma_page );
exit (0); exit ( 0 );
} }
} else { ///$frame !== "" } else { // /$frame !== ""
switch ($hist_needed) { switch ($hist_needed) {
case 2: case 2 :
printRawHistogram(0xfff,$frame); printRawHistogram ( 0xfff, $frame );
exit (0); exit ( 0 );
case 1: case 1 :
printHistogram($frame); printHistogram ( $frame );
exit (0); exit ( 0 );
default: default :
/// read raw framepars // / read raw framepars
printRawFrame($frame); printRawFrame ( $frame );
exit (0); exit ( 0 );
} }
} }
} }
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>"); $xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
$xml->addChild ('frame',$frame); $xml->addChild ( 'frame', $frame );
$xml->addChild ('hex_frame',sprintf("0x%x",$frame)); $xml->addChild ( 'hex_frame', sprintf ( "0x%x", $frame ) );
$xml->addChild ('address',$address); $xml->addChild ( 'address', $address );
$xml->addChild ('hex_address',sprintf("0x%x",$address)); $xml->addChild ( 'hex_address', sprintf ( "0x%x", $address ) );
if ($data==="") { if ($data === "") {
if ($frame==='') $data=elphel_get_P_value($address); if ($frame === '')
else $data=elphel_get_P_value($address, $frame); $data = elphel_get_P_value ($GLOBALS['sensor_port'], $address );
$xml->addChild ('read',$data); else
$xml->addChild ('hex_read',sprintf("0x%x",$data)); $data = elphel_get_P_value ($GLOBALS['sensor_port'], $address, $frame );
} else { $xml->addChild ( 'read', $data );
if (($frame==='') && flags) $frame =0; $xml->addChild ( 'hex_read', sprintf ( "0x%x", $data ) );
$xml->addChild ('frame_was',$frame); } else {
///*************************************************************************** if (($frame === '') && flags)
if ($test>0) { $frame = 0;
ob_flush(); flush(); $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); elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_COMPRESSOR_RUN | ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC, ELPHEL_CONST_COMPRESSOR_RUN_CONT, $current_frame + 2 );
$frame+=2; $frame += 2;
$current_frame+=2; $current_frame += 2;
elphel_skip_frames(2); elphel_skip_frames ($GLOBALS['sensor_port'], 2 );
} }
if ($frame==='') elphel_set_P_value($address, $data); if ($frame === '')
else elphel_set_P_value($address, $data, $frame, $flags); elphel_set_P_value ($GLOBALS['sensor_port'], $address, $data );
if ($test>0) { else
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); elphel_set_P_value ($GLOBALS['sensor_port'], $address, $data, $frame, $flags );
ob_flush(); flush(); ///OK here if ($test > 0) {
$circbuf_file=fopen("/dev/circbuf","r"); 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 );
$current_frame=$frame; ob_flush ();
printf ("<p>frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush(); flush (); // /OK here
elphel_skip_frames(2); $circbuf_file = fopen ( "/dev/circbuf", "r" );
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(); $current_frame = $frame;
// printf ("<p>start_frame2=0x%x</p>\n",$current_frame); printf ( "<p>frame=%d (0x%x), time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
ob_flush ();
flush ();
elphel_skip_frames ($GLOBALS['sensor_port'], 2 );
printf ( "<p>target frame=%d (0x%x) frame=%d(0x%x), time=%d </p>\n", $frame, $frame, elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), 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); elphel_set_P_value ($GLOBALS['sensor_port'], 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(); printf ( "<p>frame=%d (0x%x), time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
$current_frame+=6; /// to be sure - less is enough? ob_flush ();
for ($i=0;$i<6;$i++) { flush ();
elphel_skip_frames(1); $current_frame += 6; // / to be sure - less is enough?
printf ("<p>skipped 1 frame - frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush(); for($i = 0; $i < 6; $i ++) {
} elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
// elphel_skip_frames(6); printf ( "<p>skipped 1 frame - frame=%d (0x%x), time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
// printf ("<p>after skip 6 frames - frame=0x%x, time=%d </p>\n",elphel_get_frame(),time()); ob_flush(); flush(); ob_flush ();
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); flush ();
///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($GLOBALS['sensor_port'],6);
elphel_skip_frames(1); // printf ("<p>after skip 6 frames - frame=0x%x, time=%d </p>\n",elphel_get_frame($GLOBALS['sensor_port']),time()); ob_flush(); flush();
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); 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(); // /stuck before here?
elphel_skip_frames(1); printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); ob_flush ();
printf ("<p>frame=%d (0x%x) time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush(); flush ();
elphel_skip_frames(1); elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); 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(); printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
ob_flush ();
flush ();
elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
fseek ( $circbuf_file, LSEEK_CIRC_TOWP, SEEK_END );
printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
ob_flush ();
flush ();
elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
fseek ( $circbuf_file, LSEEK_CIRC_TOWP, SEEK_END );
printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
ob_flush ();
flush ();
/// Strange - frame normal delay sometimes wrong images in the // / Strange - frame normal delay sometimes wrong images in the
// printf ("<p>end_frame2=0x%x</p>\n",elphel_get_frame()); // printf ("<p>end_frame2=0x%x</p>\n",elphel_get_frame($GLOBALS['sensor_port']));
fclose($circbuf_file); fclose ( $circbuf_file );
image_table8 (); image_table8 ();
exit (0); exit ( 0 );
$xml->addChild ('test',$test); $xml->addChild ( 'test', $test );
} }
$xml->addChild ('frame',$frame); $xml->addChild ( 'frame', $frame );
$xml->addChild ('written',$data); $xml->addChild ( 'written', $data );
$xml->addChild ('hex_written',sprintf("0x%x",$data)); $xml->addChild ( 'hex_written', sprintf ( "0x%x", $data ) );
$xml->addChild ('flags',sprintf("0x%x",$flags)); $xml->addChild ( 'flags', sprintf ( "0x%x", $flags ) );
} }
$rslt=$xml->asXML(); $rslt = $xml->asXML ();
header("Content-Type: text/xml"); header ( "Content-Type: text/xml" );
header("Content-Length: ".strlen($rslt)."\n"); header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
header("Pragma: no-cache\n"); header ( "Pragma: no-cache\n" );
printf($rslt); printf ( $rslt );
exit (0); exit ( 0 );
function printGammaStructure() { function printGammaStructure() {
$gammaStructure=getGammaStructure(); $gammaStructure = getGammaStructure ();
printf("<table \"border=1\">\n"); printf ( "<table \"border=1\">\n" );
printf( "<tr><td>oldest_non_scaled</td><td><b>%d</b></td></tr>\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] );
."<tr><td>newest_non_scaled</td><td><b>%d</b></td></tr>\n" printf ( "<br/><br/>\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 ( "<table \"border=1\">\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>index </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["index"]);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>index </td>\n" );
printf("<tr><td>black </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["black"]);printf("</tr>\n"); foreach ( $gammaStructure ["entries"] as $entry )
printf("<tr><td>valid </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%x</b></td>",$entry["valid"]);printf("</tr>\n"); printf ( "<td><a href='?gamma_page=%d'><b>%d</b></a></td>", $entry ["index"], $entry ["index"] );
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>\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");
}
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() { function getGammaStructure() {
$gammas_file=fopen("/dev/gamma_cache","r"); $gammas_file = fopen ( "/dev/gamma_cache", "r" );
fseek($gammas_file,0,SEEK_END); fseek ( $gammas_file, 0, SEEK_END );
$numberOfEntries=ftell($gammas_file); $numberOfEntries = ftell ( $gammas_file );
fclose($gammas_file); fclose ( $gammas_file );
$gammaStructure=array(); $gammaStructure = array ();
$g_raw=elphel_gamma_get_raw(0); $g_raw = elphel_gamma_get_raw ( 0 );// Does not depend on $GLOBALS['sensor_port']
$g_raw_ul=unpack('V*',$g_raw); $g_raw_ul = unpack ( 'V*', $g_raw );
$gammaStructure["oldest_non_scaled"]=$g_raw_ul[5]; $gammaStructure ["oldest_non_scaled"] = $g_raw_ul [5];
$gammaStructure["newest_non_scaled"]=$g_raw_ul[6]; $gammaStructure ["newest_non_scaled"] = $g_raw_ul [6];
$gammaStructure["oldest_all"]= $g_raw_ul[7]; $gammaStructure ["oldest_all"] = $g_raw_ul [7];
$gammaStructure["newest_all"]= $g_raw_ul[8]; $gammaStructure ["newest_all"] = $g_raw_ul [8];
$gammaStructure["non_scaled_length"]=$g_raw_ul[9]; $gammaStructure ["non_scaled_length"] = $g_raw_ul [9];
$gammaStructure["num_locked"]= $g_raw_ul[10]; $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 ["locked_col"] = array (
$gammaStructure["entries"]= array (); $g_raw_ul [11],
for ($i=1; $i<$numberOfEntries; $i++) { $g_raw_ul [12],
$g_raw=elphel_gamma_get_raw($i); $g_raw_ul [13],
$g_raw_ul=unpack('V*',$g_raw); $g_raw_ul [14]
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"] = array ();
$gammaStructure["entries"][$i]= array ( for($i = 1; $i < $numberOfEntries; $i ++) {
$g_raw = elphel_gamma_get_raw ( $i ); // Does not depend on $GLOBALS['sensor_port']
$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, "index" => $i,
"hash32"=> $hash32, "hash32" => $hash32,
"scale" => ($hash32 & 0xffff)/1024.0, "scale" => ($hash32 & 0xffff) / 1024.0,
"gamma" => (($hash32 >> 16) & 0xff)/100.0, "gamma" => (($hash32 >> 16) & 0xff) / 100.0,
"black" => (($hash32 >> 24) & 0xff), "black" => (($hash32 >> 24) & 0xff),
"valid" => $g_raw_ul[ 2], /// 0 - table invalid, 1 - table valid +2 for table locked (until sent to FPGA) "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 "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_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) // / 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 "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 "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 "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 "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) // /Next two pairs are the same (union)
"oldest_scaled" => $g_raw_ul[ 9], /// oldest derivative of this prototype (scaled) "oldest_scaled" => $g_raw_ul [9], // / oldest derivative of this prototype (scaled)
"newest_scaled" => $g_raw_ul[10], /// newest 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 "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 "older_scaled" => $g_raw_ul [10]
); ) // / table type (non-scaled prototype) used before this one
;
} }
} }
return $gammaStructure; return $gammaStructure;
} }
function printRawGamma($page = 0) {
function printRawGamma($page=0) { $g_raw = elphel_gamma_get_raw ( $page ); // Does not depend on $GLOBALS['sensor_port']
$g_raw=elphel_gamma_get_raw($page); // var_dump()
//var_dump() $g_raw_ul = unpack ( 'V*', $g_raw );
$g_raw_ul=unpack('V*',$g_raw);
echo "<pre>\n"; echo "<pre>\n";
printf ("Gamma cache page %d, length=%d\n",$page, strlen($g_raw)); printf ( "Gamma cache page %d, length=%d\n", $page, strlen ( $g_raw ) );
$a=1; /// unpack started with index 1 $a = 1; // / unpack started with index 1
$hash32= $g_raw_ul[$a++]; $hash32 = $g_raw_ul [$a ++];
$scale= ($hash32 & 0xffff)/1024.0; $scale = ($hash32 & 0xffff) / 1024.0;
$gamma= (($hash32 >> 16) & 0xff)/100.0; $gamma = (($hash32 >> 16) & 0xff) / 100.0;
$black= (($hash32 >> 24) & 0xff); $black = (($hash32 >> 24) & 0xff);
printf ("hash32= %08x (scale=%f gamma=%f black=%d)\n",$hash32,$scale,$gamma,$black); printf ( "hash32= %08x (scale=%f gamma=%f black=%d)\n", $hash32, $scale, $gamma, $black );
$valid= $g_raw_ul[$a++]; $valid = $g_raw_ul [$a ++];
printf ("valid=%d, locked=%d\n",$valid & 1, $valid & 2); printf ( "valid=%d, locked=%d\n", $valid & 1, $valid & 2 );
$locked= $g_raw_ul[$a++]; $locked = $g_raw_ul [$a ++];
printf ("locked= 0x%x (for frame=%d/color=%d)\n",$locked, $locked & 7, ($locked>>3) & 3); 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 $this_non_scaled = $g_raw_ul [$a ++]; // / 0 for non-scaled
printf ("this_non_scaled=%d\n",$this_non_scaled); printf ( "this_non_scaled=%d\n", $this_non_scaled );
if ($page==0) { if ($page == 0) {
printf ("oldest_non_scaled=%d\n",$g_raw_ul[$a++]); printf ( "oldest_non_scaled=%d\n", $g_raw_ul [$a ++] );
printf ("newest_non_scaled=%d\n",$g_raw_ul[$a++]); printf ( "newest_non_scaled=%d\n", $g_raw_ul [$a ++] );
} else { } else {
printf ("newer_non_scaled=%d\n",$g_raw_ul[$a++]); printf ( "newer_non_scaled=%d\n", $g_raw_ul [$a ++] );
printf ("older_non_scaled=%d\n",$g_raw_ul[$a++]); printf ( "older_non_scaled=%d\n", $g_raw_ul [$a ++] );
} }
if ($page==0) { if ($page == 0) {
printf ("oldest_all=%d\n",$g_raw_ul[$a++]); printf ( "oldest_all=%d\n", $g_raw_ul [$a ++] );
printf ("newest_all=%d\n",$g_raw_ul[$a++]); printf ( "newest_all=%d\n", $g_raw_ul [$a ++] );
} else { } else {
printf ("newer_all=%d\n",$g_raw_ul[$a++]); printf ( "newer_all=%d\n", $g_raw_ul [$a ++] );
printf ("older_all=%d\n",$g_raw_ul[$a++]); printf ( "older_all=%d\n", $g_raw_ul [$a ++] );
} }
if ($page==0) { if ($page == 0) {
printf ("non_scaled_length=%d\n",$g_raw_ul[$a++]); /// current number of different hash values 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) printf ( "num_locked=%d\n", $g_raw_ul [$a ++] ); // / number of nodes locked (until table sent to FPGA)
} else if ($this_non_scaled==0){ } else if ($this_non_scaled == 0) {
printf ("oldest_scaled=%d\n",$g_raw_ul[$a++]); printf ( "oldest_scaled=%d\n", $g_raw_ul [$a ++] );
printf ("newest_scaled=%d\n",$g_raw_ul[$a++]); printf ( "newest_scaled=%d\n", $g_raw_ul [$a ++] );
} else { } else {
printf ("newer_scaled=%d\n",$g_raw_ul[$a++]); printf ( "newer_scaled=%d\n", $g_raw_ul [$a ++] );
printf ("older_scaled=%d\n",$g_raw_ul[$a++]); printf ( "older_scaled=%d\n", $g_raw_ul [$a ++] );
} }
///data tables // /data tables
if ($page==0) { if ($page == 0) {
printf ("\nTable of locked indexes\n"); printf ( "\nTable of locked indexes\n" );
for ($color=0;$color<4; $color++) { for($color = 0; $color < 4; $color ++) {
// for ($frame=0;$frame<8; $frame++) { // for ($frame=0;$frame<8; $frame++) {
printf (" %4d",$g_raw_ul[$a++]); printf ( " %4d", $g_raw_ul [$a ++] );
// } // }
// printf ("\n"); // printf ("\n");
} }
printf ("\n"); printf ( "\n" );
/// no need to dump the rest - it is unused in the page 0 // / no need to dump the rest - it is unused in the page 0
printf ("\n\nUnused area on page 0:"); printf ( "\n\nUnused area on page 0:" );
// for ($i=0; $i<417; $i++) { // for ($i=0; $i<417; $i++) {
for ($i=0; $i<445; $i++) { for($i = 0; $i < 445; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
$d=$g_raw_ul[$a++]; printf ( "\n0x%03x:", $i );
printf (" %08x",$d); $d = $g_raw_ul [$a ++];
printf ( " %08x", $d );
} }
} else { } else {
printf ("\nGamma table (direct):"); printf ( "\nGamma table (direct):" );
for ($i=0; $i<129; $i++) { for($i = 0; $i < 129; $i ++) {
if (($i & 0x07)==0) printf ("\n0x%03x:",$i*2); if (($i & 0x07) == 0)
$d=$g_raw_ul[$a++]; printf ( "\n0x%03x:", $i * 2 );
printf (" %04x %04x",$d & 0xffff, ($d>>16) & 0xffff ); $d = $g_raw_ul [$a ++];
} printf ( " %04x %04x", $d & 0xffff, ($d >> 16) & 0xffff );
printf ("\n\nGamma table (reverse):"); }
for ($i=0; $i<64; $i++) { printf ( "\n\nGamma table (reverse):" );
if (($i & 0x03)==0) printf ("\n0x%03x:",$i*4); for($i = 0; $i < 64; $i ++) {
$d=$g_raw_ul[$a++]; if (($i & 0x03) == 0)
printf (" %02x %02x %02x %02x",$d & 0xff, ($d>>8) & 0xff, ($d>>16) & 0xff, ($d>>24) & 0xff); 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:"); printf ( "\n\nFPGA gamma data:" );
for ($i=0; $i<256; $i++) { for($i = 0; $i < 256; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
$d=$g_raw_ul[$a++]; printf ( "\n0x%03x:", $i );
printf (" %05x",$d); $d = $g_raw_ul [$a ++];
printf ( " %05x", $d );
} }
} }
echo "</pre>\n"; echo "</pre>\n";
} }
/* /*
struct histogram_stuct_t { * struct histogram_stuct_t {
unsigned long frame; /// frame number correspoding to the current histogram * 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) * unsigned long valid; /// bit mask of valid arrays (0 - hist_r, ... ,4-cumul_hist_r, ..., 11 - percentile_b)
/// Direct histograms, loaded from the FPGA * /// Direct histograms, loaded from the FPGA
union { * union {
unsigned long hist[1024] ; /// All 4 histograms * unsigned long hist[1024] ; /// All 4 histograms
struct { * struct {
unsigned long hist_r [256] ; /// Histogram for the red component * 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_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_gb[256] ; /// Histogram for the second green component (in the "blue" line)
unsigned long hist_b [256] ; /// Histogram for blue component * unsigned long hist_b [256] ; /// Histogram for blue component
}; * };
}; * };
/// Direct cumulative histograms, calculated from the loaded from the FPGA * /// Direct cumulative histograms, calculated from the loaded from the FPGA
union { * union {
unsigned long cumul_hist[1024] ; /// All 4 cumulative histograms * unsigned long cumul_hist[1024] ; /// All 4 cumulative histograms
struct { * struct {
unsigned long cumul_hist_r [256] ; /// Cumulative histogram for the red component * 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_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_gb[256] ; /// Cumulative histogram for the second green component (in the "blue" line)
unsigned long cumul_hist_b [256] ; /// Cumulative histogram for blue component * 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) * /// 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, * /// 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, * /// 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/ * /// 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 * /// 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. * /// 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) * /// NOTE: - argument is _output_ value (after gamma-correction), reverse gamma table is needed to relate percentiles to amount of light (proportional to exposure)
union { * union {
unsigned char percentile[1024] ; /// All 4 percentiles * unsigned char percentile[1024] ; /// All 4 percentiles
struct { * struct {
unsigned char percentile_r [256] ; /// percentile for the red component * 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_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_gb[256] ; /// percentile for the second green component (in the "blue" line)
unsigned char percentile_b [256] ; /// percentile for the blue component * unsigned char percentile_b [256] ; /// percentile for the blue component
}; * };
}; * };
}; * };
*
*/ */
function printHistogram($frame) { function printHistogram($frame) {
$colors=array(0=>"R",1=>"G",2=>"GB",3=>"B"); $colors = array (
$h_arr=elphel_histogram_get(0xfff,$frame); 0 => "R",
$a=0; 1 => "G",
$offset2sum=1024+255; /// last in cumulative histogram for the same color 2 => "GB",
3 => "B"
);
$h_arr = elphel_histogram_get ($GLOBALS['sensor_port'], $GLOBALS['$sensor_subchn'], 0xfff, $frame );
$a = 0;
$offset2sum = 1024 + 255; // / last in cumulative histogram for the same color
echo "<pre>\n"; echo "<pre>\n";
for ($color=0;$color<4;$color++) { 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]); 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++) { for($i = 0; $i < 256; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
printf (" %05x",$h_arr[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %05x", $h_arr [$a ++] );
} }
printf ("\n"); printf ( "\n" );
} }
for ($color=0;$color<4;$color++) { for($color = 0; $color < 4; $color ++) {
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]); printf ( "\ncumulative histogram for color #%d %s:", $color, $colors [$color] );
for ($i=0; $i<256; $i++) { for($i = 0; $i < 256; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
printf (" %08x",$h_arr[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %08x", $h_arr [$a ++] );
} }
printf ("\n"); printf ( "\n" );
} }
for ($color=0;$color<4;$color++) { for($color = 0; $color < 4; $color ++) {
printf("\npercentile for color #%d %s:",$color,$colors[$color]); printf ( "\npercentile for color #%d %s:", $color, $colors [$color] );
for ($i=0; $i<256; $i++) { for($i = 0; $i < 256; $i ++) {
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i); if (($i & 0x01f) == 0)
printf (" %02x",$h_arr[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %02x", $h_arr [$a ++] );
} }
printf ("\n"); printf ( "\n" );
} }
echo "</pre>\n"; echo "</pre>\n";
} }
function printRawHistogram($needed, $frame) {
function printRawHistogram($needed,$frame) { $percentile_start = 8232;
$percentile_start=8232; $colors = array (
$colors=array(0=>"R",1=>"G",2=>"GB",3=>"B"); 0 => "R",
$h_raw=elphel_histogram_get_raw($needed,$frame); 1 => "G",
//var_dump() 2 => "GB",
$h_raw_ul=unpack('V*',substr($h_raw,0,$percentile_start)); 3 => "B"
);
$h_raw = elphel_histogram_get_raw ($GLOBALS['sensor_port'], $GLOBALS['$sensor_subchn'], $needed, $frame );
// var_dump()
$h_raw_ul = unpack ( 'V*', substr ( $h_raw, 0, $percentile_start ) );
echo "<pre>\n"; echo "<pre>\n";
$a=1; /// unpack started with index 1 $a = 1; // / unpack started with index 1
$hframe= $h_raw_ul[$a++]; $hframe = $h_raw_ul [$a ++];
$valid= $h_raw_ul[$a++]; $valid = $h_raw_ul [$a ++];
$hash32_r= $h_raw_ul[$a++]; $hash32_r = $h_raw_ul [$a ++];
$hash32_g= $h_raw_ul[$a++]; $hash32_g = $h_raw_ul [$a ++];
$hash32_gb=$h_raw_ul[$a++]; $hash32_gb = $h_raw_ul [$a ++];
$hash32_b= $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 ( "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); 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++) { for($color = 0; $color < 4; $color ++) {
$sum=0; $sum = 0;
for ($i=0; $i<256; $i++) $sum+=$h_raw_ul[$a+$i]; for($i = 0; $i < 256; $i ++)
printf("\nhistogram for color #%d %s sum=%d (0x%x):",$color,$colors[$color],$sum,$sum); $sum += $h_raw_ul [$a + $i];
for ($i=0; $i<256; $i++) { printf ( "\nhistogram for color #%d %s sum=%d (0x%x):", $color, $colors [$color], $sum, $sum );
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); for($i = 0; $i < 256; $i ++) {
$d=$h_raw_ul[$a++]; if (($i & 0x0f) == 0)
printf (" %05x",$d); printf ( "\n0x%03x:", $i );
} $d = $h_raw_ul [$a ++];
printf ("\n"); printf ( " %05x", $d );
} }
for ($color=0;$color<4;$color++) { printf ( "\n" );
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]); }
for ($i=0; $i<256; $i++) { for($color = 0; $color < 4; $color ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); printf ( "\ncumulative histogram for color #%d %s:", $color, $colors [$color] );
$d=$h_raw_ul[$a++]; for($i = 0; $i < 256; $i ++) {
printf (" %08x",$d); if (($i & 0x0f) == 0)
} printf ( "\n0x%03x:", $i );
printf ("\n"); $d = $h_raw_ul [$a ++];
} printf ( " %08x", $d );
for ($color=0;$color<4;$color++) { }
printf("\npercentile for color #%d %s:",$color,$colors[$color]); printf ( "\n" );
for ($i=0; $i<256; $i++) { }
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i); for($color = 0; $color < 4; $color ++) {
printf (" %02x",ord($h_raw[$percentile_start+(256*$color)+$i])); printf ( "\npercentile for color #%d %s:", $color, $colors [$color] );
} for($i = 0; $i < 256; $i ++) {
printf ("\n"); if (($i & 0x01f) == 0)
printf ( "\n0x%03x:", $i );
printf ( " %02x", ord ( $h_raw [$percentile_start + (256 * $color) + $i] ) );
}
printf ( "\n" );
} }
echo "</pre>\n"; echo "</pre>\n";
} }
function printRawFrame($frame) { function printRawFrame($frame) {
$fp_raw=elphel_framepars_get_raw($frame); $fp_raw = elphel_framepars_get_raw ($GLOBALS['sensor_port'], $frame );
$fp_raw_ul=unpack('V*',$fp_raw); $fp_raw_ul = unpack ( 'V*', $fp_raw );
echo "<pre>\n"; echo "<pre>\n";
printf ("\nFrame= %d(%08x)\n",$frame,$frame); printf ( "\nFrame= %d(%08x)\n", $frame, $frame );
$a=1; /// unpack started with index 1 $a = 1; // / unpack started with index 1
echo ".pars:"; echo ".pars:";
for ($i=0; $i<927; $i++) { for($i = 0; $i < 927; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
printf (" %08x:",$fp_raw_ul[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %08x:", $fp_raw_ul [$a ++] );
} }
printf ("\n.functions= %08x:",$fp_raw_ul[$a++]); printf ( "\n.functions= %08x:", $fp_raw_ul [$a ++] );
echo "\n.modsince:"; echo "\n.modsince:";
for ($i=0; $i<31; $i++) { for($i = 0; $i < 31; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
printf (" %08x:",$fp_raw_ul[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %08x:", $fp_raw_ul [$a ++] );
} }
printf ("\n.modsince32= %08x:",$fp_raw_ul[$a++]); printf ( "\n.modsince32= %08x:", $fp_raw_ul [$a ++] );
echo "\n.mod:"; echo "\n.mod:";
for ($i=0; $i<31; $i++) { for($i = 0; $i < 31; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
printf (" %08x:",$fp_raw_ul[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %08x:", $fp_raw_ul [$a ++] );
} }
printf ("\n.mod32= %08x:",$fp_raw_ul[$a++]); printf ( "\n.mod32= %08x:", $fp_raw_ul [$a ++] );
echo "\n.needproc:"; echo "\n.needproc:";
for ($i=0; $i<31; $i++) { for($i = 0; $i < 31; $i ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); if (($i & 0x0f) == 0)
printf (" %08x:",$fp_raw_ul[$a++]); printf ( "\n0x%03x:", $i );
printf ( " %08x:", $fp_raw_ul [$a ++] );
} }
printf ("\n.needproc32= %08x:",$fp_raw_ul[$a++]); printf ( "\n.needproc32= %08x:", $fp_raw_ul [$a ++] );
// var_dump($fp_raw_ul); // var_dump($fp_raw_ul);
echo "</pre>\n"; echo "</pre>\n";
} }
function image_table8() {
function image_table8 (){
global $imgsrv; global $imgsrv;
// $back=6; // $back=6;
// $min_back=1; // $min_back=1;
$back=8; $back = 8;
$min_back=0; $min_back = 0;
printf ("<table>\n"); printf ( "<table>\n" );
$scale="100%"; $scale = "100%";
$row_open=$false; $row_open = $false;
for ($hist=$back;$hist>=$min_back;$hist--) { for($hist = $back; $hist >= $min_back; $hist --) {
if (!(($back-$hist) % 3)) { if (! (($back - $hist) % 3)) {
if ($row_open) printf ("</tr>\n"); if ($row_open)
printf ("<tr>"); printf ( "</tr>\n" );
$row_open=true; printf ( "<tr>" );
} $row_open = true;
$url=$imgsrv; }
for ($i=0;$i<$hist;$i++) $url.='/prev'; $url = $imgsrv;
// $url .= '/img'; for($i = 0; $i < $hist; $i ++)
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'); $url .= '/prev';
} // $url .= '/img';
if ($row_open) printf ("</tr>\n"); 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' );
printf ("</table>\n"); }
if ($row_open)
printf ( "</tr>\n" );
printf ( "</table>\n" );
} }
?> ?>
PYTHONROOT=$(DESTDIR)/usr/local/bin
OWN = -o root -g root
INSTPYTHON = 0755
INSTALL = install
PYTHON_SCRIPTS = tests.py
all:
@echo "make all in python_tests"
install:
@echo "make install in python_tests"
$(INSTALL) $(OWN) -d $(PYTHONROOT)
$(INSTALL) $(OWN) -m $(INSTPYTHON) $(PYTHON_SCRIPTS) $(PYTHONROOT)
clean:
@echo "make clean in src"
#!/usr/bin/env python
from __future__ import division
from __future__ import print_function
import mmap
import struct
import os
import sys
#fp = open("/dev/frameparsall0","w+")
frameparsPaths = ("/dev/frameparsall0","/dev/frameparsall1","/dev/frameparsall2","/dev/frameparsall3")
mmap_size= 85*1024*4 # bytes
ENDIAN="<" # little, ">" for big
FRMT_BYTES={1:'B',2:'H',4:'L',8:'Q'}
def test_mmap (sensor_port = 0, out_path_base="mmap_dump_port"):
with open(out_path_base+str(sensor_port), "w+b") as bf:
with open(frameparsPaths[sensor_port],"w+") as fp:
mm = mmap.mmap(fp.fileno(), mmap_size, offset = 0) # mmap all data
bf.write(mm)
# byte_mode = 4
# data=struct.unpack_from(ENDIAN+FRMT_BYTES[byte_mode],mm, page_offs)
"""
elphel_globals->frameParsAll[port] = (struct framepars_all_t *) mmap(0, sizeof (struct framepars_all_t) , PROT_READ | PROT_WRITE, MAP_SHARED, elphel_globals->fd_fparmsall[port], 0);
/// All parameter data for a sensor port, including future ones and past. Size should be PAGE_SIZE aligned
struct framepars_all_t {
struct framepars_t framePars[PARS_FRAMES=16]; ///< Future frame parameters
struct framepars_t func2call; ///< func2call.pars[] - each parameter has a 32-bit mask of what pgm_function to call - other fields not used
unsigned long globalPars[NUM_GPAR=2048]; ///< parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both R/W
struct framepars_past_t pastPars [PASTPARS_SAVE_ENTRIES= (16 << 7)=2048]; ///< parameters of previously acquired frames
unsigned long multiSensIndex[P_MAX_PAR_ROUNDUP = 1024]; ///< indexes of individual sensor register shadows (first of 3) - now for all parameters, not just sensor ones
unsigned long multiSensRvrsIndex[P_MAX_PAR_ROUNDUP = 1024]; ///< reverse index (to parent) for the multiSensIndex in lower 16 bits, high 16 bits - sensor number
};
struct framepars_t { 1024
unsigned long pars[927]; ///< parameter values (indexed by P_* constants)
unsigned long functions; ///< each bit specifies function to be executed (triggered by some parameters change)
unsigned long modsince[31]; ///< parameters modified after this frame - each bit corresponds to one element in in par[960] (bit 31 is not used)
unsigned long modsince32; ///< parameters modified after this frame super index - non-zero elements in in mod[31] (bit 31 is not used)
unsigned long mod[31]; ///< modified parameters - each bit corresponds to one element in in par[960] (bit 31 is not used)
unsigned long mod32; ///< super index - non-zero elements in in mod[31] (bit 31 is not used)
unsigned long needproc[31]; ///< FIXME: REMOVE parameters "modified and not yet processed" (some do not need any processing)
unsigned long needproc32; ///< FIXME: REMOVE parameters "modified and not yet processed" frame super index - non-zero elements in in mod[31] (bit 31 is not used)
};
0x00000 1024*16 struct framepars_t framePars[PARS_FRAMES=16]; ///< Future frame parameters
0x04000 1024 struct framepars_t func2call; ///< func2call.pars[] - each parameter has a 32-bit mask of what pgm_function to call - other fields not used
0x04400 2048 unsigned long globalPars[NUM_GPAR=2048]; ///< parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both R/W
0x04c00 32*2048 struct framepars_past_t pastPars [PASTPARS_SAVE_ENTRIES= (16 << 7)=2048]; ///< parameters of previously acquired frames
0x14c00 1024 unsigned long multiSensIndex[P_MAX_PAR_ROUNDUP = 1024]; ///< indexes of individual sensor register shadows (first of 3) - now for all parameters, not just sensor ones
0x15000 1024 unsigned long multiSensRvrsIndex[P_MAX_PAR_ROUNDUP = 1024]; ///< reverse index (to parent) for the multiSensIndex in lower 16 bits, high 16 bits - sensor number
0x15400
85*1024*4 for mmap
return mmap.mmap(f.fileno(), self.PAGE_SIZE, offset = page_addr)
with open("/dev/mem", "r+b") as f:
for addr in range (start_addr,end_addr+byte_mode,byte_mode):
page_addr=addr & (~(self.PAGE_SIZE-1))
page_offs=addr-page_addr
mm = self.wrap_mm(f, page_addr)
# if (page_addr>=0x80000000):
# page_addr-= (1<<32)
# mm = mmap.mmap(f.fileno(), self.PAGE_SIZE, offset=page_addr)
data=struct.unpack_from(self.ENDIAN+frmt_bytes[byte_mode],mm, page_offs)
rslt.append(data[0])
for addr in range (start_addr,end_addr+byte_mode,byte_mode):
if (addr == start_addr) or ((addr & print_mask) == 0):
if self.DRY_MODE:
print ("\nsimulated: 0x%08x:"%addr,end="")
else:
print ("\n0x%08x:"%addr,end="")
d=rslt[(addr-start_addr) // byte_mode]
print (data_frmt%(d),end=" ")
print("")
return rslt
mm = self.wrap_mm(f, page_addr)
# if (page_addr>=0x80000000):
# page_addr-= (1<<32)
# mm = mmap.mmap(f.fileno(), self.PAGE_SIZE, offset=page_addr)
bf.write(mm[start_offset:end_offset])
"""
if __name__ == "__main__":
test_mmap(0)
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