# VectorNav C++ Library: include/vn/serialport.h Source File

serialport.h
#ifndef _VN_XPLAT_SERIALPORT_H_
#define _VN_XPLAT_SERIALPORT_H_
#if _MSC_VER && _WIN32
#pragma comment(lib, "setupapi.lib")
#endif
#include <string>
#include <vector>
#include <list>
#if PYTHON
#include "boostpython.h"
#endif
#include "int.h"
#include "port.h"
#include "nocopy.h"
#include "export.h"
namespace vn {
namespace xplat {
class vn_proglib_DLLEXPORT SerialPort : public IPort, util::NoCopy
{
// Types //////////////////////////////////////////////////////////////////
public:
enum StopBits
{
ONE_STOP_BIT,
TWO_STOP_BITS
};
// Constructors ///////////////////////////////////////////////////////////
public:
SerialPort(const std::string& portName, uint32_t baudrate);
~SerialPort();
// Public Methods /////////////////////////////////////////////////////////
public:
static std::vector<std::string> getPortNames();
virtual void open();
virtual void close();
virtual bool isOpen();
virtual void write(const char data[], size_t length);
virtual void read(char dataBuffer[], size_t numOfBytesToRead, size_t &numOfBytesActuallyRead);
virtual void registerDataReceivedHandler(void* userData, DataReceivedHandler handler);
virtual void unregisterDataReceivedHandler();
uint32_t baudrate();
std::string port();
void changeBaudrate(uint32_t br);
StopBits stopBits();
void setStopBits(StopBits stopBits);
size_t NumberOfReceiveDataDroppedSections();
static bool determineIfPortIsOptimized(std::string portName);
static void optimizePort(std::string portName);
#if PYTHON && !PL156_ORIGINAL && !PL156_FIX_ATTEMPT_1
virtual void stopThread();
virtual void resumeThread();
virtual bool threadStopped();
#endif
// Private Members ////////////////////////////////////////////////////////
private:
// Contains internal data, mainly stuff that is required for cross-platform
// support.
struct Impl;
Impl *_pi;
};
}
}
#endif
int.h
nocopy.h
vn::xplat::IPort
Interface for a simple port.
Definition: port.h:12
vn::xplat::SerialPort
Represents a cross-platform serial port.
Definition: serialport.h:34
xplat
Definition: mock.h:4
vn::util::NoCopy
Identifies a derived class as being unable to be copied and prevents copy attempts.
Definition: nocopy.h:21
vn
Definition: attitude.h:8