24 #include "goby/acomms/dccl.h" 25 #include "goby/common/time.h" 26 #include "goby/util/as.h" 27 #include "goby/util/binary.h" 30 using goby::acomms::operator<<;
32 int main(
int argc,
char* argv[])
43 msg_in1.set_telegram(
"hello!");
44 msg_in1.mutable_header()->set_time(
45 goby::util::as<goby::uint64>(boost::posix_time::second_clock::universal_time()));
46 msg_in1.mutable_header()->set_source_platform(1);
47 msg_in1.mutable_header()->set_dest_platform(3);
48 msg_in1.mutable_header()->set_dest_type(Header::PUBLISH_OTHER);
50 codec->info(msg_in1.GetDescriptor(), &std::cout);
51 std::cout <<
"Message in:\n" << msg_in1.DebugString() << std::endl;
52 codec->validate(msg_in1.GetDescriptor());
53 std::cout <<
"Try encode..." << std::endl;
55 codec->encode(&bytes1, msg_in1);
56 std::cout <<
"... got bytes (hex): " << goby::util::hex_encode(bytes1) << std::endl;
59 bytes1 += std::string(10,
'\0');
61 std::cout <<
"Try decode..." << std::endl;
64 std::cout <<
"... got Message out:\n" << msg_out1->DebugString() << std::endl;
65 assert(msg_in1.SerializeAsString() == msg_out1->SerializeAsString());
68 std::cout <<
"all tests passed" << std::endl;
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.
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...