| | |
| | | #ifndef __TeleWrapper_H__
|
| | | #define __TeleWrapper_H__
|
| | |
|
| | | #include <thread>
|
| | | #include <queue>
|
| | | #include <pthread.h>
|
| | | #include <unistd.h> |
| | | #include <stdlib.h> |
| | | #include "serial.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;
|
| | | enum Tel
|
| | | {
|
| | | CALL,
|
| | | HANGUP
|
| | | };
|
| | | Tel command;
|
| | | std::string param;
|
| | | // string param;
|
| | | }TeleTask;
|
| | |
|
| | | class TeleWrapper
|
| | | {
|
| | | public:
|
| | | TeleWrapper() {}
|
| | | ~TeleWrapper() {}
|
| | | TeleWrapper() {}
|
| | | ~TeleWrapper() {}
|
| | |
|
| | | bool start();
|
| | | void stop();
|
| | | void pushTask(TeleTask task);
|
| | | void popTask();
|
| | | |
| | | |
| | | void call(std::string phone);
|
| | | void hang();
|
| | | bool start();
|
| | | void stop();
|
| | | // void pause();
|
| | | void pushTask(TeleTask task);
|
| | | void popTask();
|
| | |
|
| | | pthread_t tel_thid;
|
| | | bool running;
|
| | |
|
| | | 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) ;
|
| | |
|
| | | 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);
|
| | | void callNum(char phone);
|
| | | void callNum(const std::string phone);
|
| | |
|
| | | };
|
| | |
|
| | |
|
| | |
|
| | | #endif |
| | | #endif
|