/usr/include/Aria/ArDeviceConnection.h is in libaria-dev 2.8.0+repack-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | /*
Adept MobileRobots Robotics Interface for Applications (ARIA)
Copyright (C) 2004, 2005 ActivMedia Robotics LLC
Copyright (C) 2006, 2007, 2008, 2009, 2010 MobileRobots Inc.
Copyright (C) 2011, 2012, 2013 Adept Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
If you wish to redistribute ARIA under different terms, contact
Adept MobileRobots for information about a commercial version of ARIA at
robots@mobilerobots.com or
Adept MobileRobots, 10 Columbia Drive, Amherst, NH 03031; +1-603-881-7960
*/
#ifndef ARDEVICECONNECTION_H
#define ARDEVICECONNECTION_H
#include <string>
#include "ariaTypedefs.h"
#include "ariaUtil.h"
#include "ArBasePacket.h"
/// Base class for device connections
/**
Base class for device connections, this is mostly for connections to the
robot or simulator but could also be used for a connection to a laser
or other device
Note that this is mostly a base class, so if you'll want to use one of the
classes which inherit from this one... also note that in those classes
is where you'll find setPort which sets the place the device connection
will try to connect to... the inherited classes also have an open which
returns more detailed information about the open attempt, and which takes
the parameters for where to connect
*/
class ArDeviceConnection
{
public:
/// constructor
AREXPORT ArDeviceConnection();
/// destructor also forces a close on the connection
AREXPORT virtual ~ArDeviceConnection();
/// Reads data from connection
/**
Reads data from connection
@param data pointer to a character array to read the data into
@param size maximum number of bytes to read
@param msWait read blocks for this many milliseconds (not at all for == 0)
@return number of bytes read, or -1 for failure
@see write, writePacket
*/
AREXPORT virtual int read(const char *data, unsigned int size,
unsigned int msWait = 0) = 0;
/// Writes data to connection
/**
Writes data to connection from a packet
@param packet pointer to a packet to write the data from
@return number of bytes written, or -1 for failure
@see read, write
*/
AREXPORT virtual int writePacket(ArBasePacket *packet)
{ if (packet == NULL || packet->getLength() == 0) return 0;
return write(packet->getBuf(), packet->getLength()); }
/// Writes data to connection
/**
Writes data to connection
@param data pointer to a character array to write the data from
@param size number of bytes to write
@return number of bytes read, or -1 for failure
@see read, writePacket
*/
AREXPORT virtual int write(const char *data, unsigned int size) = 0;
/// Gets the status of the connection, which is one of the enum status
/**
Gets the status of the connection, which is one of the enum status.
If you want to get a string to go along with the number, use
getStatusMessage
@return the status of the connection
@see getStatusMessage
*/
AREXPORT virtual int getStatus(void) = 0;
/// Gets the description string associated with the status
/**
@param messageNumber the int from getStatus you want the string for
@return the description associated with the status
@see getStatus
*/
AREXPORT const char *getStatusMessage(int messageNumber) const;
/// Opens the connection again, using the values from setLocation or
// a previous open
virtual bool openSimple(void) = 0;
/// Closes the connection
/**
@return whether the close succeeded or not
*/
virtual bool close(void) { return false; }
/// Gets the string of the message associated with opening the device
/**
Each class inherited from this one has an open method which returns 0
for success or an integer which can be passed into this function to
obtain a string describing the reason for failure
@param messageNumber the number returned from the open
@return the error description associated with the messageNumber
*/
AREXPORT virtual const char * getOpenMessage(int messageNumber) = 0;
enum Status {
STATUS_NEVER_OPENED = 1, ///< Never opened
STATUS_OPEN, ///< Currently open
STATUS_OPEN_FAILED, ///< Tried to open, but failed
STATUS_CLOSED_NORMALLY, ///< Closed by a close call
STATUS_CLOSED_ERROR ///< Closed because of error
};
/// Gets the time data was read in
/**
@param index looks like this is the index back in the number of bytes
last read in
@return the time the last read data was read in
*/
AREXPORT virtual ArTime getTimeRead(int index) = 0;
/// sees if timestamping is really going on or not
/** @return true if real timestamping is happening, false otherwise */
AREXPORT virtual bool isTimeStamping(void) = 0;
/// Gets the port name
AREXPORT const char *getPortName(void) const;
/// Gets the port type
AREXPORT const char *getPortType(void) const;
/// Sets the device type (what this is connecting to)
AREXPORT void setDeviceName(const char *deviceName);
/// Gets the device type (what this is connecting to)
AREXPORT const char *getDeviceName(void) const;
/// Notifies the device connection that the start of a packet is
/// trying to be read
AREXPORT void debugStartPacket(void);
/// Notifies the device connection that some bytes were read (should
/// call with 0 if it read but got no bytes)
AREXPORT void debugBytesRead(int bytesRead);
/// Notifies the device connection that the end of a packet was
/// read, which will cause log messages if set to do so
AREXPORT void debugEndPacket(bool goodPacket, int type = 0);
/// Makes all device connections so that they'll dump data
AREXPORT static bool debugShouldLog(bool shouldLog);
protected:
/// Sets the port name
AREXPORT void setPortName(const char *portName);
/// Sets the port type
AREXPORT void setPortType(const char *portType);
void buildStrMap(void);
static bool ourStrMapInited;
static ArStrMap ourStrMap;
std::string myDCPortName;
std::string myDCPortType;
std::string myDCDeviceName;
static bool ourDCDebugShouldLog;
static ArTime ourDCDebugFirstTime;
bool myDCDebugPacketStarted;
ArTime myDCDebugStartTime;
ArTime myDCDebugFirstByteTime;
ArTime myDCDebugLastByteTime;
int myDCDebugBytesRead;
int myDCDebugTimesRead;
long long myDCDebugNumGoodPackets;
long long myDCDebugNumBadPackets;
};
#endif
|