22 #include "goby/acomms/connect.h" 23 #include "goby/acomms/queue.h" 24 #include "goby/common/logger.h" 25 #include "goby/util/binary.h" 30 using goby::acomms::operator<<;
33 const int MY_MODEM_ID = 1;
34 const unsigned TEST_MESSAGE_SIZE = 3;
36 int receive_count = 0;
42 int main(
int argc,
char* argv[])
48 cfg.set_modem_id(MY_MODEM_ID);
50 q_entry->set_protobuf_name(
"GobyMessage");
52 dest_role->set_type(goby::acomms::protobuf::QueuedMessageEntry::DESTINATION_ID);
53 dest_role->set_field(
"dest");
55 q_entry->set_ack(
false);
64 test_msg1.set_dest(0);
65 test_msg1.set_telegram(1);
66 std::cout <<
"Pushed: " << test_msg1 << std::endl;
70 msg.set_max_frame_bytes(32);
74 assert(msg.frame(0).size() == TEST_MESSAGE_SIZE);
78 assert(receive_count == 1);
82 cfg.mutable_message_entry(0)->clear_manipulator();
83 cfg.mutable_message_entry(0)->add_manipulator(goby::acomms::protobuf::NO_DECODE);
88 msg.set_max_frame_bytes(32);
91 assert(msg.frame(0).size() == TEST_MESSAGE_SIZE);
94 assert(receive_count == 0);
99 cfg.mutable_message_entry(0)->clear_manipulator();
100 cfg.mutable_message_entry(0)->add_manipulator(goby::acomms::protobuf::NO_QUEUE);
105 msg.set_max_frame_bytes(32);
108 assert(msg.frame(0).size() == 0);
111 assert(receive_count == 0);
116 cfg.mutable_message_entry(0)->clear_manipulator();
117 cfg.mutable_message_entry(0)->add_manipulator(goby::acomms::protobuf::LOOPBACK);
122 assert(receive_count == 1);
125 msg.set_max_frame_bytes(32);
128 assert(msg.frame(0).size() == TEST_MESSAGE_SIZE);
131 assert(receive_count == 2);
136 cfg.mutable_message_entry(0)->clear_manipulator();
137 cfg.mutable_message_entry(0)->add_manipulator(goby::acomms::protobuf::LOOPBACK_AS_SENT);
142 assert(receive_count == 0);
145 msg.set_max_frame_bytes(32);
149 assert(receive_count == 1);
152 assert(msg.frame(0).size() == TEST_MESSAGE_SIZE);
155 assert(receive_count == 2);
159 test_msg1.set_dest(3);
162 cfg.mutable_message_entry(0)->clear_manipulator();
168 msg.set_max_frame_bytes(32);
172 assert(msg.frame(0).size() == TEST_MESSAGE_SIZE);
175 assert(receive_count == 0);
178 cfg.mutable_message_entry(0)->clear_manipulator();
179 cfg.mutable_message_entry(0)->add_manipulator(goby::acomms::protobuf::PROMISCUOUS);
185 msg.set_max_frame_bytes(32);
189 assert(msg.frame(0).size() == TEST_MESSAGE_SIZE);
192 assert(receive_count == 1);
195 std::cout <<
"all tests passed" << std::endl;
202 std::cout <<
"Received: " << in_msg << std::endl;
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.
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.
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...
boost::signals2::signal< void(protobuf::QueueSize size)> signal_queue_size_change
Signals when any queue changes size (message is popped or pushed)
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)