22 #include "goby/acomms/acomms_helpers.h" 23 #include "goby/acomms/dccl.h" 24 #include "goby/util/binary.h" 26 #include "two_message.pb.h" 31 using goby::acomms::operator<<;
38 dccl.validate<GoToCommand>();
39 dccl.validate<VehicleStatus>();
42 std::cout << dccl << std::endl;
44 std::cout <<
"ENCODE / DECODE example:" << std::endl;
47 command.set_destination(2);
48 command.set_goto_x(423);
49 command.set_goto_y(523);
50 command.set_lights_on(
true);
51 command.set_new_instructions(
"make_toast");
52 command.set_goto_speed(2.3456);
55 status.set_nav_x(234.5);
56 status.set_nav_y(451.3);
57 status.set_health(VehicleStatus::HEALTH_ABORT);
59 std::cout <<
"passing values to encoder:\n" << command <<
"\n" << status << std::endl;
61 std::string bytes2, bytes3;
62 dccl.encode(&bytes2, command);
63 dccl.encode(&bytes3, status);
65 std::cout <<
"received hexadecimal string for message 2 (GoToCommand): " 66 << goby::util::hex_encode(bytes2) << std::endl;
68 std::cout <<
"received hexadecimal string for message 3 (VehicleStatus): " 69 << goby::util::hex_encode(bytes3) << std::endl;
74 std::cout <<
"passed hexadecimal string for message 2 to decoder: " 75 << goby::util::hex_encode(bytes2) << std::endl;
77 std::cout <<
"passed hexadecimal string for message 3 to decoder: " 78 << goby::util::hex_encode(bytes3) << std::endl;
80 dccl.decode(bytes2, &command);
81 dccl.decode(bytes3, &status);
83 std::cout <<
"received values:\n" << command <<
"\n" << status << std::endl;
static DCCLCodec * get()
DCCLCodec is a singleton class; use this to get a pointer to the class.
The global namespace for the Goby project.