00001 /*!@file Devices/Pelco.C Interface to ptz cameras via the Pelco protocol */ 00002 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00006 // University of Southern California (USC) and the iLab at USC. // 00007 // See http://iLab.usc.edu for information about this project. // 00008 // //////////////////////////////////////////////////////////////////// // 00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00011 // in Visual Environments, and Applications'' by Christof Koch and // 00012 // Laurent Itti, California Institute of Technology, 2001 (patent // 00013 // pending; application number 09/912,225 filed July 23, 2001; see // 00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00015 // //////////////////////////////////////////////////////////////////// // 00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00017 // // 00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00019 // redistribute it and/or modify it under the terms of the GNU General // 00020 // Public License as published by the Free Software Foundation; either // 00021 // version 2 of the License, or (at your option) any later version. // 00022 // // 00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00026 // PURPOSE. See the GNU General Public License for more details. // 00027 // // 00028 // You should have received a copy of the GNU General Public License // 00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00031 // Boston, MA 02111-1307 USA. // 00032 // //////////////////////////////////////////////////////////////////// // 00033 // 00034 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Devices/Pelco.C $ 00036 // $Id: Pelco.C 12962 2010-03-06 02:13:53Z irock $ 00037 // 00038 00039 #include "Devices/Pelco.H" 00040 00041 #include "Component/OptionManager.H" 00042 #include "Devices/Serial.H" 00043 00044 ///*** Protol P for now ***// 00045 00046 // ###################################################################### 00047 Pelco::Pelco(OptionManager& mgr, const std::string& descrName, 00048 const std::string& tagName, const char *defdev, const int cameraAddr) : 00049 ModelComponent(mgr, descrName, tagName), 00050 itsPort(new Serial(mgr)), 00051 itsCameraAddr(cameraAddr) 00052 { 00053 // set a default config for our serial port: 00054 itsPort->configure(defdev, 9600 , "8N1", false, false, 1); 00055 00056 // attach our port as a subcomponent: 00057 addSubComponent(itsPort); 00058 00059 } 00060 00061 // ###################################################################### 00062 Pelco::~Pelco() 00063 { 00064 } 00065 00066 int Pelco::sendRawCmd(const unsigned char byte1, const unsigned char byte2, const unsigned char byte3, const unsigned char byte4) 00067 { 00068 00069 int size = 8; 00070 unsigned char cmd[size]; 00071 00072 cmd[0] = 0xA0; //STX start transmission 00073 cmd[1] = itsCameraAddr-1; //zero based address (i.e. addr 1 is 0) 00074 cmd[2] = byte1; 00075 cmd[3] = byte2; 00076 cmd[4] = byte3; 00077 cmd[5] = byte4; 00078 cmd[6] = 0xAF; //ETX (end transmission) 00079 cmd[7] = cmd[1]^cmd[2]^cmd[3]^cmd[4]^cmd[5]; //Check sum 00080 00081 // write command buffer 00082 itsPort->write(cmd, size); 00083 00084 if (true) 00085 { 00086 LINFO("Sending: "); 00087 for(int i=0; i<size; i++) 00088 printf("%x ", cmd[i]); 00089 printf("\n"); 00090 } 00091 00092 return 0; 00093 } 00094 00095 void Pelco::start2() 00096 { 00097 } 00098 00099 // ###################################################################### 00100 bool Pelco::movePanTilt(const int pan, const int tilt, 00101 const bool relative, 00102 const int panSpeed, const int tiltSpeed) 00103 { 00104 return true; 00105 } 00106 00107 // ###################################################################### 00108 bool Pelco::resetPanTilt() 00109 { 00110 return true; 00111 00112 } 00113 00114 // ###################################################################### 00115 bool Pelco::zoom(const int val, const bool relative) 00116 { 00117 00118 return false; 00119 00120 } 00121 00122 // ###################################################################### 00123 bool Pelco::setFocus(const int val, const bool relative) 00124 { 00125 00126 return false; 00127 } 00128 00129 00130 bool Pelco::stop() 00131 { 00132 return false; 00133 00134 } 00135 00136 00137 00138 // ###################################################################### 00139 /* So things look consistent in everyone's emacs... */ 00140 /* Local Variables: */ 00141 /* indent-tabs-mode: nil */ 00142 /* End: */