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,14 +106,16 @@ ...@@ -106,14 +106,16 @@
*! *!
*/ */
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>
<ul> <ul>
...@@ -145,55 +147,80 @@ function myval ($s) { ...@@ -145,55 +147,80 @@ 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,
"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 if (array_key_exists ( 'sensor_port', $_GET )) {
$sensor_port = (myval($_GET ['sensor_port'])) & 3;
}
if (array_key_exists ( 'sensor_subchn', $_GET )) {
$sensor_port = (myval($_GET ['sensor_subchn'])) & 3;
}
$framepars_path = $framepars_paths[$sensor_port];
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 ($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
<p>reading profile time start=$time_start </p> <p>reading profile time start=$time_start </p>
<p>reading profile time end=$time_end </p> <p>reading profile time end=$time_end </p>
<ol>Profiling interrupt/tasklet execution time in microseconds, starting from the start of the frame <ol>Profiling interrupt/tasklet execution time in microseconds, starting from the start of the frame
...@@ -207,337 +234,351 @@ $time_end=elphel_get_fpga_time(); ...@@ -207,337 +234,351 @@ $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>"); }
//echo "<pre>";print_r($prof_raw);echo"</pre>\n"; printf ( "</table>" );
// echo "<pre>";print_r($prof_raw);echo"</pre>\n";
exit (0);
case "histogram_direct": exit ( 0 );
case "histogram_reverse": case "histogram_direct" :
case "gamma_direct": case "histogram_reverse" :
case "gamma_reverse": case "gamma_direct" :
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>"); case "gamma_reverse" :
$value=floatval($value); $xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
switch($key) { $value = floatval ( $value );
case "histogram_direct": switch ($key) {
$xml->addChild ('histogram_direct_r', elphel_histogram(0,$value)); case "histogram_direct" :
$xml->addChild ('histogram_direct_g', elphel_histogram(1,$value)); $xml->addChild ( 'histogram_direct_r', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('histogram_direct_gb',elphel_histogram(2,$value)); $xml->addChild ( 'histogram_direct_g', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('histogram_direct_b', elphel_histogram(3,$value)); $xml->addChild ( 'histogram_direct_gb', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
break; $xml->addChild ( 'histogram_direct_b', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
case "histogram_reverse": break;
$xml->addChild ('histogram_reverse_r', elphel_reverse_histogram(0,$value)); case "histogram_reverse" :
$xml->addChild ('histogram_reverse_g', elphel_reverse_histogram(1,$value)); $xml->addChild ( 'histogram_reverse_r', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('histogram_reverse_gb',elphel_reverse_histogram(2,$value)); $xml->addChild ( 'histogram_reverse_g', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('histogram_reverse_b', elphel_reverse_histogram(3,$value)); $xml->addChild ( 'histogram_reverse_gb', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
break; $xml->addChild ( 'histogram_reverse_b', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
case "gamma_direct": break;
$xml->addChild ('gamma_direct_r', elphel_gamma(0,$value)); case "gamma_direct" :
$xml->addChild ('gamma_direct_g', elphel_gamma(1,$value)); $xml->addChild ( 'gamma_direct_r', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('gamma_direct_gb',elphel_gamma(2,$value)); $xml->addChild ( 'gamma_direct_g', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('gamma_direct_b', elphel_gamma(3,$value)); $xml->addChild ( 'gamma_direct_gb', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
break; $xml->addChild ( 'gamma_direct_b', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
case "gamma_reverse": break;
$xml->addChild ('gamma_reverse_r', elphel_reverse_gamma(0,$value)); case "gamma_reverse" :
$xml->addChild ('gamma_reverse_g', elphel_reverse_gamma(1,$value)); $xml->addChild ( 'gamma_reverse_r', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ('gamma_reverse_gb',elphel_reverse_gamma(2,$value)); $xml->addChild ( 'gamma_reverse_g', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ('gamma_reverse_b', elphel_reverse_gamma(3,$value)); $xml->addChild ( 'gamma_reverse_gb', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
break; $xml->addChild ( 'gamma_reverse_b', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
} break;
$rslt=$xml->asXML(); }
header("Content-Type: text/xml"); $rslt = $xml->asXML ();
header("Content-Length: ".strlen($rslt)."\n"); header ( "Content-Type: text/xml" );
header("Pragma: no-cache\n"); header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
printf($rslt); header ( "Pragma: no-cache\n" );
exit (0); printf ( $rslt );
case "cmd": exit ( 0 );
case "seek": case "cmd" :
case "fseek": case "seek" :
case "lseek": case "fseek" :
$xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>"); case "lseek" :
if (!$value) { $xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
$xml->addChild ('frame',elphel_get_frame()); if (! $value) {
$xml->addChild ('frame8',elphel_fpga_read(0x16) & 7); $xml->addChild ( 'frame', elphel_get_frame ($GLOBALS['sensor_port']) );
} else if ($value=="time"){ // $xml->addChild ( 'frame8', elphel_fpga_read ( 0x16 ) & 7 );
$xml->addChild ('fpga_time',elphel_get_fpga_time()); } else if ($value == "time") {
} else if ($value=="irqoff"){ $xml->addChild ( 'fpga_time', elphel_get_fpga_time ($GLOBALS['sensor_port']) );
$framepars_file=fopen("/dev/frameparsall","r"); } else if ($value == "irqoff") {
$xml->addChild ('irqoff_result',fseek($framepars_file,ELPHEL_LSEEK_INTERRUPT_OFF,SEEK_END)); //#define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts $framepars_file = fopen ( $framepars_path, "r" );
fclose($framepars_file); $xml->addChild ( 'irqoff_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_OFF, SEEK_END ) ); // #define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts
} else if ($value=="irqon"){ fclose ( $framepars_file );
/// wait for frame8=0 } else if ($value == "irqon") {
while (elphel_fpga_read(0x16) & 7) usleep (1000); /// Maybe needed to wait for 7, then 0? // / wait for frame8=0
$framepars_file=fopen("/dev/frameparsall","r"); // while ( elphel_fpga_read ( 0x16 ) & 7 )
$xml->addChild ('irqon_result',fseek($framepars_file,ELPHEL_LSEEK_INTERRUPT_ON,SEEK_END)); //#define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts // usleep ( 1000 ); // / Maybe needed to wait for 7, then 0?
fclose($framepars_file); $framepars_file = fopen ( $framepars_path, "r" );
} else if ($value=="init"){ $xml->addChild ( 'irqon_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
$framepars_file=fopen("/dev/frameparsall","r"); fclose ( $framepars_file );
$xml->addChild ('LSEEK_FRAMEPARS_INIT',fseek($framepars_file,ELPHEL_LSEEK_FRAMEPARS_INIT,SEEK_END)); } else if ($value == "init") {
$xml->addChild ('elphel_set_P_value', elphel_set_P_value(ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC));/// will start detection $framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ('LSEEK_SENSORPROC', fseek($framepars_file,ELPHEL_LSEEK_SENSORPROC, SEEK_END)); $xml->addChild ( 'LSEEK_FRAMEPARS_INIT', fseek ( $framepars_file, ELPHEL_LSEEK_FRAMEPARS_INIT, SEEK_END ) );
$frame=0; $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
// gets half-frame $xml->addChild ( 'LSEEK_SENSORPROC', fseek ( $framepars_file, ELPHEL_LSEEK_SENSORPROC, SEEK_END ) );
$frame = 0;
elphel_set_P_value(ELPHEL_MAXAHEAD, 2, 0, 8); /// When servicing interrupts, try programming up to 2 frames ahead of due time) // gets half-frame
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_MAXAHEAD, 2, 0, 8 ); // / When servicing interrupts, try programming up to 2 frames ahead of due time)
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_FPGA_XTRA, 1000, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // /compressor needs extra 1000 cycles to compress a frame (estimate)
/// good (latency should be changed, but for now that will make a correct initialization - maybe obsolete) elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_EXTERN_TIMESTAMP, 1, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / only used with async trigger
elphel_set_P_value(ELPHEL_BITS, 8, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); // / good (latency should be changed, but for now that will make a correct initialization - maybe obsolete)
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 ($GLOBALS['sensor_port'], ELPHEL_BITS, 8, $frame + 3, 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_QUALITY, 80, $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, 1, $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_COLOR_SATURATION_BLUE, 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 ($GLOBALS['sensor_port'], ELPHEL_COLOR_SATURATION_RED, 200, $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_BAYER, 0, $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 ($GLOBALS['sensor_port'], 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); fclose ( $framepars_file );
elphel_set_P_value(ELPHEL_COLOR, 1, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $gamma = 57;
elphel_set_P_value(ELPHEL_COLOR_SATURATION_BLUE,200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $black = 10;
elphel_set_P_value(ELPHEL_COLOR_SATURATION_RED, 200, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $scale_r = ( int ) (1.0 * 1024);
elphel_set_P_value(ELPHEL_SENSOR_RUN, 2, $frame+3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); $scale_g = ( int ) (0.9 * 1024);
*/ $scale_b = ( int ) (1.1 * 1024);
$scale_gb = ( int ) (0.9 * 1024);
fclose($framepars_file); 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.
} else if ($value=="gamma1"){ // 16Msbs are also "hash16" and do not need to be black level/gamma, just uniqualy identify the table for applications
*/ $gamma_pars = array (
$gamma=57; "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
$black=10; "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
$scale_r= (int) (1.0 * 1024); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$scale_g= (int) (0.9 * 1024); "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
$scale_b= (int) (1.1 * 1024); );
$scale_gb=(int) (0.9 * 1024); $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
elphel_gamma_add (0.01*$gamma, $black); elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
#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. } else if ($value == "gamma57") {
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniqualy identify the table for applications $gamma = 57;
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff), $black = 10;
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), $scale_r = ( int ) (1.0 * 1024);
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), $scale_g = ( int ) (1.0 * 1024);
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); $scale_b = ( int ) (1.0 * 1024);
$frame=elphel_get_frame(); //0 $scale_gb = ( int ) (1.0 * 1024);
elphel_set_P_arr ($gamma_pars, $frame+3,0); elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
} else if ($value=="gamma57"){ // 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.
$gamma=57; // 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications
$black=10; $gamma_pars = array (
$scale_r= (int) (1.0 * 1024); "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
$scale_g= (int) (1.0 * 1024); "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
$scale_b= (int) (1.0 * 1024); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$scale_gb=(int) (1.0 * 1024); "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
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. $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff), } else if ($value == "gamma") {
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), $gamma = 60;
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), $black = 10;
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); $scale_r = ( int ) (1.0 * 1024);
$frame=elphel_get_frame(); //0 $scale_g = ( int ) (0.9 * 1024);
elphel_set_P_arr ($gamma_pars, $frame+3,0); $scale_b = ( int ) (1.1 * 1024);
} else if ($value=="gamma"){ $scale_gb = ( int ) (0.9 * 1024);
$gamma=60; elphel_gamma_add ( 0.01 * $gamma, $black );
$black=10; // 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_r= (int) (1.0 * 1024); // 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications
$scale_g= (int) (0.9 * 1024); $gamma_pars = array (
$scale_b= (int) (1.1 * 1024); "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
$scale_gb=(int) (0.9 * 1024); "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
elphel_gamma_add (0.01*$gamma, $black); "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
#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. "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
// 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), $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), } else if ($value == "linear") {
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); $gamma = 100;
$frame=elphel_get_frame(); //0 $black = 0;
elphel_set_P_arr ($gamma_pars, $frame+3,0); $scale_r = ( int ) (1.0 * 1024);
} else if ($value=="linear"){ $scale_g = ( int ) (1.0 * 1024);
$gamma=100; $scale_b = ( int ) (1.0 * 1024);
$black=0; $scale_gb = ( int ) (1.0 * 1024);
$scale_r= (int) (1.0 * 1024); elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
$scale_g= (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_b= (int) (1.0 * 1024); // 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications
$scale_gb=(int) (1.0 * 1024); $gamma_pars = array (
elphel_gamma_add (0.01*$gamma, $black); "GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
#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. "GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniquely identify the table for applications "GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
$gamma_pars=array("GTAB_R" => ($black<<24) | ($gamma << 16) | ($scale_r & 0xffff), "GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
"GTAB_G" => ($black<<24) | ($gamma << 16) | ($scale_g & 0xffff), );
"GTAB_B" => ($black<<24) | ($gamma << 16) | ($scale_b & 0xffff), $frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
"GTAB_GB" => ($black<<24) | ($gamma << 16) | ($scale_gb & 0xffff)); elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
$frame=elphel_get_frame(); //0 } else if ($value == "initgamma") {
elphel_set_P_arr ($gamma_pars, $frame+3,0); $gammas_file = fopen ( "/dev/gamma_cache", "r" );
} else if ($value=="initgamma"){ $xml->addChild ( 'LSEEK_GAMMA_INIT', fseek ( $gammas_file, ELPHEL_LSEEK_GAMMA_INIT, SEEK_END ) );
$gammas_file=fopen("/dev/gamma_cache","r"); fclose ( $gammas_file );
$xml->addChild ('LSEEK_GAMMA_INIT',fseek($gammas_file,ELPHEL_LSEEK_GAMMA_INIT,SEEK_END)); } else if ($value == "jpegheader") {
fclose($gammas_file); $circbuf_file = fopen ( "/dev/circbuf", "r" );
} else if ($value=="jpegheader"){ fseek ( $circbuf_file, ELPHEL_LSEEK_CIRC_LAST, SEEK_END );
$circbuf_file=fopen("/dev/circbuf","r"); $jpeg_start = ftell ( $circbuf_file );
fseek($circbuf_file,ELPHEL_LSEEK_CIRC_LAST,SEEK_END); $xml->addChild ( 'circbuf_pointer', sprintf ( "0x%x (0x%x)", $jpeg_start, $jpeg_start >> 2 ) );
$jpeg_start=ftell($circbuf_file); fclose ( $circbuf_file );
$xml->addChild ('circbuf_pointer',sprintf("0x%x (0x%x)",$jpeg_start,$jpeg_start>>2)); $header_file = fopen ( "/dev/jpeghead", "r" );
fclose($circbuf_file); // / Now select right frame (different frames may have different header sizes)
$header_file=fopen("/dev/jpeghead","r"); fseek ( $header_file, $jpeg_start + 1, SEEK_END ); // / selects frame, creates header
/// Now select right frame (different frames may have different header sizes) fseek ( $header_file, 0, SEEK_END ); // / positions to the end
fseek($header_file,$jpeg_start+1,SEEK_END); /// selects frame, creates header $header_size = ftell ( $header_file ); // /
fseek($header_file,0,SEEK_END); /// positions to the end $xml->addChild ( 'header_size', $header_size );
$header_size=ftell($header_file); /// fseek ( $header_file, 0, SEEK_SET ); // / positions to the beginning
$xml->addChild ('header_size',$header_size); $header = fread ( $header_file, 8192 );
fseek($header_file,0,SEEK_SET); /// positions to the beginning $xml->addChild ( 'header_read_length', strlen ( $header ) );
$header=fread ($header_file,8192); fclose ( $header_file );
$xml->addChild ('header_read_length',strlen($header)); $aheader = unpack ( 'C*', $header );
fclose($header_file); for($i = 0; $i < count ( $aheader ); $i += 16) {
$aheader=unpack('C*',$header); $d = "";
for ($i=0; $i<count($aheader) ;$i+=16){ for($j = $i; ($j < $i + 16) && ($j < count ( $aheader )); $j ++)
$d=""; $d .= sprintf ( " %02x", $aheader [$j + 1] );
for ($j=$i; ($j<$i+16) && ($j<count($aheader)); $j++) $d.=sprintf(" %02x",$aheader[$j+1]); $xml->addChild ( sprintf ( 'header%03x', $i ), $d );
$xml->addChild (sprintf('header%03x',$i),$d); }
} } else if ($value == "reset") {
} else if ($value=="reset"){ $framepars_file = fopen ( $framepars_path, "r" );
$framepars_file=fopen("/dev/frameparsall","r"); $xml->addChild ( 'LSEEK_DMA_STOP', fseek ( $framepars_file, ELPHEL_LSEEK_DMA_STOP, SEEK_END ) );
$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_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 ) );
$xml->addChild ('LSEEK_COMPRESSOR_RESET', fseek($framepars_file,ELPHEL_LSEEK_COMPRESSOR_RESET,SEEK_END)); fclose ( $framepars_file );
fclose($framepars_file); } else if ($value == "constants") {
} 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 ( $framepars_path, "r" );
$framepars_file=fopen("/dev/frameparsall","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 ();
header ( "Content-Type: text/xml" );
$rslt=$xml->asXML(); header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
header("Content-Type: text/xml"); header ( "Pragma: no-cache\n" );
header("Content-Length: ".strlen($rslt)."\n"); printf ( $rslt );
header("Pragma: no-cache\n"); exit ( 0 );
printf($rslt); case "a" : // / Make it recognize P_* constants?
exit (0); case "adr" :
case "a": /// Make it recognize P_* constants? case "na" : // / add flag "new"
case "adr": case "sa" : // / add flag "static"
case "na": /// add flag "new" $address = myval ( $value );
case "sa": /// add flag "static" if (($address == 0) && (strlen ( $value ) > 3)) { // suspect constant
$address=myval ($value); $address = $elp_const ["ELPHEL_" . $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)
switch ($key){ $address |= ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC;
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;
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 ($GLOBALS['sensor_port']);
$current_frame=elphel_get_frame(); switch ($value) {
switch ($value) { case "this" :
case "this": $frame=$current_frame; $frame = $current_frame;
break; break;
case "next": $frame=$current_frame+1; case "next" :
break; $frame = $current_frame + 1;
case "next2": $frame=$current_frame+2; break;
break; case "next2" :
case "next3": $frame=$current_frame+3; $frame = $current_frame + 2;
break; break;
case "next4": $frame=$current_frame+4; case "next3" :
break; $frame = $current_frame + 3;
case "next5": $frame=$current_frame+5; break;
break; case "next4" :
case "next6": $frame=$current_frame+6; $frame = $current_frame + 4;
break; break;
break; case "next5" :
case "prev": $frame=$current_frame-1; $frame = $current_frame + 5;
break; break;
case "prev2": $frame=$current_frame-2; case "next6" :
break; $frame = $current_frame + 6;
case "prev3": $frame=$current_frame-3; break;
break; break;
case "prev4": $frame=$current_frame-4; case "prev" :
break; $frame = $current_frame - 1;
case "prev5": $frame=$current_frame-5; break;
break; case "prev2" :
case "prev6": $frame=$current_frame-6; $frame = $current_frame - 2;
break; break;
default: case "prev3" :
$frame=myval ($value); $frame = $current_frame - 3;
} break;
break; case "prev4" :
case "flags": /// simple flags - "z(ero)"/"(s(tatic), "n(new)",+ constants $frame = $current_frame - 4;
case "flag": break;
switch ($value) { case "prev5" :
case "z": $frame = $current_frame - 5;
case "zero": break;
case "s": case "prev6" :
case "static": $frame = $current_frame - 6;
$flags=ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO; break;
break; default :
case "n": $frame = myval ( $value );
case "new": }
$flags=ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC; break;
break; case "flags" : // / simple flags - "z(ero)"/"(s(tatic), "n(new)",+ constants
default: case "flag" :
$flags=myval ($value); switch ($value) {
} case "z" :
break; case "zero" :
case "t": case "s" :
case "test": case "static" :
$test=myval ($value); $flags = ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO;
break; break;
case "gamma": case "n" :
case "gamma_page": case "new" :
$gamma_page=myval ($value); $flags = ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC;
break; break;
case "gamma_structure": default :
/// later add value - list of pages to process $flags = myval ( $value );
printGammaStructure(); }
/* echo "<pre>\n"; break;
var_dump(getGammaStructure()); case "t" :
echo "</pre>\n";*/ case "test" :
exit (0); $test = myval ( $value );
} break;
} case "gamma" :
if ($address==="") { case "gamma_page" :
if ($frame==="") { $gamma_page = myval ( $value );
if ($gamma_page==="") { break;
echo <<<USAGE 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> <p>read/fwrite frame parameters, execute commands</p>
<ul> <ul>
<li><b>framepars.php?cmd=<i>command number</i></b> - execute <i>register_address</i></li> <li><b>framepars.php?cmd=<i>command number</i></b> - execute <i>register_address</i></li>
...@@ -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 === '')
if ($frame==='') $data=elphel_get_P_value($address); $data = elphel_get_P_value ($GLOBALS['sensor_port'], $address );
else $data=elphel_get_P_value($address, $frame); else
$xml->addChild ('read',$data); $data = elphel_get_P_value ($GLOBALS['sensor_port'], $address, $frame );
$xml->addChild ('hex_read',sprintf("0x%x",$data)); $xml->addChild ( 'read', $data );
} else { $xml->addChild ( 'hex_read', sprintf ( "0x%x", $data ) );
if (($frame==='') && flags) $frame =0; } else {
$xml->addChild ('frame_was',$frame); if (($frame === '') && flags)
///*************************************************************************** $frame = 0;
if ($test>0) { $xml->addChild ( 'frame_was', $frame );
ob_flush(); flush(); // /***************************************************************************
if ($test > 0) {
elphel_set_P_value(ELPHEL_COMPRESSOR_RUN | ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC, ELPHEL_CONST_COMPRESSOR_RUN_CONT, $current_frame+2); ob_flush ();
$frame+=2; flush ();
$current_frame+=2;
elphel_skip_frames(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;
if ($frame==='') elphel_set_P_value($address, $data); $current_frame += 2;
else elphel_set_P_value($address, $data, $frame, $flags); elphel_skip_frames ($GLOBALS['sensor_port'], 2 );
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); if ($frame === '')
ob_flush(); flush(); ///OK here elphel_set_P_value ($GLOBALS['sensor_port'], $address, $data );
$circbuf_file=fopen("/dev/circbuf","r"); else
$current_frame=$frame; elphel_set_P_value ($GLOBALS['sensor_port'], $address, $data, $frame, $flags );
printf ("<p>frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush(); if ($test > 0) {
elphel_skip_frames(2); 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 );
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(); ob_flush ();
// printf ("<p>start_frame2=0x%x</p>\n",$current_frame); flush (); // /OK here
$circbuf_file = fopen ( "/dev/circbuf", "r" );
elphel_set_P_value(ELPHEL_COMPRESSOR_RUN | ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC, ELPHEL_CONST_COMPRESSOR_RUN_STOP, $current_frame+4); $current_frame = $frame;
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); elphel_skip_frames ($GLOBALS['sensor_port'], 2 );
printf ("<p>skipped 1 frame - frame=%d (0x%x), time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush(); 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 ();
// elphel_skip_frames(6); flush ();
// printf ("<p>after skip 6 frames - frame=0x%x, time=%d </p>\n",elphel_get_frame(),time()); ob_flush(); flush(); // printf ("<p>start_frame2=0x%x</p>\n",$current_frame);
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END);
///stuck before here? 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 () );
elphel_skip_frames(1); ob_flush ();
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); flush ();
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?
elphel_skip_frames(1); for($i = 0; $i < 6; $i ++) {
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
printf ("<p>frame=%d (0x%x) time=%d </p>\n",elphel_get_frame(),elphel_get_frame(),time()); ob_flush(); flush(); 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 () );
elphel_skip_frames(1); ob_flush ();
fseek($circbuf_file,LSEEK_CIRC_TOWP,SEEK_END); flush ();
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);
/// Strange - frame normal delay sometimes wrong images in the // printf ("<p>after skip 6 frames - frame=0x%x, time=%d </p>\n",elphel_get_frame($GLOBALS['sensor_port']),time()); ob_flush(); flush();
// printf ("<p>end_frame2=0x%x</p>\n",elphel_get_frame()); fseek ( $circbuf_file, LSEEK_CIRC_TOWP, SEEK_END );
fclose($circbuf_file); // /stuck before here?
printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
image_table8 (); ob_flush ();
exit (0); flush ();
$xml->addChild ('test',$test); elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
} fseek ( $circbuf_file, LSEEK_CIRC_TOWP, SEEK_END );
$xml->addChild ('frame',$frame); printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
$xml->addChild ('written',$data); ob_flush ();
$xml->addChild ('hex_written',sprintf("0x%x",$data)); flush ();
$xml->addChild ('flags',sprintf("0x%x",$flags)); elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
} fseek ( $circbuf_file, LSEEK_CIRC_TOWP, SEEK_END );
$rslt=$xml->asXML(); printf ( "<p>frame=%d (0x%x) time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
header("Content-Type: text/xml"); ob_flush ();
header("Content-Length: ".strlen($rslt)."\n"); flush ();
header("Pragma: no-cache\n"); elphel_skip_frames ($GLOBALS['sensor_port'], 1 );
printf($rslt); fseek ( $circbuf_file, LSEEK_CIRC_TOWP, SEEK_END );
exit (0); 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
// printf ("<p>end_frame2=0x%x</p>\n",elphel_get_frame($GLOBALS['sensor_port']));
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() { 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" printf ( "<table \"border=1\">\n" );
."<tr><td>non_scaled_length</td><td><b>%d</b></td></tr>\n" // printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["index"]);printf("</tr>\n");
."<tr><td>num_locked</td><td><b>%d</b></td></tr>\n" printf ( "<tr><td>index </td>\n" );
."<tr><td>locked_col 0</td><td><b>%d</b></td>\n" foreach ( $gammaStructure ["entries"] as $entry )
."<tr><td>locked_col 1</td><td><b>%d</b></td>\n" printf ( "<td><a href='?gamma_page=%d'><b>%d</b></a></td>", $entry ["index"], $entry ["index"] );
."<tr><td>locked_col 2</td><td><b>%d</b></td>\n" printf ( "</tr>\n" );
."<tr><td>locked_col 3</td><td><b>%d</b></td>\n"
."</table>\n", printf ( "<tr><td>hash32 </td>\n" );
$gammaStructure["oldest_non_scaled"], foreach ( $gammaStructure ["entries"] as $entry )
$gammaStructure["newest_non_scaled"], printf ( "<td><b>%08x</b></td>", $entry ["hash32"] );
$gammaStructure["oldest_all"], printf ( "</tr>\n" );
$gammaStructure["newest_all"], printf ( "<tr><td>scale </td>\n" );
$gammaStructure["non_scaled_length"], foreach ( $gammaStructure ["entries"] as $entry )
$gammaStructure["num_locked"], printf ( "<td><b>%01.3f</b></td>", $entry ["scale"] );
$gammaStructure["locked_col"][0], printf ( "</tr>\n" );
$gammaStructure["locked_col"][1], printf ( "<tr><td>gamma </td>\n" );
$gammaStructure["locked_col"][2], foreach ( $gammaStructure ["entries"] as $entry )
$gammaStructure["locked_col"][3] printf ( "<td><b>%01.3f</b></td>", $entry ["gamma"] );
); printf ( "</tr>\n" );
printf("<br/><br/>\n"); printf ( "<tr><td>black </td>\n" );
foreach ( $gammaStructure ["entries"] as $entry )
printf("<table \"border=1\">\n"); printf ( "<td><b>%d</b></td>", $entry ["black"] );
// printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["index"]);printf("</tr>\n"); printf ( "</tr>\n" );
printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ( "<tr><td>valid </td>\n" );
printf ("<td><a href='?gamma_page=%d'><b>%d</b></a></td>",$entry["index"],$entry["index"]);printf("</tr>\n"); foreach ( $gammaStructure ["entries"] as $entry )
printf ( "<td><b>0x%x</b></td>", $entry ["valid"] );
printf("<tr><td>hash32 </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%08x</b></td>",$entry["hash32"]);printf("</tr>\n"); 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>locked </td>\n" );
printf("<tr><td>gamma </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["gamma"]);printf("</tr>\n"); foreach ( $gammaStructure ["entries"] as $entry )
printf("<tr><td>black </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["black"]);printf("</tr>\n"); printf ( "<td><b>0x%8x</b></td>", $entry ["locked"] );
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>\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" );
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"); foreach ( $gammaStructure ["entries"] as $entry )
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 ( "<td><b>%d</b></td>", $entry ["this_non_scaled"] );
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>\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>newer_non_scaled</td>\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"); foreach ( $gammaStructure ["entries"] as $entry )
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 ( "<td><b>%d</b></td>", $entry ["newer_non_scaled"] );
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>\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_non_scaled</td>\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"); foreach ( $gammaStructure ["entries"] as $entry )
printf("</table>\n"); 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 ++) {
"index" => $i, $g_raw = elphel_gamma_get_raw ( $i ); // Does not depend on $GLOBALS['sensor_port']
"hash32"=> $hash32, $g_raw_ul = unpack ( 'V*', $g_raw );
"scale" => ($hash32 & 0xffff)/1024.0, if ($g_raw_ul [4] >= 0) { // / >=0 if ever used. This field seems to do nothing in the code.
"gamma" => (($hash32 >> 16) & 0xff)/100.0, $hash32 = $g_raw_ul [1];
"black" => (($hash32 >> 24) & 0xff), $gammaStructure ["entries"] [$i] = array (
"valid" => $g_raw_ul[ 2], /// 0 - table invalid, 1 - table valid +2 for table locked (until sent to FPGA) "index" => $i,
"locked" => $g_raw_ul[ 3], /// bit frame+ (color<<3) locked for color/frame "hash32" => $hash32,
"this_non_scaled" => $g_raw_ul[ 4], /// 0 for non-scaled, others - (for scaled) - pointer to the corresponding non-scaled "scale" => ($hash32 & 0xffff) / 1024.0,
/// This is non-scaled (gamma data is full 16-bit) "gamma" => (($hash32 >> 16) & 0xff) / 100.0,
"newer_non_scaled" => $g_raw_ul[ 5], /// table type (non-scaled prototype) used later than this one "black" => (($hash32 >> 24) & 0xff),
"older_non_scaled" => $g_raw_ul[ 6], /// table type (non-scaled prototype) used before this one "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
"newer_all" => $g_raw_ul[ 7], /// newer in a single chain of all scaled tables, regardless of the prototype "this_non_scaled" => $g_raw_ul [4], // / 0 for non-scaled, others - (for scaled) - pointer to the corresponding non-scaled
"older_all" => $g_raw_ul[ 8], /// older in a single chain of all scaled tables, regardless of the prototype // / This is non-scaled (gamma data is full 16-bit)
///Next two pairs are the same (union) "newer_non_scaled" => $g_raw_ul [5], // / table type (non-scaled prototype) used later than this one
"oldest_scaled" => $g_raw_ul[ 9], /// oldest derivative of this prototype (scaled) "older_non_scaled" => $g_raw_ul [6], // / table type (non-scaled prototype) used before this one
"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_all" => $g_raw_ul [7], // / newer in a single chain of all scaled tables, regardless of the prototype
"older_scaled" => $g_raw_ul[10] /// table type (non-scaled prototype) used before this one "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)
return $gammaStructure; "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
function printRawGamma($page=0) { ;
$g_raw=elphel_gamma_get_raw($page); }
//var_dump() }
$g_raw_ul=unpack('V*',$g_raw); return $gammaStructure;
echo "<pre>\n"; }
printf ("Gamma cache page %d, length=%d\n",$page, strlen($g_raw)); function printRawGamma($page = 0) {
$a=1; /// unpack started with index 1 $g_raw = elphel_gamma_get_raw ( $page ); // Does not depend on $GLOBALS['sensor_port']
$hash32= $g_raw_ul[$a++]; // var_dump()
$scale= ($hash32 & 0xffff)/1024.0; $g_raw_ul = unpack ( 'V*', $g_raw );
$gamma= (($hash32 >> 16) & 0xff)/100.0; echo "<pre>\n";
$black= (($hash32 >> 24) & 0xff); printf ( "Gamma cache page %d, length=%d\n", $page, strlen ( $g_raw ) );
printf ("hash32= %08x (scale=%f gamma=%f black=%d)\n",$hash32,$scale,$gamma,$black); $a = 1; // / unpack started with index 1
$valid= $g_raw_ul[$a++]; $hash32 = $g_raw_ul [$a ++];
printf ("valid=%d, locked=%d\n",$valid & 1, $valid & 2); $scale = ($hash32 & 0xffff) / 1024.0;
$gamma = (($hash32 >> 16) & 0xff) / 100.0;
$locked= $g_raw_ul[$a++]; $black = (($hash32 >> 24) & 0xff);
printf ("locked= 0x%x (for frame=%d/color=%d)\n",$locked, $locked & 7, ($locked>>3) & 3); printf ( "hash32= %08x (scale=%f gamma=%f black=%d)\n", $hash32, $scale, $gamma, $black );
$valid = $g_raw_ul [$a ++];
$this_non_scaled=$g_raw_ul[$a++]; /// 0 for non-scaled printf ( "valid=%d, locked=%d\n", $valid & 1, $valid & 2 );
printf ("this_non_scaled=%d\n",$this_non_scaled);
if ($page==0) { $locked = $g_raw_ul [$a ++];
printf ("oldest_non_scaled=%d\n",$g_raw_ul[$a++]); printf ( "locked= 0x%x (for frame=%d/color=%d)\n", $locked, $locked & 7, ($locked >> 3) & 3 );
printf ("newest_non_scaled=%d\n",$g_raw_ul[$a++]);
} else { $this_non_scaled = $g_raw_ul [$a ++]; // / 0 for non-scaled
printf ("newer_non_scaled=%d\n",$g_raw_ul[$a++]); printf ( "this_non_scaled=%d\n", $this_non_scaled );
printf ("older_non_scaled=%d\n",$g_raw_ul[$a++]); if ($page == 0) {
} printf ( "oldest_non_scaled=%d\n", $g_raw_ul [$a ++] );
printf ( "newest_non_scaled=%d\n", $g_raw_ul [$a ++] );
if ($page==0) { } else {
printf ("oldest_all=%d\n",$g_raw_ul[$a++]); printf ( "newer_non_scaled=%d\n", $g_raw_ul [$a ++] );
printf ("newest_all=%d\n",$g_raw_ul[$a++]); printf ( "older_non_scaled=%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 ( "oldest_all=%d\n", $g_raw_ul [$a ++] );
printf ( "newest_all=%d\n", $g_raw_ul [$a ++] );
if ($page==0) { } else {
printf ("non_scaled_length=%d\n",$g_raw_ul[$a++]); /// current number of different hash values printf ( "newer_all=%d\n", $g_raw_ul [$a ++] );
printf ("num_locked=%d\n",$g_raw_ul[$a++]); /// number of nodes locked (until table sent to FPGA) printf ( "older_all=%d\n", $g_raw_ul [$a ++] );
} else if ($this_non_scaled==0){ }
printf ("oldest_scaled=%d\n",$g_raw_ul[$a++]);
printf ("newest_scaled=%d\n",$g_raw_ul[$a++]); if ($page == 0) {
} else { printf ( "non_scaled_length=%d\n", $g_raw_ul [$a ++] ); // / current number of different hash values
printf ("newer_scaled=%d\n",$g_raw_ul[$a++]); printf ( "num_locked=%d\n", $g_raw_ul [$a ++] ); // / number of nodes locked (until table sent to FPGA)
printf ("older_scaled=%d\n",$g_raw_ul[$a++]); } else if ($this_non_scaled == 0) {
} printf ( "oldest_scaled=%d\n", $g_raw_ul [$a ++] );
///data tables printf ( "newest_scaled=%d\n", $g_raw_ul [$a ++] );
if ($page==0) { } else {
printf ("\nTable of locked indexes\n"); printf ( "newer_scaled=%d\n", $g_raw_ul [$a ++] );
for ($color=0;$color<4; $color++) { printf ( "older_scaled=%d\n", $g_raw_ul [$a ++] );
// for ($frame=0;$frame<8; $frame++) { }
printf (" %4d",$g_raw_ul[$a++]); // /data tables
// } if ($page == 0) {
// printf ("\n"); printf ( "\nTable of locked indexes\n" );
} for($color = 0; $color < 4; $color ++) {
printf ("\n"); // for ($frame=0;$frame<8; $frame++) {
/// no need to dump the rest - it is unused in the page 0 printf ( " %4d", $g_raw_ul [$a ++] );
printf ("\n\nUnused area on page 0:"); // }
// for ($i=0; $i<417; $i++) { // printf ("\n");
for ($i=0; $i<445; $i++) { }
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); printf ( "\n" );
$d=$g_raw_ul[$a++]; // / no need to dump the rest - it is unused in the page 0
printf (" %08x",$d); printf ( "\n\nUnused area on page 0:" );
} // for ($i=0; $i<417; $i++) {
for($i = 0; $i < 445; $i ++) {
} else { if (($i & 0x0f) == 0)
printf ("\nGamma table (direct):"); printf ( "\n0x%03x:", $i );
for ($i=0; $i<129; $i++) { $d = $g_raw_ul [$a ++];
if (($i & 0x07)==0) printf ("\n0x%03x:",$i*2); printf ( " %08x", $d );
$d=$g_raw_ul[$a++]; }
printf (" %04x %04x",$d & 0xffff, ($d>>16) & 0xffff ); } else {
} printf ( "\nGamma table (direct):" );
printf ("\n\nGamma table (reverse):"); for($i = 0; $i < 129; $i ++) {
for ($i=0; $i<64; $i++) { if (($i & 0x07) == 0)
if (($i & 0x03)==0) printf ("\n0x%03x:",$i*4); printf ( "\n0x%03x:", $i * 2 );
$d=$g_raw_ul[$a++]; $d = $g_raw_ul [$a ++];
printf (" %02x %02x %02x %02x",$d & 0xff, ($d>>8) & 0xff, ($d>>16) & 0xff, ($d>>24) & 0xff); printf ( " %04x %04x", $d & 0xffff, ($d >> 16) & 0xffff );
} }
printf ( "\n\nGamma table (reverse):" );
printf ("\n\nFPGA gamma data:"); for($i = 0; $i < 64; $i ++) {
for ($i=0; $i<256; $i++) { if (($i & 0x03) == 0)
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); printf ( "\n0x%03x:", $i * 4 );
$d=$g_raw_ul[$a++]; $d = $g_raw_ul [$a ++];
printf (" %05x",$d); printf ( " %02x %02x %02x %02x", $d & 0xff, ($d >> 8) & 0xff, ($d >> 16) & 0xff, ($d >> 24) & 0xff );
} }
}
echo "</pre>\n"; 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 { * 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",
echo "<pre>\n"; 3 => "B"
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]); $h_arr = elphel_histogram_get ($GLOBALS['sensor_port'], $GLOBALS['$sensor_subchn'], 0xfff, $frame );
for ($i=0; $i<256; $i++) { $a = 0;
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); $offset2sum = 1024 + 255; // / last in cumulative histogram for the same color
printf (" %05x",$h_arr[$a++]); echo "<pre>\n";
} for($color = 0; $color < 4; $color ++) {
printf ("\n"); 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 ($color=0;$color<4;$color++) { if (($i & 0x0f) == 0)
printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]); printf ( "\n0x%03x:", $i );
for ($i=0; $i<256; $i++) { printf ( " %05x", $h_arr [$a ++] );
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); }
printf (" %08x",$h_arr[$a++]); printf ( "\n" );
} }
printf ("\n"); for($color = 0; $color < 4; $color ++) {
} printf ( "\ncumulative histogram for color #%d %s:", $color, $colors [$color] );
for ($color=0;$color<4;$color++) { for($i = 0; $i < 256; $i ++) {
printf("\npercentile for color #%d %s:",$color,$colors[$color]); if (($i & 0x0f) == 0)
for ($i=0; $i<256; $i++) { printf ( "\n0x%03x:", $i );
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i); printf ( " %08x", $h_arr [$a ++] );
printf (" %02x",$h_arr[$a++]); }
} printf ( "\n" );
printf ("\n"); }
} for($color = 0; $color < 4; $color ++) {
echo "</pre>\n"; 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) {
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"
echo "<pre>\n"; );
$a=1; /// unpack started with index 1 $h_raw = elphel_histogram_get_raw ($GLOBALS['sensor_port'], $GLOBALS['$sensor_subchn'], $needed, $frame );
$hframe= $h_raw_ul[$a++]; // var_dump()
$valid= $h_raw_ul[$a++]; $h_raw_ul = unpack ( 'V*', substr ( $h_raw, 0, $percentile_start ) );
$hash32_r= $h_raw_ul[$a++]; echo "<pre>\n";
$hash32_g= $h_raw_ul[$a++]; $a = 1; // / unpack started with index 1
$hash32_gb=$h_raw_ul[$a++]; $hframe = $h_raw_ul [$a ++];
$hash32_b= $h_raw_ul[$a++]; $valid = $h_raw_ul [$a ++];
$hash32_r = $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)); $hash32_g = $h_raw_ul [$a ++];
printf ("hash32: R:0x%x G:0x%x GB:0x%x B:0x%x)\n",$hash32_r,$hash32_g,$hash32_gb,$hash32_b); $hash32_gb = $h_raw_ul [$a ++];
for ($color=0;$color<4;$color++) { $hash32_b = $h_raw_ul [$a ++];
$sum=0;
for ($i=0; $i<256; $i++) $sum+=$h_raw_ul[$a+$i]; 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("\nhistogram for color #%d %s sum=%d (0x%x):",$color,$colors[$color],$sum,$sum); printf ( "hash32: R:0x%x G:0x%x GB:0x%x B:0x%x)\n", $hash32_r, $hash32_g, $hash32_gb, $hash32_b );
for ($i=0; $i<256; $i++) { for($color = 0; $color < 4; $color ++) {
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); $sum = 0;
$d=$h_raw_ul[$a++]; for($i = 0; $i < 256; $i ++)
printf (" %05x",$d); $sum += $h_raw_ul [$a + $i];
} printf ( "\nhistogram for color #%d %s sum=%d (0x%x):", $color, $colors [$color], $sum, $sum );
printf ("\n"); for($i = 0; $i < 256; $i ++) {
} if (($i & 0x0f) == 0)
for ($color=0;$color<4;$color++) { 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 ( " %05x", $d );
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); }
$d=$h_raw_ul[$a++]; printf ( "\n" );
printf (" %08x",$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("\npercentile for color #%d %s:",$color,$colors[$color]); printf ( "\n0x%03x:", $i );
for ($i=0; $i<256; $i++) { $d = $h_raw_ul [$a ++];
if (($i & 0x01f)==0) printf ("\n0x%03x:",$i); printf ( " %08x", $d );
printf (" %02x",ord($h_raw[$percentile_start+(256*$color)+$i])); }
} printf ( "\n" );
printf ("\n"); }
} for($color = 0; $color < 4; $color ++) {
echo "</pre>\n"; 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) { 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++]); }
echo "\n.modsince:"; printf ( "\n.functions= %08x:", $fp_raw_ul [$a ++] );
for ($i=0; $i<31; $i++) { echo "\n.modsince:";
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); for($i = 0; $i < 31; $i ++) {
printf (" %08x:",$fp_raw_ul[$a++]); if (($i & 0x0f) == 0)
} printf ( "\n0x%03x:", $i );
printf ("\n.modsince32= %08x:",$fp_raw_ul[$a++]); printf ( " %08x:", $fp_raw_ul [$a ++] );
echo "\n.mod:"; }
for ($i=0; $i<31; $i++) { printf ( "\n.modsince32= %08x:", $fp_raw_ul [$a ++] );
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); echo "\n.mod:";
printf (" %08x:",$fp_raw_ul[$a++]); for($i = 0; $i < 31; $i ++) {
} if (($i & 0x0f) == 0)
printf ("\n.mod32= %08x:",$fp_raw_ul[$a++]); printf ( "\n0x%03x:", $i );
echo "\n.needproc:"; printf ( " %08x:", $fp_raw_ul [$a ++] );
for ($i=0; $i<31; $i++) { }
if (($i & 0x0f)==0) printf ("\n0x%03x:",$i); printf ( "\n.mod32= %08x:", $fp_raw_ul [$a ++] );
printf (" %08x:",$fp_raw_ul[$a++]); echo "\n.needproc:";
} for($i = 0; $i < 31; $i ++) {
printf ("\n.needproc32= %08x:",$fp_raw_ul[$a++]); if (($i & 0x0f) == 0)
// var_dump($fp_raw_ul); printf ( "\n0x%03x:", $i );
echo "</pre>\n"; 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() {
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)
if ($row_open) printf ("</tr>\n"); printf ( "</tr>\n" );
printf ("<tr>"); printf ( "<tr>" );
$row_open=true; $row_open = true;
} }
$url=$imgsrv; $url = $imgsrv;
for ($i=0;$i<$hist;$i++) $url.='/prev'; for($i = 0; $i < $hist; $i ++)
// $url .= '/img'; $url .= '/prev';
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 .= '/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"); 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