blob: 7ea44a39bbca7f8e83f00f575a40e1f7021298f2 (
plain)
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
|
// -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*-
// ***** BEGIN LICENSE BLOCK *****
////////////////////////////////////////////////////////////////////
// Copyright (c) 2011-2013 RALOVICH, Kristóf //
// //
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the GNU General Public License //
// version 2 as published by the Free Software Foundation. //
// //
////////////////////////////////////////////////////////////////////
// ***** END LICENSE BLOCK *****
#pragma once
//#include <pthread.h>
#include <queue>
#include <boost/thread.hpp>
#include "antdefs.hpp"
#include "lqueue.hpp"
#include <list>
#include "Serial.hpp"
namespace antpm{
struct SerialTtyPrivate;
struct SerialTtyIOThread;
// Serial communication over a POSIX serial port.
class SerialTty : public Serial
{
public:
SerialTty();
virtual ~SerialTty();
virtual bool open();
virtual void close();
//virtual bool read(char& c);
virtual bool read(char* dst, const size_t sizeBytes, size_t& bytesRead);
virtual bool readBlocking(char* dst, const size_t sizeBytes, size_t& bytesRead);
virtual bool write(const char* src, const size_t sizeBytes, size_t& bytesWritten);
//virtual void wait();
private:
friend struct SerialTtyIOThread;
void* ioHandler();
public:
virtual const size_t getQueueLength() const;
virtual const char* getImplName() { return "AntTtyHandler2"; }
virtual bool isOpen() const;
private:
void queueData();
private:
std::auto_ptr<SerialTtyPrivate> m_p;
};
}
|