aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M
diff options
context:
space:
mode:
Diffstat (limited to 'Transceiver52M')
-rw-r--r--Transceiver52M/UHDDevice.cpp36
1 files changed, 10 insertions, 26 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 1f9dd78..99e7967 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -212,22 +212,6 @@ static double select_rate(uhd_dev_type type, int sps, bool diversity = false)
return -9999.99;
}
-/** Timestamp conversion
- @param timestamp a UHD or OpenBTS timestamp
- @param rate sample rate
- @return the converted timestamp
-*/
-uhd::time_spec_t convert_time(TIMESTAMP ticks, double rate)
-{
- double secs = (double) ticks / rate;
- return uhd::time_spec_t(secs);
-}
-
-TIMESTAMP convert_time(uhd::time_spec_t ts, double rate)
-{
- return (TIMESTAMP)(ts.get_real_secs() * rate + 0.5);
-}
-
/*
Sample Buffer - Allows reading and writing of timed samples using OpenBTS
or UHD style timestamps. Time conversions are handled
@@ -864,7 +848,7 @@ bool uhd_device::flush_recv(size_t num_pkts)
}
}
- ts_initial = convert_time(md.time_spec, rx_rate);
+ ts_initial = md.time_spec.to_ticks(rx_rate);
}
LOG(INFO) << "Initial timestamp " << ts_initial << std::endl;
@@ -1001,7 +985,7 @@ int uhd_device::readSamples(std::vector<short *> &bufs, int len, bool *overrun,
// Shift read time with respect to transmit clock
timestamp += ts_offset;
- ts = convert_time(timestamp, rx_rate);
+ ts = uhd::time_spec_t::from_ticks(timestamp, rx_rate);
LOG(DEBUG) << "Requested timestamp = " << ts.get_real_secs();
// Check that timestamp is valid
@@ -1083,7 +1067,7 @@ int uhd_device::writeSamples(std::vector<short *> &bufs, int len, bool *underrun
metadata.has_time_spec = true;
metadata.start_of_burst = false;
metadata.end_of_burst = false;
- metadata.time_spec = convert_time(timestamp, tx_rate);
+ metadata.time_spec = uhd::time_spec_t::from_ticks(timestamp, tx_rate);
*underrun = false;
@@ -1397,7 +1381,7 @@ ssize_t smpl_buf::avail_smpls(TIMESTAMP timestamp) const
ssize_t smpl_buf::avail_smpls(uhd::time_spec_t timespec) const
{
- return avail_smpls(convert_time(timespec, clk_rt));
+ return avail_smpls(timespec.to_ticks(clk_rt));
}
ssize_t smpl_buf::read(void *buf, size_t len, TIMESTAMP timestamp)
@@ -1443,7 +1427,7 @@ ssize_t smpl_buf::read(void *buf, size_t len, TIMESTAMP timestamp)
ssize_t smpl_buf::read(void *buf, size_t len, uhd::time_spec_t ts)
{
- return read(buf, len, convert_time(ts, clk_rt));
+ return read(buf, len, ts.to_ticks(clk_rt));
}
ssize_t smpl_buf::write(void *buf, size_t len, TIMESTAMP timestamp)
@@ -1458,14 +1442,14 @@ ssize_t smpl_buf::write(void *buf, size_t len, TIMESTAMP timestamp)
if (timestamp < time_end) {
LOG(ERR) << "Overwriting old buffer data: timestamp="<<timestamp<<" time_end="<<time_end;
- uhd::time_spec_t ts = convert_time(timestamp, clk_rt);
- LOG(DEBUG) << "Requested timestamp = " << timestamp << " (real_sec=" << std::fixed << ts.get_real_secs() << " = " << convert_time(ts, clk_rt) << ") rate=" << clk_rt;
+ uhd::time_spec_t ts = uhd::time_spec_t::from_ticks(timestamp, clk_rt);
+ LOG(DEBUG) << "Requested timestamp = " << timestamp << " (real_sec=" << std::fixed << ts.get_real_secs() << " = " << ts.to_ticks(clk_rt) << ") rate=" << clk_rt;
// Do not return error here, because it's a rounding error and is not fatal
}
if (timestamp > time_end && time_end != 0) {
LOG(ERR) << "Skipping buffer data: timestamp="<<timestamp<<" time_end="<<time_end;
- uhd::time_spec_t ts = convert_time(timestamp, clk_rt);
- LOG(DEBUG) << "Requested timestamp = " << timestamp << " (real_sec=" << std::fixed << ts.get_real_secs() << " = " << convert_time(ts, clk_rt) << ") rate=" << clk_rt;
+ uhd::time_spec_t ts = uhd::time_spec_t::from_ticks(timestamp, clk_rt);
+ LOG(DEBUG) << "Requested timestamp = " << timestamp << " (real_sec=" << std::fixed << ts.get_real_secs() << " = " << ts.to_ticks(clk_rt) << ") rate=" << clk_rt;
// Do not return error here, because it's a rounding error and is not fatal
}
@@ -1500,7 +1484,7 @@ ssize_t smpl_buf::write(void *buf, size_t len, TIMESTAMP timestamp)
ssize_t smpl_buf::write(void *buf, size_t len, uhd::time_spec_t ts)
{
- return write(buf, len, convert_time(ts, clk_rt));
+ return write(buf, len, ts.to_ticks(clk_rt));
}
std::string smpl_buf::str_status(size_t ts) const