00001 /*************************************************************************** 00002 tag: Peter Soetens Wed Jan 18 14:11:40 CET 2006 comedi_internal.h 00003 00004 comedi_internal.h - description 00005 ------------------- 00006 begin : Wed January 18 2006 00007 copyright : (C) 2006 Peter Soetens 00008 email : peter.soetens@mech.kuleuven.be 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU Lesser General Public * 00013 * License as published by the Free Software Foundation; either * 00014 * version 2.1 of the License, or (at your option) any later version. * 00015 * * 00016 * This library is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00019 * Lesser General Public License for more details. * 00020 * * 00021 * You should have received a copy of the GNU Lesser General Public * 00022 * License along with this library; if not, write to the Free Software * 00023 * Foundation, Inc., 59 Temple Place, * 00024 * Suite 330, Boston, MA 02111-1307 USA * 00025 * * 00026 ***************************************************************************/ 00027 00028 00029 00030 // Some info about this hack : 00031 // For LXRT, we should include <rtai_comedi.h> 00032 // but this file is horribly broken, thus 00033 // we use the signatures of the linux/comedilib.h 00034 // functions but _link_ against libkcomedilib_lxrt.so 00035 00036 #ifndef _COMEDI_INTERNAL_HPP 00037 #define _COMEDI_INTERNAL_HPP 00038 00039 #include <rtt/RTT.hpp> 00040 #ifdef OROPKG_OS_LXRT 00041 #define __KERNEL__ 00042 extern "C" 00043 { 00044 #include <linux/comedilib.h> 00045 } 00046 #undef __KERNEL__ 00047 #else 00048 // userspace gnu/linux: 00049 #include <comedilib.h> 00050 #endif 00051 00052 #include <rtt/Logger.hpp> 00053 00054 namespace OCL 00055 { 00056 using namespace RTT; 00057 00063 class ComediDevice::DeviceInfo 00064 { 00065 public: 00066 DeviceInfo( unsigned int dm ) 00067 : devminor(dm), it(0) 00068 { 00069 char devString[ 15 ]; 00070 snprintf( devString, 15, "/dev/comedi%d", devminor ); 00071 00072 it = comedi_open( devString ); 00073 00074 if ( it == 0 ) 00075 log(Error) <<"Could not open "<< devString << ": no such device or invalid rights." << endlog(); 00076 else 00077 log(Info) << "Opened " << devString << ": success." << endlog(); 00078 00079 00080 } 00081 00082 ~DeviceInfo() { 00083 if ( it ) 00084 if ( comedi_close(it) < 0 ) 00085 log(Error) << "Device /dev/comedi"<<devminor<<" : close failed" << endlog(); 00086 } 00087 00088 unsigned int devminor; 00092 comedi_t *it; 00093 }; 00094 00095 00096 00097 00098 } 00099 #endif