diff options
| author | Trung Tran <trung.tran@ettus.com> | 2019-01-09 21:51:41 -0800 | 
|---|---|---|
| committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-14 09:43:56 -0800 | 
| commit | a8ac2016ee18e37bddbde05bf299c97a896a7f56 (patch) | |
| tree | e4d2ba326d9298764f010d9f381471a74968a024 /host | |
| parent | 654c2fece997c4708dd928625494b8b796d1b2a2 (diff) | |
| download | uhd-a8ac2016ee18e37bddbde05bf299c97a896a7f56.tar.gz uhd-a8ac2016ee18e37bddbde05bf299c97a896a7f56.tar.bz2 uhd-a8ac2016ee18e37bddbde05bf299c97a896a7f56.zip  | |
rpc,mpmd: replace all set_timeout() to new api
Using new rpc client new API that ensure atomic setting of timeout on
each rpc call.
Diffstat (limited to 'host')
| -rw-r--r-- | host/lib/include/uhdlib/utils/rpc.hpp | 5 | ||||
| -rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.hpp | 6 | ||||
| -rw-r--r-- | host/lib/usrp/mpmd/mpmd_mboard_impl.cpp | 38 | ||||
| -rw-r--r-- | host/lib/usrp/mpmd/mpmd_prop_tree.cpp | 20 | 
4 files changed, 11 insertions, 58 deletions
diff --git a/host/lib/include/uhdlib/utils/rpc.hpp b/host/lib/include/uhdlib/utils/rpc.hpp index f1cfec06b..67f0248e6 100644 --- a/host/lib/include/uhdlib/utils/rpc.hpp +++ b/host/lib/include/uhdlib/utils/rpc.hpp @@ -242,11 +242,6 @@ class rpc_client          _token = token;      } -    void set_timeout(size_t timeout_ms) -    { -        _client.set_timeout(timeout_ms); -    } -    private:      /*! This is internal object to hold timeout of the rpc client diff --git a/host/lib/usrp/mpmd/mpmd_impl.hpp b/host/lib/usrp/mpmd/mpmd_impl.hpp index b5d559e3e..b3d753949 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.hpp +++ b/host/lib/usrp/mpmd/mpmd_impl.hpp @@ -136,12 +136,6 @@ class mpmd_mboard_impl      uhd::device_addr_t get_rx_hints() const;      uhd::device_addr_t get_tx_hints() const; -    //! Set the RPC call timeout to the default value -    void set_timeout_default(); - -    //! Set the RPC call timeout to the value for initializations -    void set_timeout_init(); -    private:      /*! Reference to the RPC client that handles claiming       */ diff --git a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp index e58337dd2..fe92f132e 100644 --- a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp @@ -77,7 +77,7 @@ namespace {      ) {          auto init_status =              rpc->request_with_token<std::vector<std::string>>( -                "get_init_status"); +                MPMD_DEFAULT_INIT_TIMEOUT, "get_init_status");          if (init_status[0] != "true") {              throw uhd::runtime_error(                  std::string("Device is in bad state: ") + init_status[1] @@ -94,7 +94,7 @@ namespace {                  mpm_device_args[key] = mb_args[key];              }          } -        if (not rpc->request_with_token<bool>("init", mpm_device_args)) { +        if (not rpc->request_with_token<bool>(MPMD_DEFAULT_INIT_TIMEOUT, "init", mpm_device_args)) {              throw uhd::runtime_error("Failed to initialize device.");          }      } @@ -201,6 +201,7 @@ namespace {                  uhd::mpmd::mpmd_impl::MPM_RPC_PORT_KEY,                  uhd::mpmd::mpmd_impl::MPM_RPC_PORT              ), +            MPMD_DEFAULT_RPC_TIMEOUT,              uhd::mpmd::mpmd_impl::MPM_RPC_GET_LAST_ERROR_CMD);      } @@ -225,11 +226,10 @@ boost::optional<device_addr_t> mpmd_mboard_impl::is_device_reachable(          mpmd_impl::MPM_RPC_PORT      );      auto rpcc = uhd::rpc_client::make(rpc_addr, rpc_port); -    rpcc->set_timeout(MPMD_SHORT_RPC_TIMEOUT);      // 1) Read back device info      dev_info device_info_dict;      try { -        device_info_dict = rpcc->request<dev_info>("get_device_info"); +        device_info_dict = rpcc->request<dev_info>(MPMD_SHORT_RPC_TIMEOUT, "get_device_info");      } catch (const uhd::runtime_error& e) {          UHD_LOG_ERROR("MPMD", e.what());      } catch (...) { @@ -270,8 +270,7 @@ boost::optional<device_addr_t> mpmd_mboard_impl::is_device_reachable(              UHD_LOG_TRACE("MPMD",                  "Was able to ping device, trying RPC connection.");              auto chdr_rpcc = uhd::rpc_client::make(chdr_addr, rpc_port); -            chdr_rpcc->set_timeout(MPMD_SHORT_RPC_TIMEOUT); -            auto dev_info_chdr = chdr_rpcc->request<dev_info>("get_device_info"); +            auto dev_info_chdr = chdr_rpcc->request<dev_info>(MPMD_SHORT_RPC_TIMEOUT, "get_device_info");              if (dev_info_chdr["serial"] != device_info_dict["serial"]) {                  UHD_LOG_DEBUG("MPMD", boost::format(                      "Connected to CHDR interface, but got wrong device. " @@ -365,13 +364,7 @@ mpmd_mboard_impl::~mpmd_mboard_impl()   ****************************************************************************/  void mpmd_mboard_impl::init()  { -    this->set_rpcc_timeout(mb_args.cast<size_t>( -        "init_timeout", MPMD_DEFAULT_INIT_TIMEOUT -    ));      init_device(rpc, mb_args); -    this->set_rpcc_timeout(mb_args.cast<size_t>( -        "rpc_timeout", MPMD_DEFAULT_RPC_TIMEOUT -    ));      // RFNoC block clocks are now on. Noc-IDs can be read back.  } @@ -467,20 +460,6 @@ uhd::device_addr_t mpmd_mboard_impl::get_tx_hints() const      return tx_hints;  } -void mpmd_mboard_impl::set_timeout_default() -{ -    this->set_rpcc_timeout(mb_args.cast<size_t>( -            "rpc_timeout", MPMD_DEFAULT_RPC_TIMEOUT -    )); -} - -void mpmd_mboard_impl::set_timeout_init() -{ -    this->set_rpcc_timeout(mb_args.cast<size_t>( -            "init_timeout", MPMD_DEFAULT_INIT_TIMEOUT -    )); -} -  /*****************************************************************************   * Private methods   ****************************************************************************/ @@ -494,13 +473,6 @@ bool mpmd_mboard_impl::claim()      }  } -void mpmd_mboard_impl::set_rpcc_timeout(const uint64_t timeout_ms){ -    rpc->set_timeout(timeout_ms); -    //FIXME: remove this when we know why rpc client didn't reset timer -    // while other rpc client not yet return. -    _claim_rpc->set_timeout(timeout_ms); -} -  uhd::task::sptr mpmd_mboard_impl::claim_device_and_make_task(  ) {      auto rpc_token = _claim_rpc->request<std::string>("claim", diff --git a/host/lib/usrp/mpmd/mpmd_prop_tree.cpp b/host/lib/usrp/mpmd/mpmd_prop_tree.cpp index 256ac850a..27893341d 100644 --- a/host/lib/usrp/mpmd/mpmd_prop_tree.cpp +++ b/host/lib/usrp/mpmd/mpmd_prop_tree.cpp @@ -55,10 +55,8 @@ namespace {          // Now call update component          const size_t update_component_timeout = MPMD_UPDATE_COMPONENT_TIMEOUT * comps.size(); -        mb->rpc->set_timeout(update_component_timeout); -        mb->rpc->notify_with_token("update_component", all_metadata, all_data); -        mb->set_timeout_default(); - +        mb->rpc->notify_with_token(update_component_timeout, +            "update_component", all_metadata, all_data);          return all_comps_copy;      } @@ -114,9 +112,7 @@ void mpmd_impl::init_property_tree(      /*** Clocking *******************************************************/      tree->create<std::string>(mb_path / "clock_source/value")          .add_coerced_subscriber([mb](const std::string &clock_source){ -            mb->set_timeout_init(); -            mb->rpc->notify_with_token("set_clock_source", clock_source); -            mb->set_timeout_default(); +            mb->rpc->notify_with_token(MPMD_DEFAULT_INIT_TIMEOUT, "set_clock_source", clock_source);          })          .set_publisher([mb](){              return mb->rpc->request_with_token<std::string>( @@ -134,9 +130,7 @@ void mpmd_impl::init_property_tree(      ;      tree->create<std::string>(mb_path / "time_source/value")          .add_coerced_subscriber([mb](const std::string &time_source){ -            mb->set_timeout_init(); -            mb->rpc->notify_with_token("set_time_source", time_source); -            mb->set_timeout_default(); +            mb->rpc->notify_with_token(MPMD_DEFAULT_INIT_TIMEOUT, "set_time_source", time_source);          })          .set_publisher([mb](){              return mb->rpc->request_with_token<std::string>( @@ -168,13 +162,11 @@ void mpmd_impl::init_property_tree(          tree->create<sensor_value_t>(                  mb_path / "sensors" / sensor_name)              .set_publisher([mb, sensor_name](){ -                mb->set_timeout_init();                  auto sensor_val = sensor_value_t(                      mb->rpc->request_with_token<sensor_value_t::sensor_map_t>( -                        "get_mb_sensor", sensor_name +                        MPMD_DEFAULT_INIT_TIMEOUT, "get_mb_sensor", sensor_name                      )                  ); -                mb->set_timeout_default();                  return sensor_val;              })              .set_coercer([](const sensor_value_t &){ @@ -196,7 +188,7 @@ void mpmd_impl::init_property_tree(                          mb_eeprom[key].cend()                  );              } -            mb->rpc->notify_with_token("set_mb_eeprom", eeprom_map); +            mb->rpc->notify_with_token(MPMD_DEFAULT_INIT_TIMEOUT, "set_mb_eeprom", eeprom_map);          })          .set_publisher([mb](){              auto mb_eeprom =  | 
