23 #ifndef BenthosATM900Driver20161221H 24 #define BenthosATM900Driver20161221H 26 #include <dccl/codec.h> 27 #include <dccl/field_codec_fixed.h> 28 #include <dccl/field_codec_manager.h> 30 #include "goby/common/time.h" 32 #include "benthos_atm900_driver_fsm.h" 33 #include "driver_base.h" 34 #include "goby/acomms/acomms_helpers.h" 35 #include "goby/acomms/protobuf/benthos_atm900.pb.h" 36 #include "rudics_packet.h" 61 static const std::string SERIAL_DELIMITER;
71 dccl::Bitset encode() {
return dccl::Bitset(); }
72 dccl::Bitset encode(
const uint32& wire_value) {
return dccl::Bitset(); }
73 dccl::uint32 decode(dccl::Bitset* bits) {
return 0; }
74 virtual unsigned size() {
return 0; }
77 extern boost::shared_ptr<dccl::Codec> benthos_header_dccl_;
79 inline void init_benthos_dccl()
81 dccl::FieldCodecManager::add<NoOpIdentifierCodec>(
"benthos_header_id");
82 benthos_header_dccl_.reset(
new dccl::Codec(
"benthos_header_id"));
86 inline void serialize_benthos_modem_message(std::string* out,
90 header.set_type(in.type());
91 if (in.has_ack_requested())
92 header.set_ack_requested(in.ack_requested());
94 for (
int i = 0, n = in.acked_frame_size(); i < n; ++i)
95 header.add_acked_frame(in.acked_frame(i));
97 benthos_header_dccl_->encode(out, header);
100 for (
int i = 0, n = in.frame_size(); i < n; ++i)
102 if (in.frame(i).empty())
105 std::string rudics_packet;
106 serialize_rudics_packet(in.frame(i), &rudics_packet,
"\r",
false);
107 *out += rudics_packet;
111 inline void parse_benthos_modem_message(std::string in,
115 benthos_header_dccl_->decode(&in, &header);
117 out->set_type(header.type());
118 if (header.has_ack_requested())
119 out->set_ack_requested(header.ack_requested());
121 for (
int i = 0, n = header.acked_frame_size(); i < n; ++i)
122 out->add_acked_frame(header.acked_frame(i));
124 std::vector<std::string> encoded_frames;
125 boost::split(encoded_frames, in, boost::is_any_of(
"\r"), boost::token_compress_on);
127 for (
int i = 0, n = encoded_frames.size(); i < n; ++i)
129 if (!encoded_frames[i].empty())
130 parse_rudics_packet(out->add_frame(), encoded_frames[i] +
"\r",
"\r",
false);
void shutdown()
Shuts down the modem driver.
void handle_initiate_transmission(const protobuf::ModemTransmission &m)
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
google::protobuf::uint32 uint32
an unsigned 32 bit integer
void do_work()
Allows the modem driver to do its work.
The global namespace for the Goby project.
void startup(const protobuf::DriverConfig &cfg)
Starts the modem driver. Must be called before poll().
provides an abstract base class for acoustic modem drivers. This is subclassed by the various drivers...