diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-01-30 09:40:02 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-01-30 09:40:02 +0100 |
commit | 211c590f594f83dc8b5fc724d49c1c8d7207d2f2 (patch) | |
tree | 16b03b97da7c61930053a0b8699a36d36e9857b2 /host/lib/usrp/x300/x300_impl.cpp | |
parent | 207903d343f6cb520d86e62c2ebee2e847546f7b (diff) | |
parent | 75e6ae59b3f4832372c08d7da390c5fdcc283067 (diff) | |
download | uhd-211c590f594f83dc8b5fc724d49c1c8d7207d2f2.tar.gz uhd-211c590f594f83dc8b5fc724d49c1c8d7207d2f2.tar.bz2 uhd-211c590f594f83dc8b5fc724d49c1c8d7207d2f2.zip |
Merge branch 'maint'
Diffstat (limited to 'host/lib/usrp/x300/x300_impl.cpp')
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 8164c79b6..aa54c2228 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -1529,13 +1529,32 @@ void x300_impl::claimer_loop(wb_iface::sptr iface) x300_impl::claim_status_t x300_impl::claim_status(wb_iface::sptr iface) { - //If timed out, then device is definitely unclaimed - if (iface->peek32(X300_FW_SHMEM_ADDR(X300_FW_SHMEM_CLAIM_STATUS)) == 0) - return UNCLAIMED; + claim_status_t claim_status = CLAIMED_BY_OTHER; // Default to most restrictive + boost::system_time timeout_time = boost::get_system_time() + boost::posix_time::seconds(1); + while (boost::get_system_time() < timeout_time) + { + //If timed out, then device is definitely unclaimed + if (iface->peek32(X300_FW_SHMEM_ADDR(X300_FW_SHMEM_CLAIM_STATUS)) == 0) + { + claim_status = UNCLAIMED; + break; + } - //otherwise check claim src to determine if another thread with the same src has claimed the device - uint32_t hash = iface->peek32(X300_FW_SHMEM_ADDR(X300_FW_SHMEM_CLAIM_SRC)); - return (hash == get_process_hash() ? CLAIMED_BY_US : CLAIMED_BY_OTHER); + //otherwise check claim src to determine if another thread with the same src has claimed the device + uint32_t hash = iface->peek32(X300_FW_SHMEM_ADDR(X300_FW_SHMEM_CLAIM_SRC)); + if (hash == 0) + { + // A non-zero claim status and an empty hash means the claim might + // be in the process of being released. This is possible because + // older firmware takes a long time to update the status. Wait and + // check status again. + boost::this_thread::sleep(boost::posix_time::milliseconds(5)); + continue; + } + claim_status = (hash == get_process_hash() ? CLAIMED_BY_US : CLAIMED_BY_OTHER); + break; + } + return claim_status; } void x300_impl::claim(wb_iface::sptr iface) |