houxiao
2017-08-17 2b43077d967c28fe99e1ff2b99f19e1433c710d9
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
#ifndef __TeleWrapper_H__
#define __TeleWrapper_H__
 
#include <thread>
#include <queue>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <string>
 
 
#define PORT  "/dev/ttyS4"
#define  BAUD 2400
 
 
typedef struct TeleTask
{
    enum Tel
    {
        CALL,
        HANGUP
    };
    Tel command;
    std::string param;
    //  string param;
}TeleTask;
 
class TeleWrapper
{
public:
    TeleWrapper() {}
    ~TeleWrapper() {}
 
    bool start();
    void stop();
  //  void pause();
    void pushTask(TeleTask task);
    void popTask();
 
 
    void call(std::string phone);
    void hang();
 
    pthread_t tel_thid;
    bool running;
 
    std::queue<TeleTask> telQueue;
 
    //不安全
    pthread_mutex_t mutex;
    pthread_cond_t cond;
private:
    int  fd =-1;
    //static
    static void *tel_thd(void *arg) ;
 
 
    void callNum(char phone);
    void callNum(const std::string phone);
 
};
 
#endif