SerialPort.hpp   SerialPort.hpp 
/* /*
The stellarium telescope library helps building The stellarium telescope library helps building
telescope server programs, that can communicate with stellarium telescope server programs, that can communicate with stellarium
by means of the stellarium TCP telescope protocol. by means of the stellarium TCP telescope protocol.
It also contains smaple server classes (dummy, Meade LX200). It also contains smaple server classes (dummy, Meade LX200).
Author and Copyright of this file and of the stellarium telescope library: Author and Copyright of this file and of the stellarium telescope library:
Johannes Gajdosik, 2006 Johannes Gajdosik, 2006
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU General Public License
License as published by the Free Software Foundation; either as published by the Free Software Foundation; either version 2
version 2.1 of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU General Public License
License along with this library; if not, write to the Free Software along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA USA.
*/ */
#ifndef _SERIAL_PORT_HPP_ #ifndef _SERIAL_PORT_HPP_
#define _SERIAL_PORT_HPP_ #define _SERIAL_PORT_HPP_
#include "Connection.hpp" #include "Connection.hpp"
#ifdef WIN32 #ifdef Q_OS_WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <termios.h> #include <termios.h>
#endif #endif
//! Serial interface connection. //! Serial interface connection.
class SerialPort : public Connection class SerialPort : public Connection
{ {
public: public:
//! Class constructor. //! Class constructor.
//! @param serial_device A string containing the name of a serial po rt. //! @param serial_device A string containing the name of a serial po rt.
//! On UNIX systems, this should be something like "/dev/ttyS0". //! On UNIX systems, this should be something like "/dev/ttyS0".
//! On Microsoft Windows systems, this should be something like "COM 1:". //! On Microsoft Windows systems, this should be something like "COM 1:".
SerialPort(Server &server, const char *serial_device); SerialPort(Server &server, const char *serial_device);
~SerialPort(void); ~SerialPort(void);
//! Returns true if the connection is closed. //! Returns true if the connection is closed.
//! This method has different platform-dependent implementations. //! This method has different platform-dependent implementations.
virtual bool isClosed(void) const virtual bool isClosed(void) const
{ {
#ifdef WIN32 #ifdef Q_OS_WIN32
return (handle == INVALID_HANDLE_VALUE); return (handle == INVALID_HANDLE_VALUE);
#else #else
return IS_INVALID_SOCKET(fd); return IS_INVALID_SOCKET(fd);
#endif #endif
} }
protected: protected:
void prepareSelectFds(fd_set&, fd_set&, int&); void prepareSelectFds(fd_set&, fd_set&, int&);
private: private:
//! Returns false, as SerialPort implements a serial port connection . //! Returns false, as SerialPort implements a serial port connection .
bool isTcpConnection(void) const {return false;} bool isTcpConnection(void) const {return false;}
//! Returns true, as SerialPort implements a serial port connection. //! Returns true, as SerialPort implements a serial port connection.
bool isAsciiConnection(void) const {return true;} bool isAsciiConnection(void) const {return true;}
private: private:
#ifdef WIN32 #ifdef Q_OS_WIN32
int readNonblocking(char *buf, int count); int readNonblocking(char *buf, int count);
int writeNonblocking(const char *buf, int count); int writeNonblocking(const char *buf, int count);
void handleSelectFds(const fd_set&, const fd_set&) {} void handleSelectFds(const fd_set&, const fd_set&) {}
HANDLE handle; HANDLE handle;
DCB dcb_original; DCB dcb_original;
#else #else
struct termios termios_original; struct termios termios_original;
#endif #endif
}; };
 End of changes. 6 change blocks. 
12 lines changed or deleted 12 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/