37 #include "goby/acomms/connect.h" 38 #include "goby/acomms/modem_driver.h" 39 #include "goby/common/logger.h" 40 #include "goby/util/binary.h" 44 using goby::acomms::operator<<;
48 int main(
int argc,
char* argv[])
52 std::cout <<
"usage: driver_simple /dev/tty_of_modem modem_id [type: MMDriver " 53 "(default)|ABCDriver]" 65 cfg.set_serial_port(argv[1]);
66 using google::protobuf::uint32;
68 uint32 our_id = goby::util::as<uint32>(argv[2]);
69 cfg.set_modem_id(our_id);
76 if (boost::iequals(argv[3],
"ABCDriver"))
78 std::cout <<
"Starting Example driver ABCDriver" << std::endl;
86 std::cout <<
"Starting WHOI Micro-Modem MMDriver" << std::endl;
90 cfg.AddExtension(micromodem::protobuf::Config::nvram_cfg,
"DQF,1");
105 transmit_message.set_type(goby::acomms::protobuf::ModemTransmission::DATA);
106 transmit_message.set_src(goby::util::as<unsigned>(our_id));
108 transmit_message.set_rate(0);
110 transmit_message.add_frame(
"Hello, world!");
111 transmit_message.set_ack_requested(
false);
113 std::cout << transmit_message << std::endl;
146 std::cout <<
"got a message: " << data_msg << std::endl;
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
virtual void startup(const protobuf::DriverConfig &cfg)=0
Starts the modem driver. Must be called before poll().
virtual void do_work()=0
Allows the modem driver to do its work.
provides an API to the imaginary ABC modem (as an example how to write drivers)
google::protobuf::uint32 uint32
an unsigned 32 bit integer
provides an API to the WHOI Micro-Modem driver
boost::signals2::signal< void(const protobuf::ModemTransmission &message)> signal_receive
Called when a binary data transmission is received from the modem.
const int BROADCAST_ID
special modem id for the broadcast destination - no one is assigned this address. Analogous to 192...
virtual void handle_initiate_transmission(const protobuf::ModemTransmission &m)=0
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
void connect(Signal *signal, Slot slot)
connect a signal to a slot (e.g. function pointer)
common::FlexOstream glog
Access the Goby logger through this object.
provides an abstract base class for acoustic modem drivers. This is subclassed by the various drivers...
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...