aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tsou <ttsou@vt.edu>2012-06-17 21:15:46 -0400
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-06-24 01:46:10 +0400
commit8d804a4cd809dfd59fd60b4ee9c36f4230cfc4d7 (patch)
treec2293563dd9e4c6f9a5650f5c16ddf77bdafd2dc
parent82ede3e810ee9cc070ed25857771810eeff7785a (diff)
transceiver: workaround for transmit testing with no clock reset
Non-functional clock reset causes huge initial timing offset between expected and received timestamps. Receive an initial packet to 'set' the expected starting timestamp value for both transmit and receive. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
-rw-r--r--Transceiver52M/UHDDevice.cpp19
-rw-r--r--Transceiver52M/radioInterface.cpp2
2 files changed, 17 insertions, 4 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index a065ed7..c725696 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -58,6 +58,8 @@ const double rx_smpl_offset = .00005;
const double rx_smpl_offset = .0000869;
#endif
+static TIMESTAMP init_rd_ts = 0;
+
/** Timestamp conversion
@param timestamp a UHD or OpenBTS timestamp
@param rate sample rate
@@ -169,8 +171,8 @@ public:
bool setTxFreq(double wFreq);
bool setRxFreq(double wFreq);
- inline TIMESTAMP initialWriteTimestamp() { return 0; }
- inline TIMESTAMP initialReadTimestamp() { return 0; }
+ inline TIMESTAMP initialWriteTimestamp() { return init_rd_ts; }
+ inline TIMESTAMP initialReadTimestamp() { return init_rd_ts; }
inline double fullScaleInputValue() { return 32000 * tx_ampl; }
inline double fullScaleOutputValue() { return 32000; }
@@ -546,6 +548,17 @@ void uhd_device::restart(uhd::time_spec_t ts)
cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
cmd.stream_now = true;
usrp_dev->issue_stream_cmd(cmd);
+
+ uhd::rx_metadata_t md;
+ uint32_t buff[rx_spp];
+
+ usrp_dev->get_device()->recv(buff,
+ rx_spp,
+ md,
+ uhd::io_type_t::COMPLEX_INT16,
+ uhd::device::RECV_MODE_ONE_PACKET);
+
+ init_rd_ts = convert_time(md.time_spec, actual_smpl_rt);
}
bool uhd_device::start()
@@ -912,7 +925,7 @@ ssize_t smpl_buf::read(void *buf, size_t len, TIMESTAMP timestamp)
num_smpls = len;
// Starting index
- size_t read_start = data_start + (timestamp - time_start);
+ size_t read_start = data_start + (timestamp - time_start) % buf_len;
// Read it
if (read_start + num_smpls < buf_len) {
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp
index b733d0e..f01b528 100644
--- a/Transceiver52M/radioInterface.cpp
+++ b/Transceiver52M/radioInterface.cpp
@@ -120,9 +120,9 @@ void RadioInterface::start()
LOG(INFO) << "starting radio interface...";
mAlignRadioServiceLoopThread.start((void * (*)(void*))AlignRadioServiceLoopAdapter,
(void*)this);
+ mRadio->start();
writeTimestamp = mRadio->initialWriteTimestamp();
readTimestamp = mRadio->initialReadTimestamp();
- mRadio->start();
LOG(DEBUG) << "Radio started";
mRadio->updateAlignment(writeTimestamp-10000);
mRadio->updateAlignment(writeTimestamp-10000);