22 #include "goby/acomms/acomms_constants.h" 23 #include "goby/acomms/connect.h" 24 #include "goby/acomms/queue.h" 25 #include "goby/common/logger.h" 26 #include "goby/util/binary.h" 31 using goby::acomms::operator<<;
33 int receive_count = 0;
38 int main(
int argc,
char* argv[])
45 const int MY_MODEM_ID = 1;
46 cfg.set_modem_id(MY_MODEM_ID);
47 cfg.add_message_entry()->set_protobuf_name(
"TestMsg");
53 test_msg1.set_double_default_optional(1.23);
54 test_msg1.set_float_default_optional(0.2);
56 std::cout <<
"Pushed: " << test_msg1 << std::endl;
60 msg.set_max_frame_bytes(256);
63 std::cout <<
"requesting data, got: " << msg << std::endl;
64 std::cout <<
"\tdata as hex: " << goby::util::hex_encode(msg.frame(0)) << std::endl;
69 assert(msg.frame(0) == encoded);
70 assert(msg.src() == MY_MODEM_ID);
73 assert(msg.ack_requested() ==
false);
78 assert(receive_count == 1);
80 std::cout <<
"all tests passed" << std::endl;
85 std::cout <<
"Received: " << msg << std::endl;
87 assert(test_msg1.SerializeAsString() == msg.SerializeAsString());
provides an API to the goby-acomms Queuing Library.
void set_name(const std::string &s)
Set the name of the application that the logger is serving.
static DCCLCodec * get()
DCCLCodec is a singleton class; use this to get a pointer to the class.
boost::signals2::signal< void(const google::protobuf::Message &msg)> signal_receive
Signals when a DCCL message is received.
void handle_modem_data_request(protobuf::ModemTransmission *msg)
Finds data to send to the modem.
void handle_modem_receive(const protobuf::ModemTransmission &message)
Receive incoming data from the modem.
const int BROADCAST_ID
special modem id for the broadcast destination - no one is assigned this address. Analogous to 192...
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.
void set_cfg(const protobuf::QueueManagerConfig &cfg)
Set (and overwrite completely if present) the current configuration. (protobuf::QueueManagerConfig de...
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...
void push_message(const google::protobuf::Message &new_message)
Push a message (and add the queue if it does not exist)