25 #ifndef GOBY_ACOMMS_MODEMDRIVER_BENTHOS_ATM900_DRIVER_H
26 #define GOBY_ACOMMS_MODEMDRIVER_BENTHOS_ATM900_DRIVER_H
28 #include <boost/algorithm/string/classification.hpp>
29 #include <boost/algorithm/string/constants.hpp>
30 #include <boost/algorithm/string/split.hpp>
31 #include <boost/any.hpp>
33 #include <dccl/bitset.h>
34 #include <dccl/codec.h>
35 #include <dccl/common.h>
36 #include <dccl/exception.h>
37 #include <dccl/field_codec_fixed.h>
38 #include <dccl/field_codec_manager.h>
39 #include <dccl/version.h>
60 void startup(
const protobuf::DriverConfig& cfg)
override;
66 void receive(
const protobuf::ModemTransmission&
msg);
67 void send(
const protobuf::ModemTransmission&
msg);
70 const benthos::protobuf::Config& benthos_driver_cfg()
const
80 static const std::string SERIAL_DELIMITER;
82 benthos::fsm::BenthosATM900FSM fsm_;
83 protobuf::DriverConfig driver_cfg_;
92 unsigned size()
override {
return 0; }
99 auto benthos_id_name =
"benthos_header_id";
100 #ifdef DCCL_VERSION_4_1_OR_NEWER
103 dccl::FieldCodecManager::add<NoOpIdentifierCodec>(benthos_id_name);
111 const goby::acomms::protobuf::ModemTransmission& in)
113 benthos::protobuf::BenthosHeader header;
114 header.set_type(in.type());
115 if (in.has_ack_requested())
116 header.set_ack_requested(in.ack_requested());
118 for (
int i = 0, n = in.acked_frame_size(); i < n; ++i)
119 header.add_acked_frame(in.acked_frame(i));
124 for (
int i = 0, n = in.frame_size(); i < n; ++i)
126 if (in.frame(i).empty())
129 std::string rudics_packet;
131 *out += rudics_packet;
136 goby::acomms::protobuf::ModemTransmission* out)
138 benthos::protobuf::BenthosHeader header;
141 out->set_type(header.type());
142 if (header.has_ack_requested())
143 out->set_ack_requested(header.ack_requested());
145 for (
int i = 0, n = header.acked_frame_size(); i < n; ++i)
146 out->add_acked_frame(header.acked_frame(i));
148 std::vector<std::string> encoded_frames;
149 boost::split(encoded_frames, in, boost::is_any_of(
"\r"), boost::token_compress_on);
151 for (
auto& encoded_frame : encoded_frames)
153 if (!encoded_frame.empty())
void do_work() override
Allows the modem driver to do its work.
void shutdown() override
Shuts down the modem driver.
void handle_initiate_transmission(const protobuf::ModemTransmission &m) override
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
void startup(const protobuf::DriverConfig &cfg) override
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...
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::goby::acomms::protobuf::DriverConfig, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::acomms::benthos::protobuf::Config >, 11, false > config
void serialize_benthos_modem_message(std::string *out, const goby::acomms::protobuf::ModemTransmission &in)
void parse_benthos_modem_message(std::string in, goby::acomms::protobuf::ModemTransmission *out)
void parse_rudics_packet(std::string *bytes, std::string rudics_pkt, const std::string &reserved=std::string("\0\r\n", 3)+std::string(1, 0xff), bool include_crc=true)
void serialize_rudics_packet(std::string bytes, std::string *rudics_pkt, const std::string &reserved=std::string("\0\r\n", 3)+std::string(1, 0xff), bool include_crc=true)
std::shared_ptr< dccl::Codec > benthos_header_dccl_
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
void split(const char *b, const char *e, char d, std::function< void(const char *, const char *)> fn)