00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009 $_pass = FALSE;
00010
00011 $MD_LENGTH = 32;
00012 $SPC_DAT_FILE = "/etc/test/spc.dat";
00013 if(file_exists($SPC_DAT_FILE)) {
00014 $inits = parse_ini_file($SPC_DAT_FILE);
00015 } else {
00016 $inits["test"] = "empty";
00017 }
00018
00019 require 'i2c.inc';
00020
00021 # initialize result
00022
00023
00024
00025 $res_xml = "<?xml version='1.0' standalone='yes'?><test name=\"sensor_pattern_compression\">";
00026
00027 # "online result" - i.e. runtime
00028 function res_update($name, $result, $description) {
00029 global $res_xml;
00030
00031 $res_xml .= "<${name} result=\"${result}\">";
00032 if($description != "")
00033 $res_xml .= $description;
00034 $res_xml .= "</${name}>\n";
00035 }
00036
00037
00038 function _finish() {
00039
00040
00041
00042
00043
00044 global $res_xml;
00045 global $_pass;
00046 if($_pass == TRUE)
00047 res_update("finish", "OK", "");
00048 else
00049 res_update("finish", "FAIL", "");
00050
00051 $res_xml .= "</test>";
00052 #echo $res_xml;
00053
00054 $xml = new SimpleXMLElement($res_xml);
00055
00056
00057
00058
00059
00060
00061 $rslt=$xml->asXML();
00062
00063 header("Content-Type: text/xml");
00064 header("Content-Length: ".strlen($rslt)."\n");
00065 header("Pragma: no-cache\n");
00066 printf($rslt);
00067 exit(0);
00068 }
00069
00070 $MODE = "check";
00071
00072 if($_GET['mode'] == "add")
00073 $MODE = "add";
00074
00075
00076
00077 $data = elphel_fpga_read(0x13);
00078 $fpga_rev = sprintf("0x%x",$data);
00079
00080
00081
00082 $SDRAM_PHASES_LOG = "/var/log/fpga_sdram_phase";
00083 if(is_file($SDRAM_PHASES_LOG)) {
00084 $ph_rez = exec("cat $SDRAM_PHASES_LOG | grep 'result='");
00085 if($ph_rez == "result=OK") {
00086 res_update("SDRAM_phase", "OK", "");
00087 } else {
00088
00089
00090 res_update("SDRAM_phase", "FAIL", "SDRAM phase incorrect");
00091 _finish();
00092 }
00093 }
00094
00095
00096
00097 $sdram_rez = exec("fpcf -mem 2000000 FFFF 0000 AAAA 5555 | grep 'result='");
00098 if($sdram_rez == "result=OK") {
00099 res_update("SDRAM_memory", "OK", "");
00100 } else {
00101
00102
00103 res_update("SDRAM_memory", "FAIL", "SDRAM pattern test fail");
00104 _finish();
00105 }
00106
00107
00108
00109 file_get_contents("http://127.0.0.1/camera_demo.php");
00110
00111
00112
00113 $s_id=i2c_receive(16, 0, 0x4800, 0);
00114 $s_id = sprintf("0x%x",$s_id);
00115 if($s_id != "0x1801") {
00116
00117
00118 res_update("SENSOR_id", "FAIL", "Unknown sensor ID ${s_id}");
00119 _finish();
00120 } else
00121 res_update("SENSOR_id", "OK", "");
00122
00123
00124
00125
00126
00127 if(array_key_exists("rev_".$fpga_rev, $inits) !== TRUE && $MODE == "check") {
00128
00129
00130 res_update("FPGA_compress", "UNKNOWN", "Unknown FPGA revision");
00131 _finish();
00132 }
00133
00134
00135 file_get_contents("http://127.0.0.1/imconf_load.php?conf=/etc/test/sensor_pattern_compress.conf");
00136
00137
00138 $s_id = i2c_send(16, 0, 0x48A0, 0x19, 0);
00139
00140
00141
00142 # skip the first two images (really needed first skip, second probably not)
00143 # because the top part of the previous real image will be at test image
00144 exec("wget http://127.0.0.1:8081/noexif/next/wait/img -O /dev/null");
00145 exec("wget http://127.0.0.1:8081/noexif/next/wait/img -O /dev/null");
00146 # this one is really test image
00147 exec("wget http://127.0.0.1:8081/noexif/next/wait/img -O /tmp/spc.jpeg");
00148
00149 $md = "";
00150 if(is_file("/tmp/spc.jpeg")) {
00151 $md = substr(exec("md5sum /tmp/spc.jpeg"), 0, $MD_LENGTH);
00152 unlink("/tmp/spc.jpeg");
00153 }
00154
00155 if($MODE == "check") {
00156 $_md = $inits["rev_".$fpga_rev];
00157 if($md != $_md) {
00158
00159
00160 res_update("FPGA_compress", "FAIL", "MD5SUM is |$md| and must be |$_md|");
00161 $s_id = i2c_send(16, 0, 0x48A0, 0x00, 0);
00162 _finish();
00163 } else {
00164 res_update("FPGA_compress", "OK", "");
00165 $_pass = TRUE;
00166
00167 }
00168 } else if($MODE == "add") {
00169 $f = fopen($SPC_DAT_FILE, 'a');
00170 # pair of "FPGA revision"="MD5SUM"
00171 fwrite($f, "rev_$fpga_rev=$md\n");
00172 fclose($f);
00173
00174 res_update("FPGA_compress", "OK", "MD5SUM record updated");
00175 $_pass = TRUE;
00176 } else {
00177 res_update("FPGA_compress", "UNKNOWN", "wrong command ${MODE}");
00178
00179 }
00180
00181
00182 $s_id = i2c_send(16, 0, 0x48A0, 0x00, 0);
00183 _finish();
00184
00185 ?>