/[H7]/branches/linux-serial/server/main.cpp
ViewVC logotype

Contents of /branches/linux-serial/server/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 60 - (show annotations) (download)
Mon Feb 5 20:34:51 2007 UTC (17 years, 3 months ago) by torben
File size: 724 byte(s)
Beginning of a linux H7 server


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 }

  ViewVC Help
Powered by ViewVC 1.1.20