apps/compass/compass_os5000.php

Go to the documentation of this file.
00001 <?php
00002 /*!*******************************************************************************
00003 *! FILE NAME  : compass.php
00004 *! DESCRIPTION: Reads Heading, Roll, Pitch from the Honeywell HMR3000 compass
00005 *!              module attached to the serial port of the Elphel model 353 camera
00006 *!              Requires 10349/10369 boards with extra connection to +5V
00007 *!              (on 10369 can use 4-pin RJ45 sync out as power).
00008 *!              Needs system to be configured with the debug port disabled.
00009 *! Copyright (C) 2008 Elphel, Inc
00010 *! -----------------------------------------------------------------------------**
00011 *!
00012 *!  This program is free software: you can redistribute it and/or modify
00013 *!  it under the terms of the GNU General Public License as published by
00014 *!  the Free Software Foundation, either version 3 of the License, or
00015 *!  (at your option) any later version.
00016 *!
00017 *!  This program is distributed in the hope that it will be useful,
00018 *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *!  GNU General Public License for more details.
00021 *!
00022 *!  You should have received a copy of the GNU General Public License
00023 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00024 *! -----------------------------------------------------------------------------**
00025 *!
00026 *!  $Log: compass_os5000.php,v $
00027 *!  Revision 1.1.1.1  2008/11/27 20:04:01  elphel
00028 *!
00029 *!
00030 *!  Revision 1.1  2008/04/07 09:17:01  elphel
00031 *!  manual interface to compass modules
00032 *!
00033 *!  Revision 1.1  2008/03/23 20:13:47  elphel
00034 *!  added support for the Honeywell HMR3000 compass module attached to the serial port.
00035 *!
00036 *!
00037 */
00038         // command code and value come with no spaces
00039         // example: "http://192.168.1.75/var/compass.php?*1", * - command, 1 - value
00040         $ser_port="/dev/ttyUSB0";
00041 
00042         $xml = new SimpleXMLElement("<?xml version='1.0'?><hpr/>");
00043         
00044         $s=str_split($_SERVER["QUERY_STRING"]);
00045 
00046         for ($i=1; $i<sizeof($s); $i++) {
00047                 $s1.= $s[$i];
00048         }
00049         
00050         exec ("stty -F $ser_port onlcr -echo speed 19200");
00051 
00052         $sero=fopen($ser_port,"w");
00053         $seri=fopen($ser_port,"r");
00054 
00055         $n=fwrite($sero,chr(27).$s[0]."\n");// chr(27) - ESC character, $s[0] - command,"\n" - <enter> 
00056         $response=fgets($seri);             // here the compass writes "enter value or esc"
00057         $n=fwrite($sero,"$s1\n");           // command value is written
00058 
00059         for ($i=0; $i<3; $i++) {
00060                 fgets($seri);
00061                 $response.="; ".fgets($seri);
00062         }
00063 
00064         fclose ($sero);
00065         fclose ($seri);
00066 
00067   $xml->addChild ('raw',$response);
00068   
00069   $rslt=$xml->asXML();
00070   header("Content-Type: text/xml");
00071   header("Content-Length: ".strlen($rslt)."\n");
00072   header("Pragma: no-cache\n");
00073   printf($rslt);
00074 ?>
00075  

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