Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
temp commit to debug CI
Browse files Browse the repository at this point in the history
  • Loading branch information
hhenry01 committed Mar 7, 2024
1 parent 253526e commit e9f8460
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 73 deletions.
1 change: 1 addition & 0 deletions functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ function(make_unit_test module srcs link_libs inc_dirs compile_defs)
add_dependencies(${test_module} ${AUTOGEN_TARGETS})
# Make the unit test runnable with CTest (invoked via test.sh)
add_test(NAME ${test_module} COMMAND ${test_module})
set_tests_properties(${test_module} PROPERTIES TIMEOUT 60) # 1 minute per test timeout
endif()
endfunction()
136 changes: 68 additions & 68 deletions projects/local_transceiver/src/local_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ void LocalTransceiver::updateSensor(msg::GenericSensors msg)
void LocalTransceiver::updateSensor(msg::LPathData localData)
{
sensors_.clear_local_path_data();
Sensors::Path * new_local = sensors_.mutable_local_path_data();
for (const msg::HelperLatLon & local_data : localData.local_path.waypoints) {
Sensors::Path * new_local = sensors_.mutable_local_path_data();
Polaris::Waypoint * waypoint = new_local->add_waypoints();
Polaris::Waypoint * waypoint = new_local->add_waypoints();
waypoint->set_latitude(local_data.latitude);
waypoint->set_longitude(local_data.longitude);
}
Expand Down Expand Up @@ -135,74 +135,74 @@ bool LocalTransceiver::send()
throw std::length_error(err_string);
}

std::string write_bin_cmd_str = AT::write_bin::CMD + std::to_string(data.size()); //according to specs
std::string write_bin_cmd_str = AT::write_bin::CMD + std::to_string(data.size()); //according to specs
AT::Line at_write_cmd(write_bin_cmd_str);

static constexpr int MAX_NUM_RETRIES = 20; // allow retries because the connection is imperfect
for (int i = 0; i < MAX_NUM_RETRIES; i++) {
if (!send(at_write_cmd)) {
continue;
}

if (!rcvRsps({
at_write_cmd,
AT::Line(AT::DELIMITER),
AT::Line(AT::RSP_READY),
AT::Line("\n"),
})) {
continue;
}

std::string msg_str = data + checksum(data);
AT::Line msg(msg_str);
if (!send(msg)) {
continue;
}

if (!rcvRsps({
AT::Line(AT::DELIMITER),
AT::Line(AT::write_bin::rsp::SUCCESS),
AT::Line("\n"),
AT::Line(AT::DELIMITER),
AT::Line(AT::STATUS_OK),
AT::Line("\n"),
})) {
continue;
}

// Check SBD Session status to see if data was sent successfully
// NEEDS AN ACTIVE SERVER ON $WEBHOOK_SERVER_ENDPOINT OR VIRTUAL IRIDIUM WILL CRASH
static const AT::Line sbdix_cmd = AT::Line(AT::SBD_SESSION);
if (!send(sbdix_cmd)) {
continue;
}

if (!rcvRsps({
AT::Line("\r"),
sbdix_cmd,
AT::Line(AT::DELIMITER),
})) {
continue;
}

auto opt_rsp = readRsp();
if (!opt_rsp) {
continue;
}

// This string will look something like:
// "+SBDIX:<MO status>,<MOMSN>,<MT status>,<MTMSN>,<MT length>,<MTqueued>\r\n\r\nOK\r"
// on success
// Don't bother to check for OK\r as MO status will tell us if it succeeded or not
std::string opt_rsp_val = opt_rsp.value();
std::vector<std::string> sbd_status_vec;
boost::algorithm::split(sbd_status_vec, opt_rsp_val, boost::is_any_of(AT::DELIMITER));

AT::SBDStatusRsp rsp(sbd_status_vec[0]);
if (rsp.MOSuccess()) {
return true;
}
}
// static constexpr int MAX_NUM_RETRIES = 20; // allow retries because the connection is imperfect
// for (int i = 0; i < MAX_NUM_RETRIES; i++) {
// if (!send(at_write_cmd)) {
// continue;
// }

// if (!rcvRsps({
// at_write_cmd,
// AT::Line(AT::DELIMITER),
// AT::Line(AT::RSP_READY),
// AT::Line("\n"),
// })) {
// continue;
// }

// std::string msg_str = data + checksum(data);
// AT::Line msg(msg_str);
// if (!send(msg)) {
// continue;
// }

// if (!rcvRsps({
// AT::Line(AT::DELIMITER),
// AT::Line(AT::write_bin::rsp::SUCCESS),
// AT::Line("\n"),
// AT::Line(AT::DELIMITER),
// AT::Line(AT::STATUS_OK),
// AT::Line("\n"),
// })) {
// continue;
// }

// // Check SBD Session status to see if data was sent successfully
// // NEEDS AN ACTIVE SERVER ON $WEBHOOK_SERVER_ENDPOINT OR VIRTUAL IRIDIUM WILL CRASH
// static const AT::Line sbdix_cmd = AT::Line(AT::SBD_SESSION);
// if (!send(sbdix_cmd)) {
// continue;
// }

// if (!rcvRsps({
// AT::Line("\r"),
// sbdix_cmd,
// AT::Line(AT::DELIMITER),
// })) {
// continue;
// }

// auto opt_rsp = readRsp();
// if (!opt_rsp) {
// continue;
// }

// // This string will look something like:
// // "+SBDIX:<MO status>,<MOMSN>,<MT status>,<MTMSN>,<MT length>,<MTqueued>\r\n\r\nOK\r"
// // on success
// // Don't bother to check for OK\r as MO status will tell us if it succeeded or not
// std::string opt_rsp_val = opt_rsp.value();
// std::vector<std::string> sbd_status_vec;
// boost::algorithm::split(sbd_status_vec, opt_rsp_val, boost::is_any_of(AT::DELIMITER));

// AT::SBDStatusRsp rsp(sbd_status_vec[0]);
// if (rsp.MOSuccess()) {
// return true;
// }
// }
std::cerr << "Failed to transmit data to satellite!" << std::endl;
std::cerr << sensors.DebugString() << std::endl;
return false;
Expand Down
22 changes: 17 additions & 5 deletions projects/local_transceiver/test/test_local_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,25 @@ class TestLocalTransceiver : public ::testing::Test
protected:
static void SetUpTestSuite() { http_echo_server_proc_ = bp::child(RUN_HTTP_ECHO_SERVER_CMD); }

static void TearDownTestSuite() { http_echo_server_proc_.terminate(); }
static void TearDownTestSuite()
{
std::error_code e;
http_echo_server_proc_.terminate(e);
if (e) {
throw std::runtime_error("Failed to terminate HTTP Echo Server! " + e.message());
}
}

TestLocalTransceiver()
{
try {
lcl_trns_ = new LocalTransceiver(LOCAL_TRANSCEIVER_TEST_PORT, SATELLITE_BAUD_RATE);
} catch (boost::system::system_error & /**/) {
std::cerr << "Failed to create Local Transceiver for tests, is only one instance of: \""
<< RUN_VIRTUAL_IRIDIUM_SCRIPT_PATH << "\" running?" << std::endl;
} catch (boost::system::system_error & e) {
std::stringstream ss;
ss << "Failed to create Local Transceiver for tests, is only one instance of: \""
<< RUN_VIRTUAL_IRIDIUM_SCRIPT_PATH << "\" running?" << std::endl;
ss << e.what() << std::endl;
throw std::runtime_error(ss.str());
}
}
~TestLocalTransceiver() override
Expand Down Expand Up @@ -162,5 +172,7 @@ TEST_F(TestLocalTransceiver, sendData)
lcl_trns_->updateSensor(batteries);
lcl_trns_->updateSensor(sensors);
lcl_trns_->updateSensor(local_paths);
lcl_trns_->send();

std::cout << "Sending data" << std::endl;
EXPECT_TRUE(lcl_trns_->send());
}

0 comments on commit e9f8460

Please sign in to comment.