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.1.1  2008/11/27 20:04:03  elphel
00024 *!
00025 *!
00026 *!  Revision 1.1  2007/12/06 19:02:52  elphel
00027 *!  collected most of the camera PHP script into one  /packages/web/353/php_top directory
00028 *!
00029 *!  Revision 1.1  2007/10/16 19:25:27  elphel
00030 *!  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
00031 *!
00032 *!
00033 */
00034 
00035  $cmd=$_GET['cmd'];
00036  $addr=$_GET['addr'];
00037  $data=$_GET['data'];
00038 
00039 // if (is_numeric ($addr)) $addr=$addr+0;
00040 // if (is_numeric ($data)) $data=$data+0;
00041 
00042  switch  ($cmd) {
00043    case "list":
00044    $start=0;
00045    $length=2048;
00046    $sensorpars  = fopen('/dev/sensorpars', 'r');
00047    fseek ($sensorpars, 4*$start) ; // 32-bit registers
00048    $d = fread($sensorpars, 4*$length);
00049    fclose($sensorpars);
00050    $regs=unpack('V*',$d); // unsigned long, little endian
00051 //   print_r($regs);
00052    echo "<table>\n";
00053    for ($i=0; $i<$length; $i+=16){
00054      printf("<tr><td>%x</td>",$i);
00055      for ($j=1; $j<17; $j++){
00056        printf("<td>%x</td>",$regs[$i+$j]);
00057      }
00058      echo "</tr>\n";
00059    }
00060    echo "</table>\n";
00061 //}
00062 
00063    break;
00064    case "read":
00065      if (is_numeric ($addr)) {
00066        $sensorpars  = fopen('/dev/sensorpars', 'r');
00067 //echo "addr=".$addr;
00068        fseek ($sensorpars, 4*($addr+0)) ; // 32-bit registers
00069        $d = fread($sensorpars, 4);
00070        fclose($sensorpars);
00071        $regs=unpack('V*',$d); // unsigned long, little endian
00072 //   print_r($regs);
00073        printf ("<p>%d(0x%x):%d(0x%x)</p>\n",($addr+0),($addr+0),$regs[1],$regs[1]);
00074      }
00075 
00076   break;
00077    case "write":
00078     if (is_numeric ($addr) && is_numeric ($data)) {
00079        $sensorpars  = fopen('/dev/sensorpars', 'w');
00080        fseek ($sensorpars, 4*($addr+0)) ; // 32-bit registers
00081        $d=$data+0;
00082        fwrite($sensorpars, chr($d & 0xff).chr(($d>>8) & 0xff).chr(($d>>16) & 0xff).chr(($d>>24) & 0xff));
00083        fclose($sensorpars);
00084     }
00085    break;
00086    default:
00087     echo <<<USAGE
00088    <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>
00089    <ul>
00090     <li><b>cmd=list</b> - show all registers</li>
00091     <li><b>cmd=read&addr=<i>ra</i></b> -  read register <i>ra</i></li>
00092     <li><b>cmd=write&addr=<i>ra</i>&data=<i>rd</i></b> -  write <i>rd</i> to register <i>ra</i></li>
00093   </ul>
00094 USAGE;
00095 
00096  }
00097 ?>

Generated on Fri Nov 28 00:06:25 2008 for elphel by  doxygen 1.5.1