Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/middleware/protobuf/intervehicle.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ message PortalConfig
(goby.field).description = "Time between modem reports",
(dccl.field) = { units { base_dimensions: "T" } }
];

optional bool required = 22 [
default = true,
(goby.field).description = "Specify if the modem is necessary for an application's communications archictecture."
];

optional uint32 connection_attempts = 23 [
default = 1,
(goby.field).description = "The number of times to re-attempt initialising the link. Set to 0 for infinite attempts."
];
}

repeated LinkConfig link = 1;
Expand Down
58 changes: 44 additions & 14 deletions src/middleware/transport/intervehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,28 +779,58 @@ class InterVehiclePortal
data.underlying_thread.reset(new std::thread(
[&data, link]()
{
try
{
data.modem_driver_thread.reset(new intervehicle::ModemDriverThread(*link));
data.modem_driver_thread->run(data.driver_thread_alive);
}
catch (std::exception& e)
{
goby::glog.is_warn() &&
goby::glog << "Modem driver thread had uncaught exception: " << e.what()
<< std::endl;
throw;
}
uint32_t attempts = 0;
do {
attempts++;
try
{
data.modem_driver_thread.reset(
new intervehicle::ModemDriverThread(*link));
data.modem_driver_thread->run(data.driver_thread_alive);
}
catch (std::exception& e)
{
if (link->connection_attempts() == 0 ||
attempts < link->connection_attempts())
{
goby::glog.is_warn() &&
goby::glog << "Modem driver thread had uncaught exception: "
<< e.what() << " Attempting reconnection."
<< std::endl;
}
else
{
if (link->required())
{
goby::glog.is_warn() &&
goby::glog << "Modem driver thread had uncaught exception: "
<< e.what() << std::endl;
throw;
}
else
{
goby::glog.is_warn() &&
goby::glog << "Modem driver thread had uncaught exception: "
<< e.what()
<< " However, the communication link is not "
"required. Ignoring uncaught exception."
<< std::endl;
}
}
}
} while (link->connection_attempts() == 0 ||
attempts < link->connection_attempts());
}));

if (goby::glog.buf().is_gui())
// allows for visual grouping of each link in the NCurses gui
std::this_thread::sleep_for(std::chrono::milliseconds(250));
}

while (drivers_ready_ < modem_drivers_.size())
while (drivers_ready_ > 1) // < modem_drivers_.size())
{
goby::glog.is_debug1() && goby::glog << "Waiting for drivers to be ready." << std::endl;
goby::glog.is_debug1() &&
goby::glog << "Waiting for at least one modem driver to be ready." << std::endl;
this->poll();
std::this_thread::sleep_for(std::chrono::seconds(1));
}
Expand Down