/[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 67 - (show annotations) (download)
Tue Feb 6 23:37:39 2007 UTC (17 years, 3 months ago) by torben
File size: 1136 byte(s)
Added some more of the H7 linux server - now it basically works :)


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 #include "serverthread.h"
10
11 #include "globalstorage.h"
12
13 void my_pause()
14 {
15 char d[1];
16 std::cout << "Press enter to continue" << std::endl;
17 std::cin.getline(d,1);
18 }
19
20 int main(int argc, char* argv[])
21 {
22 CH7Serial& serialPort = GlobalStorage::instance()->serialPort;
23
24 SerialThread& serial = GlobalStorage::instance()->serialThread;
25 ServerThread server;
26 // GlobalStorage::instance()->serialThread = &serial;
27
28 try
29 {
30 serialPort.open("/dev/ttyS0", CSerial::Baud9600);
31 }
32 catch(std::exception&e )
33 {
34 std::cout << "Error opening serial port : " << e.what() << std::endl;
35 exit(1);
36 }
37
38 try
39 {
40 GlobalStorage::instance()->server.start(9000); //listen on port 9000
41 }
42 catch(...)
43 {
44 std::cout << "Could not listen on port 9000" << std::endl;
45 serialPort.close();
46 exit(2);
47 }
48
49
50
51 boost::thread serialThread(serial);
52 boost::thread serverThread(server);
53
54 my_pause();
55
56 serial.stop();
57 server.stop();
58 while(!serial.stopped() && !server.stopped() )
59 usleep(10000);
60 }

  ViewVC Help
Powered by ViewVC 1.1.20