packages/web/353/php_top/senspars.php

Go to the documentation of this file.
00001 <?php
00002 /*!*******************************************************************************
00003 *! FILE NAME  : senspars.php
00004 *! DESCRIPTION: Provides control of FPGA compressor/image acquisition
00005 *!              to the circular buffer (circbuf)
00006 *! Copyright (C) 2007 Elphel, Inc
00007 *! -----------------------------------------------------------------------------**
00008 *!
00009 *!  This program is free software: you can redistribute it and/or modify
00010 *!  it under the terms of the GNU General Public License as published by
00011 *!  the Free Software Foundation, either version 3 of the License, or
00012 *!  (at your option) any later version.
00013 *!
00014 *!  This program is distributed in the hope that it will be useful,
00015 *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 *!  GNU General Public License for more details.
00018 *!
00019 *!  You should have received a copy of the GNU General Public License
00020 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021 *! -----------------------------------------------------------------------------**
00022 *!  $Log: senspars.php,v $
00023 *!  Revision 1.1  2007/12/06 19:02:52  elphel
00024 *!  collected most of the camera PHP script into one  /packages/web/353/php_top directory
00025 *!
00026 *!  Revision 1.1  2007/10/16 19:25:27  elphel
00027 *!  Added php script to control driver parameters (P_XXX, as defined in c313a.h) instead of the IOCTL. It is possible to control sensor phase with it
00028 *!
00029 *!
00030 */
00031 
00032  $cmd=$_GET['cmd'];
00033  $addr=$_GET['addr'];
00034  $data=$_GET['data'];
00035 
00036 // if (is_numeric ($addr)) $addr=$addr+0;
00037 // if (is_numeric ($data)) $data=$data+0;
00038 
00039  switch  ($cmd) {
00040    case "list":
00041    $start=0;
00042    $length=2048;
00043    $sensorpars  = fopen('/dev/sensorpars', 'r');
00044    fseek ($sensorpars, 4*$start) ; // 32-bit registers
00045    $d = fread($sensorpars, 4*$length);
00046    fclose($sensorpars);
00047    $regs=unpack('V*',$d); // unsigned long, little endian
00048 //   print_r($regs);
00049    echo "<table>\n";
00050    for ($i=0; $i<$length; $i+=16){
00051      printf("<tr><td>%x</td>",$i);
00052      for ($j=1; $j<17; $j++){
00053        printf("<td>%x</td>",$regs[$i+$j]);
00054      }
00055      echo "</tr>\n";
00056    }
00057    echo "</table>\n";
00058 //}
00059 
00060    break;
00061    case "read":
00062      if (is_numeric ($addr)) {
00063        $sensorpars  = fopen('/dev/sensorpars', 'r');
00064 //echo "addr=".$addr;
00065        fseek ($sensorpars, 4*($addr+0)) ; // 32-bit registers
00066        $d = fread($sensorpars, 4);
00067        fclose($sensorpars);
00068        $regs=unpack('V*',$d); // unsigned long, little endian
00069 //   print_r($regs);
00070        printf ("<p>%d(0x%x):%d(0x%x)</p>\n",($addr+0),($addr+0),$regs[1],$regs[1]);
00071      }
00072 
00073   break;
00074    case "write":
00075     if (is_numeric ($addr) && is_numeric ($data)) {
00076        $sensorpars  = fopen('/dev/sensorpars', 'w');
00077        fseek ($sensorpars, 4*($addr+0)) ; // 32-bit registers
00078        $d=$data+0;
00079        fwrite($sensorpars, chr($d & 0xff).chr(($d>>8) & 0xff).chr(($d>>16) & 0xff).chr(($d>>24) & 0xff));
00080        fclose($sensorpars);
00081     }
00082    break;
00083    default:
00084     echo <<<USAGE
00085    <p>This read/writes P_XXX registers as defined in  <a href="http://elphel.cvs.sourceforge.net/elphel/elphel353-7.1/os/linux-2.6-tag--devboard-R2_10-4/include/asm-cris/elphel/c313a.h">os/linux-2.6/include/asm-cris/elphel/c313a.h</a>.</p>
00086    <ul>
00087     <li><b>cmd=list</b> - show all registers</li>
00088     <li><b>cmd=read&addr=<i>ra</i></b> -  read register <i>ra</i></li>
00089     <li><b>cmd=write&addr=<i>ra</i>&data=<i>rd</i></b> -  write <i>rd</i> to register <i>ra</i></li>
00090   </ul>
00091 USAGE;
00092 
00093  }
00094 ?>

Generated on Thu Aug 7 16:19:01 2008 for elphel by  doxygen 1.5.1