simple.proto
import "dccl/option_extensions.proto";
message Simple
{
// see http://gobysoft.org/wiki/DcclIdTable
option (dccl.msg).id = 124;
// if, for example, we want to use on the WHOI Micro-Modem rate 0
option (dccl.msg).max_bytes = 32;
required string telegram = 1 [(dccl.field).max_length = 30];
}
queue_simple.cpp
#include "goby/acomms/connect.h"
#include "goby/acomms/queue.h"
#include "goby/util/binary.h"
#include "simple.pb.h"
#include <iostream>
using goby::acomms::operator<<;
int main()
{
const int our_id = 1;
cfg.
set_modem_id(our_id);
cfg.
add_message_entry()->set_protobuf_name(
"Simple");
Simple msg;
msg.set_telegram("hello all!");
std::cout << "1. pushing message to queue 1: " << msg << std::endl;
std::cout << "2. " << q_manager << std::endl;
std::cout
<< "3. executing loopback (simulating sending a message to ourselves over the modem link)"
<< std::endl;
request_msg.
set_max_frame_bytes(32);
request_msg.
set_max_num_frames(1);
std::cout << "4. requesting data, got: " << request_msg << std::endl;
std::cout <<
"\tdata as hex: " << goby::util::hex_encode(request_msg.
frame(0)) << std::endl;
return 0;
}
{
std::cout << "5. received message: " << msg << std::endl;
}