1 |
#include <iostream> |
2 |
#include <string> |
3 |
|
4 |
#include <boost/thread/thread.hpp> |
5 |
#include <boost/thread/mutex.hpp> |
6 |
|
7 |
#include "../H7Serial.h" |
8 |
#include "serialthread.h" |
9 |
|
10 |
|
11 |
void my_pause() |
12 |
{ |
13 |
char d[1]; |
14 |
std::cout << "Press enter to continue" << std::endl; |
15 |
std::cin.getline(d,1); |
16 |
} |
17 |
|
18 |
int main(int argc, char* argv[]) |
19 |
{ |
20 |
CH7Serial serial; |
21 |
boost::mutex writeMutex; |
22 |
try |
23 |
{ |
24 |
serial.open("/dev/ttyS0", CSerial::Baud9600); |
25 |
} |
26 |
catch(std::exception&e ) |
27 |
{ |
28 |
std::cout << "Error opening serial port : " << e.what() << std::endl; |
29 |
} |
30 |
|
31 |
SerialThread serialThreadFunction(serial, writeMutex); |
32 |
boost::thread serialT(serialThreadFunction); |
33 |
|
34 |
my_pause(); |
35 |
|
36 |
serialThreadFunction.stop(); |
37 |
while(!serialThreadFunction.stopped()) |
38 |
usleep(10000); |
39 |
} |