uhd: Fix rounding error in timestamp conversion functions.

Rounding error introduced oscilating timing advance error by regularly
overwriting one bit and then skipping one bit.

This commit also adds an error message to show up in logs if this ever
happens again.
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 9038bc1..272ce60 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -210,8 +210,7 @@
 
 TIMESTAMP convert_time(uhd::time_spec_t ts, double rate)
 {
-	TIMESTAMP ticks = ts.get_full_secs() * rate;
-	return ts.get_tick_count(rate) + ticks;
+	return (TIMESTAMP)(ts.get_real_secs() * rate + 0.5);
 }
 
 /*
@@ -1430,6 +1429,19 @@
 	if ((timestamp + len) <= time_end)
 		return ERROR_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;
+		// 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;
+		// Do not return error here, because it's a rounding error and is not fatal
+	}
+
 	// Starting index
 	size_t write_start = (data_start + (timestamp - time_start)) % buf_len;