Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches

provides an API to the imaginary ABC modem (as an example how to write drivers) More...

#include <goby/acomms/modemdriver/janus_driver.h>

Inheritance diagram for goby::acomms::JanusDriver:
goby::acomms::ModemDriverBase

Public Member Functions

 JanusDriver ()
 
 ~JanusDriver () override
 
void startup (const protobuf::DriverConfig &cfg) override
 Starts the modem driver. Must be called before poll().
 
void shutdown () override
 Shuts down the modem driver.
 
void do_work () override
 Allows the modem driver to do its work.
 
void handle_initiate_transmission (const protobuf::ModemTransmission &m) override
 Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission() using bind().
 
void handle_ack_transmission (const protobuf::ModemTransmission &m)
 
void pad_message (std::vector< uint8_t > &vec)
 
void send_janus_packet (const protobuf::ModemTransmission &msg, std::vector< std::uint8_t > payload, bool ack=false)
 
void append_crc16 (std::vector< std::uint8_t > &vec)
 
void to_modem_transmission (janus_rx_msg_pkt packet, protobuf::ModemTransmission &msg)
 
void send_janus_packet_thread (const protobuf::ModemTransmission &msg, std::vector< std::uint8_t > payload, bool ack)
 
void send_ack (unsigned int src, unsigned int dest, unsigned int frame_number)
 
void DecodeGobyHeader (std::uint8_t header, protobuf::ModemTransmission &m)
 
std::uint8_t get_goby_header (const protobuf::ModemTransmission &msg)
 
std::uint8_t CreateGobyHeader (const protobuf::ModemTransmission &m)
 
janus_rx_msg_pkt parse_janus_packet (const janus_packet_t pkt, bool verbosity)
 
unsigned int get_frame_num (std::string cargo)
 
janus_simple_tx_t init_janus_tx ()
 
janus_simple_rx_t init_janus_rx ()
 
janus_parameters_t get_janus_params (const janus::protobuf::Config &config)
 
- Public Member Functions inherited from goby::acomms::ModemDriverBase
virtual void update_cfg (const protobuf::DriverConfig &cfg)
 Update configuration while running (not required to be implemented)
 
virtual ~ModemDriverBase ()
 Public Destructor.
 
virtual void report (protobuf::ModemReport *report)
 Returns report including modem availability and signal quality (if known)
 
int driver_order ()
 Integer for the order in which this driver was started (first driver started is 1, second driver is 2, etc.)
 

Public Attributes

janus_parameters_t params_tx
 
janus_parameters_t params_rx
 
unsigned int acomms_id
 
unsigned int tx_application_type
 
unsigned int rx_application_type
 
unsigned int tx_class_id
 
unsigned int rx_class_id
 
std::uint32_t next_frame_ {0}
 
janus_simple_tx_t simple_tx
 
janus_simple_rx_t simple_rx
 
janus_packet_t packet_rx = 0
 
janus_rx_state_t state_rx = 0
 
unsigned queried_detection_time
 
janus_carrier_sensing_t carrier_sensing
 
protobuf::ModemTransmission modem_msg
 
- Public Attributes inherited from goby::acomms::ModemDriverBase
boost::signals2::signal< void(const protobuf::ModemTransmission &message)> signal_receive
 Called when a binary data transmission is received from the modem.
 
boost::signals2::signal< void(const protobuf::ModemTransmission &message)> signal_transmit_result
 Called when a transmission is completed.
 
boost::signals2::signal< void(protobuf::ModemTransmission *msg)> signal_data_request
 Called when the modem or modem driver needs data to send. The returned data should be stored in ModemTransmission::frame.
 
boost::signals2::signal< void(protobuf::ModemTransmission *msg_request)> signal_modify_transmission
 Called before the modem driver begins processing a transmission. This allows a third party to modify the parameters of the transmission (such as destination or rate) on the fly.
 
boost::signals2::signal< void(const protobuf::ModemRaw &msg)> signal_raw_incoming
 Called after any message is received from the modem by the driver. Used by the MACManager for auto-discovery of vehicles. Also useful for higher level analysis and debugging of the transactions between the driver and the modem.
 
boost::signals2::signal< void(const protobuf::ModemRaw &msg)> signal_raw_outgoing
 Called after any message is sent from the driver to the modem. Useful for higher level analysis and debugging of the transactions between the driver and the modem.
 

Static Public Attributes

static constexpr int DEFAULT_MTU_BYTES {1024}
 

Additional Inherited Members

- Static Public Member Functions inherited from goby::acomms::ModemDriverBase
static std::string driver_name (const protobuf::DriverConfig &cfg)
 Unique driver name (e.g. UDP_MULTICAST::1 or my_driver_name::2)
 
- Protected Member Functions inherited from goby::acomms::ModemDriverBase
 ModemDriverBase ()
 Constructor.
 
void modem_write (const std::string &out)
 write a line to the serial port.
 
bool modem_read (std::string *in)
 read a line from the serial port, including end-of-line character(s)
 
void modem_start (const protobuf::DriverConfig &cfg, bool modem_connection_expected=true)
 start the physical connection to the modem (serial port, TCP, etc.). must be called before ModemDriverBase::modem_read() or ModemDriverBase::modem_write()
 
void modem_close ()
 closes the serial port. Use modem_start to reopen the port.
 
const std::string & glog_out_group () const
 
const std::string & glog_in_group () const
 
util::LineBasedInterfacemodem ()
 use for direct access to the modem
 
- Static Protected Attributes inherited from goby::acomms::ModemDriverBase
static std::atomic< int > count_
 

Detailed Description

provides an API to the imaginary ABC modem (as an example how to write drivers)

Definition at line 75 of file janus_driver.h.

Constructor & Destructor Documentation

◆ JanusDriver()

goby::acomms::JanusDriver::JanusDriver ( )

◆ ~JanusDriver()

goby::acomms::JanusDriver::~JanusDriver ( )
override

Member Function Documentation

◆ append_crc16()

void goby::acomms::JanusDriver::append_crc16 ( std::vector< std::uint8_t > &  vec)

◆ CreateGobyHeader()

std::uint8_t goby::acomms::JanusDriver::CreateGobyHeader ( const protobuf::ModemTransmission m)

◆ DecodeGobyHeader()

void goby::acomms::JanusDriver::DecodeGobyHeader ( std::uint8_t  header,
protobuf::ModemTransmission m 
)

◆ do_work()

void goby::acomms::JanusDriver::do_work ( )
overridevirtual

Allows the modem driver to do its work.

Should be called regularly to perform the work of the driver as the driver does not run in its own thread. This allows us to guarantee that no signals are called except inside this method. Does not block.

Implements goby::acomms::ModemDriverBase.

◆ get_frame_num()

unsigned int goby::acomms::JanusDriver::get_frame_num ( std::string  cargo)

◆ get_goby_header()

std::uint8_t goby::acomms::JanusDriver::get_goby_header ( const protobuf::ModemTransmission msg)

◆ get_janus_params()

janus_parameters_t goby::acomms::JanusDriver::get_janus_params ( const janus::protobuf::Config config)

◆ handle_ack_transmission()

void goby::acomms::JanusDriver::handle_ack_transmission ( const protobuf::ModemTransmission m)

◆ handle_initiate_transmission()

void goby::acomms::JanusDriver::handle_initiate_transmission ( const protobuf::ModemTransmission m)
overridevirtual

Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission() using bind().

Parameters
mModemTransmission (defined in acomms_modem_message.proto) containing the details of the transmission to be started. This may contain data frames. If not, data will be requested when the driver calls the data request signal (ModemDriverBase::signal_data_request)

Implements goby::acomms::ModemDriverBase.

◆ init_janus_rx()

janus_simple_rx_t goby::acomms::JanusDriver::init_janus_rx ( )

◆ init_janus_tx()

janus_simple_tx_t goby::acomms::JanusDriver::init_janus_tx ( )

◆ pad_message()

void goby::acomms::JanusDriver::pad_message ( std::vector< uint8_t > &  vec)

◆ parse_janus_packet()

janus_rx_msg_pkt goby::acomms::JanusDriver::parse_janus_packet ( const janus_packet_t  pkt,
bool  verbosity 
)

◆ send_ack()

void goby::acomms::JanusDriver::send_ack ( unsigned int  src,
unsigned int  dest,
unsigned int  frame_number 
)

◆ send_janus_packet()

void goby::acomms::JanusDriver::send_janus_packet ( const protobuf::ModemTransmission msg,
std::vector< std::uint8_t >  payload,
bool  ack = false 
)

◆ send_janus_packet_thread()

void goby::acomms::JanusDriver::send_janus_packet_thread ( const protobuf::ModemTransmission msg,
std::vector< std::uint8_t >  payload,
bool  ack 
)

◆ shutdown()

void goby::acomms::JanusDriver::shutdown ( )
overridevirtual

Shuts down the modem driver.

Implements goby::acomms::ModemDriverBase.

◆ startup()

void goby::acomms::JanusDriver::startup ( const protobuf::DriverConfig cfg)
overridevirtual

Starts the modem driver. Must be called before poll().

Parameters
cfgStartup configuration for the driver and modem. DriverConfig is defined in acomms_driver_base.proto. Derived classes can define extensions (see https://developers.google.com/protocol-buffers/docs/proto) to DriverConfig to handle modem specific configuration.

Implements goby::acomms::ModemDriverBase.

◆ to_modem_transmission()

void goby::acomms::JanusDriver::to_modem_transmission ( janus_rx_msg_pkt  packet,
protobuf::ModemTransmission msg 
)

Member Data Documentation

◆ acomms_id

unsigned int goby::acomms::JanusDriver::acomms_id

Definition at line 102 of file janus_driver.h.

◆ carrier_sensing

janus_carrier_sensing_t goby::acomms::JanusDriver::carrier_sensing

Definition at line 114 of file janus_driver.h.

◆ DEFAULT_MTU_BYTES

constexpr int goby::acomms::JanusDriver::DEFAULT_MTU_BYTES {1024}
staticconstexpr

Definition at line 108 of file janus_driver.h.

◆ modem_msg

protobuf::ModemTransmission goby::acomms::JanusDriver::modem_msg

Definition at line 115 of file janus_driver.h.

◆ next_frame_

std::uint32_t goby::acomms::JanusDriver::next_frame_ {0}

Definition at line 107 of file janus_driver.h.

◆ packet_rx

janus_packet_t goby::acomms::JanusDriver::packet_rx = 0

Definition at line 111 of file janus_driver.h.

◆ params_rx

janus_parameters_t goby::acomms::JanusDriver::params_rx

Definition at line 101 of file janus_driver.h.

◆ params_tx

janus_parameters_t goby::acomms::JanusDriver::params_tx

Definition at line 100 of file janus_driver.h.

◆ queried_detection_time

unsigned goby::acomms::JanusDriver::queried_detection_time

Definition at line 113 of file janus_driver.h.

◆ rx_application_type

unsigned int goby::acomms::JanusDriver::rx_application_type

Definition at line 104 of file janus_driver.h.

◆ rx_class_id

unsigned int goby::acomms::JanusDriver::rx_class_id

Definition at line 106 of file janus_driver.h.

◆ simple_rx

janus_simple_rx_t goby::acomms::JanusDriver::simple_rx

Definition at line 110 of file janus_driver.h.

◆ simple_tx

janus_simple_tx_t goby::acomms::JanusDriver::simple_tx

Definition at line 109 of file janus_driver.h.

◆ state_rx

janus_rx_state_t goby::acomms::JanusDriver::state_rx = 0

Definition at line 112 of file janus_driver.h.

◆ tx_application_type

unsigned int goby::acomms::JanusDriver::tx_application_type

Definition at line 103 of file janus_driver.h.

◆ tx_class_id

unsigned int goby::acomms::JanusDriver::tx_class_id

Definition at line 105 of file janus_driver.h.


The documentation for this class was generated from the following file: