]> git.mxchange.org Git - simgear.git/blob - simgear/serial/testserial.cxx
Patch from Melchior Franz:
[simgear.git] / simgear / serial / testserial.cxx
1 #include <simgear/compiler.h>
2
3 #include STL_STRING
4 #include STL_IOSTREAM
5
6 #include <simgear/debug/logstream.hxx>
7
8 #include "serial.hxx"
9
10 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
11 SG_USING_STD(cout);
12 SG_USING_STD(endl);
13 #endif
14
15
16 int main () {
17     FGSerialPort port;
18     string value;
19     bool result;
20
21     sglog().setLogLevels( SG_ALL, SG_INFO );
22
23     cout << "start of main" << endl;
24
25     result = port.open_port("/dev/ttyS1");
26     cout << "opened port, result = " << result << endl;
27
28     result = port.set_baud(4800);
29     cout << "set baud, result = " << result << endl;
30
31     port.write_port("ATDT 626-9800\n");
32
33     while ( true ) {
34         value = port.read_port();
35         if ( value.length() ) {
36             cout << "-> " << value << endl;
37         }
38     }
39
40     return 0;
41 }