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 Benthos ATM 900 Driver
23 
24 #include "../../acomms/driver_tester/driver_tester.h"
25 #include "goby/acomms/modemdriver/benthos_atm900_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::BenthosATM900Driver);
43  driver2.reset(new goby::acomms::BenthosATM900Driver);
44 
45  goby::acomms::protobuf::DriverConfig modem1_cfg, modem2_cfg;
46 
47  modem1_cfg.set_modem_id(1);
48  modem2_cfg.set_modem_id(2);
49 
50  modem1_cfg.set_serial_port("/dev/ttyUSB0");
51  modem2_cfg.set_serial_port("/dev/ttyUSB1");
52 
53  // add some simulated delay
54  modem1_cfg.AddExtension(benthos::protobuf::BenthosATM900DriverConfig::config, "@SimAcDly=1000");
55  modem2_cfg.AddExtension(benthos::protobuf::BenthosATM900DriverConfig::config, "@SimAcDly=1000");
56 
57  // turn down TxPower to minimum
58  modem1_cfg.AddExtension(benthos::protobuf::BenthosATM900DriverConfig::config, "@TxPower=1");
59  modem2_cfg.AddExtension(benthos::protobuf::BenthosATM900DriverConfig::config, "@TxPower=1");
60 
61  // go to lowpower quickly to test this
62  modem1_cfg.AddExtension(benthos::protobuf::BenthosATM900DriverConfig::config,
63  "@IdleTimer=00:00:05");
64  modem2_cfg.AddExtension(benthos::protobuf::BenthosATM900DriverConfig::config,
65  "@IdleTimer=00:00:05");
66 
67  std::vector<int> tests_to_run;
68  tests_to_run.push_back(0);
69  tests_to_run.push_back(4);
70  tests_to_run.push_back(5);
71 
72  DriverTester tester(driver1, driver2, modem1_cfg, modem2_cfg, tests_to_run,
73  goby::acomms::protobuf::DRIVER_BENTHOS_ATM900);
74  return tester.run();
75 }
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