Go to the documentation of this file.00001
00048 #ifndef VSERIAL_PORT_H
00049 #define VSERIAL_PORT_H
00050
00051 #include <poll.h>
00052
00056 class Port {
00057 protected:
00058 const char* m_conn_string;
00059 struct pollfd* m_pollfd_ptr;
00060 Port(const char* conn_string, struct pollfd* pollfd_ptr);
00061
00062 public:
00063 virtual ~Port();
00064 static Port* create(const char *conn_string, struct pollfd* pollfd_ptr);
00065
00066 virtual ssize_t read(void *buf, size_t count) = 0;
00067 virtual ssize_t write(void *buf, size_t count) = 0;
00068
00069 short poll_revents();
00070 };
00071
00073 class PtyPort: public Port {
00074 private:
00075 const char* m_path;
00076 int m_slavefd;
00077
00078 void _create_pty();
00079 void _respawn_pty();
00080
00081 public:
00082 PtyPort(const char *path, struct pollfd* pollfd_ptr);
00083 virtual ssize_t read(void *buf, size_t count);
00084 virtual ssize_t write(void *buf, size_t count);
00085
00086 virtual ~PtyPort();
00087 };
00088
00091 class SerialPort: public Port {
00092 public:
00093 SerialPort(const char *conn_string, pollfd* pollfd_ptr);
00094 virtual ssize_t read(void *buf, size_t count);
00095 virtual ssize_t write(void *buf, size_t count);
00096
00097 virtual ~SerialPort();
00098 };
00099
00101 class PortException {
00102 public:
00103 const char* conn_str;
00104 const char* message;
00105 PortException(const char* con, const char* msg);
00106 };
00107
00108 #endif // VSERIAL_PORT_H