mirror of
				https://github.com/RangeNetworks/openbts.git
				synced 2025-11-04 05:43:14 +00:00 
			
		
		
		
	uhd: rework handling of timestamp errors
On a lapses of time monotonicity (and possibly other errors), stop and restart the receive streaming with a buffer flush in between. This is a cleaner replacement to the previous clock reset with that didn't attempt to stop steaming. Signed-off-by: Thomas Tsou <ttsou@vt.edu> git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2647 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
		@@ -141,6 +141,7 @@ public:
 | 
			
		||||
	bool open();
 | 
			
		||||
	bool start();
 | 
			
		||||
	bool stop();
 | 
			
		||||
	void restart(uhd::time_spec_t ts);
 | 
			
		||||
	void setPriority();
 | 
			
		||||
 | 
			
		||||
	int readSamples(short *buf, int len, bool *overrun, 
 | 
			
		||||
@@ -205,7 +206,6 @@ private:
 | 
			
		||||
 | 
			
		||||
	void init_gains();
 | 
			
		||||
	void set_ref_clk(bool ext_clk);
 | 
			
		||||
	void reset_clk(uhd::time_spec_t ts);
 | 
			
		||||
	double set_rates(double rate);
 | 
			
		||||
	bool flush_recv(size_t num_pkts);
 | 
			
		||||
 | 
			
		||||
@@ -387,13 +387,19 @@ bool uhd_device::flush_recv(size_t num_pkts)
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void uhd_device::reset_clk(uhd::time_spec_t ts)
 | 
			
		||||
void uhd_device::restart(uhd::time_spec_t ts)
 | 
			
		||||
{
 | 
			
		||||
	double time;
 | 
			
		||||
	uhd::stream_cmd_t cmd = uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS;
 | 
			
		||||
	usrp_dev->issue_stream_cmd(cmd);
 | 
			
		||||
 | 
			
		||||
	usrp_dev->set_time_now(uhd::time_spec_t(ts));
 | 
			
		||||
	time = usrp_dev->get_time_now().get_real_secs();
 | 
			
		||||
	LOG(INFO) << "Reset USRP clock to " << time << " seconds";
 | 
			
		||||
	flush_recv(50);
 | 
			
		||||
 | 
			
		||||
	usrp_dev->set_time_now(ts);
 | 
			
		||||
	aligned = false;
 | 
			
		||||
 | 
			
		||||
	cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
 | 
			
		||||
	cmd.stream_now = true;
 | 
			
		||||
	usrp_dev->issue_stream_cmd(cmd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool uhd_device::start()
 | 
			
		||||
@@ -515,7 +521,7 @@ int uhd_device::readSamples(short *buf, int len, bool *overrun,
 | 
			
		||||
 | 
			
		||||
		// Other metadata timing checks
 | 
			
		||||
		if (check_rx_md_err(metadata, prev_ts) < 0) {
 | 
			
		||||
			reset_clk(prev_ts);
 | 
			
		||||
			restart(prev_ts);
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user