diff --git a/CMakeLists.txt b/CMakeLists.txt index 4784d3ef9..4014e7d73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -683,7 +683,9 @@ set(Boost_ADDITIONAL_VERSIONS "1.70.0" "1.70" "1.71.0" "1.71" ) set(Boost_USE_MULTITHREAD ON) -set(Boost_USE_STATIC_LIBS OFF) +#set(Boost_USE_STATIC_LIBS OFF) +option(Boost_USE_STATIC_LIBS "Use Boost static libs" OFF) + set(BOOST_COMPONENTS atomic chrono date_time serialization system thread) if(NOT ${FILESYSTEM_FOUND}) set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem) diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index e450a1b8e..9d1e8af04 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -76,6 +76,10 @@ else() ) endif() +if(CMAKE_ANDROID_ARCH_ABI) + target_compile_definitions(pvt_libs PUBLIC -DANDROID=1) +endif(CMAKE_ANDROID_ARCH_ABI) + target_link_libraries(pvt_libs PUBLIC Boost::date_time diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index a320bd527..4b41dcd2a 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -1511,6 +1511,9 @@ std::string Rinex_Printer::getLocalTime() const line += std::string("GNSS-SDR"); line += std::string(12, ' '); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) @@ -1521,6 +1524,8 @@ std::string Rinex_Printer::getLocalTime() const { username = "UNKNOWN USER"; } +#endif + line += Rinex_Printer::leftJustify(username, 20); const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); @@ -3527,8 +3532,11 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const line.clear(); line += Rinex_Printer::leftJustify("GNSS-SDR", 20); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -3537,6 +3545,7 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const { username = "UNKNOWN USER"; } +#endif line += Rinex_Printer::leftJustify(username, 20); // Date of file creation (dd-mmm-yy hhmm) const boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); @@ -6001,8 +6010,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -6011,6 +6023,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -6327,8 +6340,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -6337,6 +6353,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -6682,8 +6699,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -6692,6 +6712,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -6991,8 +7012,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7001,6 +7025,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -7314,8 +7339,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7324,6 +7352,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -7571,8 +7600,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7581,6 +7613,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -7822,8 +7855,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -7832,6 +7868,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -8103,8 +8140,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -8113,6 +8153,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -8449,8 +8490,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -8459,6 +8503,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -8767,8 +8812,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -8777,6 +8825,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -9034,8 +9083,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -9044,6 +9096,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); @@ -9316,8 +9369,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme // -------- Line OBSERVER / AGENCY line.clear(); std::string username; +#if ANDROID + username = "ANDROID USER"; +#else std::array c_username{}; - int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); if (nGet == 0) { username = c_username.data(); @@ -9326,6 +9382,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme { username = "UNKNOWN USER"; } +#endif line += leftJustify(username, 20); line += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 4b4fa761d..86d886dd9 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -62,6 +62,10 @@ else() ) endif() +if(CMAKE_ANDROID_ARCH_ABI) + target_compile_definitions(core_receiver PUBLIC -DANDROID=1) +endif(CMAKE_ANDROID_ARCH_ABI) + if(ENABLE_FPGA) target_compile_definitions(core_receiver PUBLIC -DENABLE_FPGA=1) endif() diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index ff0eecfa1..d34b79c9a 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -418,7 +418,11 @@ int ControlThread::run() { pthread_t id = keyboard_thread_.native_handle(); keyboard_thread_.detach(); +#ifndef ANDROID pthread_cancel(id); +#else + //todo: find alternative +#endif } // Terminate telecommand thread @@ -426,8 +430,12 @@ int ControlThread::run() { pthread_t id2 = cmd_interface_thread_.native_handle(); cmd_interface_thread_.detach(); +#ifndef ANDROID pthread_cancel(id2); - } +#else + //todo: find alternative +#endif + } LOG(INFO) << "Flowgraph stopped";