Goby v2
test.cpp
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 //
5 //
6 // This file is part of the Goby Underwater Autonomy Project Binaries
7 // ("The Goby Binaries").
8 //
9 // The Goby Binaries are free software: you can redistribute them and/or modify
10 // them under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // The Goby Binaries are distributed in the hope that they will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
21 
22 // tests functionality of the Iridium Driver
23 
24 #include "../../acomms/driver_tester/driver_tester.h"
25 #include "goby/acomms/modemdriver/iridium_driver.h"
26 
27 boost::shared_ptr<goby::acomms::ModemDriverBase> driver1, driver2;
28 
29 int main(int argc, char* argv[])
30 {
31  goby::glog.add_stream(goby::common::logger::DEBUG3, &std::clog);
32  std::ofstream fout;
33 
34  if (argc == 2)
35  {
36  fout.open(argv[1]);
37  goby::glog.add_stream(goby::common::logger::DEBUG3, &fout);
38  }
39 
40  goby::glog.set_name(argv[0]);
41 
42  driver1.reset(new goby::acomms::IridiumDriver);
43  driver2.reset(new goby::acomms::IridiumDriver);
44 
45  goby::acomms::protobuf::DriverConfig glider_cfg, shore_cfg;
46 
47  // at-duck1
48  glider_cfg.set_modem_id(1);
49  glider_cfg.set_connection_type(goby::acomms::protobuf::DriverConfig::CONNECTION_TCP_AS_CLIENT);
50  glider_cfg.set_tcp_server("127.0.0.1");
51  glider_cfg.set_reconnect_interval(1);
52  glider_cfg.set_tcp_port(4001);
53  IridiumDriverConfig::Remote* shore = glider_cfg.MutableExtension(IridiumDriverConfig::remote);
54  shore->set_iridium_number("6001");
55  shore->set_modem_id(2);
56  glider_cfg.AddExtension(IridiumDriverConfig::config, "+GSN");
57 
58  // at-duck2
59  shore_cfg.set_modem_id(2);
60  shore_cfg.set_connection_type(goby::acomms::protobuf::DriverConfig::CONNECTION_TCP_AS_CLIENT);
61  shore_cfg.set_tcp_server("127.0.0.1");
62  shore_cfg.set_reconnect_interval(1);
63  shore_cfg.set_tcp_port(4002);
64  IridiumDriverConfig::Remote* gumstix = shore_cfg.MutableExtension(IridiumDriverConfig::remote);
65  gumstix->set_iridium_number("6001");
66  gumstix->set_modem_id(2);
67  // shore_cfg.AddExtension(IridiumDriverConfig::config, "+GSN");
68 
69  // shore
70  // {
71  // shore_cfg.set_modem_id(2);
72  // shore_cfg.set_connection_type(goby::acomms::protobuf::DriverConfig::CONNECTION_TCP_AS_CLIENT);
73  // shore_cfg.set_tcp_server("rudics.whoi.edu");
74  // shore_cfg.set_tcp_port(54321);
75  // IridiumDriverConfig::Remote* remote =
76  // shore_cfg.MutableExtension(IridiumDriverConfig::remote);
77  // remote->set_modem_id(1);
78  // remote->set_iridium_number("i881693783740");
79  // shore_cfg.AddExtension(IridiumDriverConfig::config, "s29=8");
80  // shore_cfg.AddExtension(IridiumDriverConfig::config, "s57=9600");
81  // }
82 
83  // // gumstix
84  // {
85  // glider_cfg.set_modem_id(1);
86  // glider_cfg.set_connection_type(goby::acomms::protobuf::DriverConfig::CONNECTION_SERIAL);
87  // glider_cfg.set_serial_port("/dev/ttyUSB0");
88  // glider_cfg.set_serial_baud(9600);
89  // IridiumDriverConfig::Remote* remote =
90  // glider_cfg.MutableExtension(IridiumDriverConfig::remote);
91  // remote->set_iridium_number("i00881600005141");
92  // remote->set_modem_id(2);
93  // glider_cfg.AddExtension(IridiumDriverConfig::config, "+IPR=5,0");
94  // glider_cfg.AddExtension(IridiumDriverConfig::config, "+CGSN");
95  // glider_cfg.AddExtension(IridiumDriverConfig::config, "+CGMM");
96  // glider_cfg.AddExtension(IridiumDriverConfig::config, "+CGMI");
97  // glider_cfg.AddExtension(IridiumDriverConfig::config, "Q0"); // quiet mode off
98  // glider_cfg.AddExtension(IridiumDriverConfig::config, "&D2"); // DTR low hangs up
99  // glider_cfg.AddExtension(IridiumDriverConfig::config, "&C1"); // DCD indicates state of connection
100  // }
101 
102  std::vector<int> tests_to_run;
103  tests_to_run.push_back(4);
104  tests_to_run.push_back(5);
105 
106  DriverTester tester(driver1, driver2, glider_cfg, shore_cfg, tests_to_run,
107  goby::acomms::protobuf::DRIVER_IRIDIUM);
108  return tester.run();
109 }
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
Definition: flex_ostream.h:67
common::FlexOstream glog
Access the Goby logger through this object.
void add_stream(logger::Verbosity verbosity=logger::VERBOSE, std::ostream *os=0)
Attach a stream object (e.g. std::cout, std::ofstream, ...) to the logger with desired verbosity...
Definition: flex_ostream.h:96