00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00031 #ifndef _DIOC_H_ 00032 #define _DIOC_H_ 00033 00034 //System Includes 00035 //all system includes go here 00036 #include <string.h> 00037 #include <termios.h> 00038 #include <sys/ioctl.h> 00039 #include <stdlib.h> 00040 #include <stdio.h> 00041 #include <sys/types.h> 00042 #include <sys/stat.h> 00043 #include <fcntl.h> 00044 #include <unistd.h> 00045 #include <ros/ros.h> 00046 #include <termios.h> 00047 #include <sys/ioctl.h> 00048 #include <signal.h> 00049 00055 class class_dioc 00056 { 00057 public: 00065 class_dioc(const char*pdevice); 00066 00073 ~class_dioc(); 00074 00075 typedef enum {ON,OFF,BLINK1,BLINK3} status_enum; 00076 typedef enum {STATUS=0,FRONT,RIGHT,LEFT,REVERSE,BRAKE,BLUE,RED,GREEN,CROSS_A,CROSS_B} id_enum; 00077 00085 int SetStatus(id_enum ID,status_enum ENUM); 00086 00094 int SetStatus(id_enum ID, int status); 00095 00101 int GetStatus(id_enum ID); 00102 00107 int CommStatus(void); 00108 00119 void perr(int ret); 00120 00121 private: 00122 00129 void CleanBuffer(void); 00130 00132 bool active; 00133 00135 int port; 00136 00138 int ret; 00139 00141 char*device; 00142 00143 char err[1024]; 00144 }; 00145 #endif