houxiao
2017-07-20 cf0afe7a787dfed444a418dc0a224a49160108c1
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
64
65
66
#ifndef __TeleWrapper_H__
#define __TeleWrapper_H__
 
#include <queue>
#include <pthread.h>
#include <unistd.h>  
#include <stdlib.h> 
#include "serial.h"
 
 
#define PORT  "/dev/ttyS4"
#define  BAUD 2400
 
 
typedef struct TeleTask
{
    enum Tel
    {
        CALL,
        HANGUP
    };
    Tel command;
    std::string param;
}TeleTask;
 
class TeleWrapper
{
public:
    TeleWrapper() {}
    ~TeleWrapper() {}
 
    bool start();
    void stop();
    void pushTask(TeleTask task);
    void popTask();
    
    
  void call(std::string phone);
  void hang();
 
    pthread_t tel_thid;
  bool running;
private:
 
  int  fd =-1;
  
    std::queue<TeleTask> telQueue;
    void *tel_thd(void *arg) ;
 
  bool pthread_pause = false;  
  
  pthread_cond_t cond_pause = PTHREAD_COND_INITIALIZER;  
  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  
  void thread_pause();
  void thread_resume();
  
  
 
 void callNum(  char phone);
 
};
 
 
 
#endif