serialinterface.h
Go to the documentation of this file.
00001 /*
00002  *  AscTec Autopilot Serial Interface
00003  *  Copyright (C) 2010, CCNY Robotics Lab
00004  *  Ivan Dryanovski <ivan.dryanovski@gmail.com>
00005  *  William Morris <morris@ee.ccny.cuny.edu>
00006  *  http://robotics.ccny.cuny.edu
00007  *
00008  *  This program is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  This program is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *  GNU General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public License
00019  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 #ifndef ASCTEC_AUTOPILOT_SERIALINTERFACE_H
00023 #define ASCTEC_AUTOPILOT_SERIALINTERFACE_H
00024 
00025 #include <stdio.h>
00026 #include <sys/termios.h>
00027 #include <sys/ioctl.h>
00028 #include <cstring>
00029 #include <unistd.h>
00030 #include <cstdlib>
00031 #include <time.h>
00032 #include <errno.h>
00033 #include <bitset>
00034 
00035 #include <ros/ros.h>
00036 
00037 #include "asctec_autopilot/crc16.h"
00038 #include "asctec_autopilot/telemetry.h"
00039 
00040 namespace asctec
00041 {
00042   class SerialInterface
00043   {
00044   public:
00045     SerialInterface (std::string port, uint32_t speed);
00046     ~SerialInterface ();
00047 
00048     void output (char *output, int len);
00049     void output (unsigned char *output, int len);
00050     bool getPackets (Telemetry *telemetry);
00051     void sendControl (Telemetry *telemetry);
00052     void sendEstop (Telemetry *telemetry);
00053     void dumpDebug (void);
00054     bool getPacket (char *spacket, unsigned char &packet_type, unsigned short &packet_crc, unsigned short &packet_size);
00055 
00056     uint32_t serialport_bytes_rx_;
00057     uint32_t serialport_bytes_tx_;
00058     int *scan;
00059     bool status;
00060     int pt[800];
00061     int counter;
00062   private:
00063       speed_t bitrate (int);
00064     void flush ();
00065     void drain ();
00066     void stall (bool);
00067     int wait (int);
00068 
00069     int dev_;
00070     std::string serialport_name_;
00071     uint32_t serialport_speed_;
00072     speed_t serialport_baud_;
00073   };
00074 }
00075 #endif


asctec_autopilot
Author(s): William Morris, Ivan Dryanovski, Steven Bellens, Patrick Bouffard et al.
autogenerated on Tue Jan 7 2014 11:04:25