[PATCH] osmo-trx[master]: Move device specific code out of radioInterface

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Apr 24 17:18:59 UTC 2018


Review at  https://gerrit.osmocom.org/7915

Move device specific code out of radioInterface

This way code of radioInterface is independent of the device and doesn't
need to be rebuild for each device.

Change-Id: Id104e1edef02f863b6465ced5b4241050dc188f9
---
M Transceiver52M/device/radioDevice.h
M Transceiver52M/device/uhd/UHDDevice.cpp
M Transceiver52M/device/usrp1/USRPDevice.cpp
M Transceiver52M/device/usrp1/USRPDevice.h
M Transceiver52M/radioInterface.cpp
M Transceiver52M/radioInterface.h
6 files changed, 36 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/15/7915/1

diff --git a/Transceiver52M/device/radioDevice.h b/Transceiver52M/device/radioDevice.h
index 9913de0..8915b17 100644
--- a/Transceiver52M/device/radioDevice.h
+++ b/Transceiver52M/device/radioDevice.h
@@ -148,6 +148,9 @@
   /** return the used RX path */
   virtual std::string getTxAntenna(size_t chan = 0) = 0;
 
+  /** return whether user drives synchronization of Tx/Rx of USRP */
+  virtual bool requiresRadioAlign() = 0;
+
   /** Return internal status values */
   virtual double getTxFreq(size_t chan = 0) = 0;
   virtual double getRxFreq(size_t chan = 0) = 0;
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 4466da4..ecdebe1 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -255,6 +255,8 @@
 	bool setTxAntenna(const std::string &ant, size_t chan);
 	std::string getTxAntenna(size_t chan);
 
+	bool requiresRadioAlign();
+
 	inline double getSampleRate() { return tx_rate; }
 	inline double numberRead() { return rx_pkt_cnt; }
 	inline double numberWritten() { return 0; }
@@ -1282,6 +1284,11 @@
 	return usrp_dev->get_tx_antenna(chan);
 }
 
+bool uhd_device::requiresRadioAlign()
+{
+	return false;
+}
+
 /*
  * Only allow sampling the Rx path lower than Tx and not vice-versa.
  * Using Tx with 4 SPS and Rx at 1 SPS is the only allowed mixed
diff --git a/Transceiver52M/device/usrp1/USRPDevice.cpp b/Transceiver52M/device/usrp1/USRPDevice.cpp
index f7f24e9..455528a 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.cpp
+++ b/Transceiver52M/device/usrp1/USRPDevice.cpp
@@ -353,6 +353,10 @@
 	return "";
 }
 
+bool USRPDevice::requiresRadioAlign()
+{
+	return true;
+}
 
 // NOTE: Assumes sequential reads
 int USRPDevice::readSamples(std::vector<short *> &bufs, int len, bool *overrun,
diff --git a/Transceiver52M/device/usrp1/USRPDevice.h b/Transceiver52M/device/usrp1/USRPDevice.h
index f981643..9091dea 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.h
+++ b/Transceiver52M/device/usrp1/USRPDevice.h
@@ -191,6 +191,9 @@
   /* return the used RX path */
   std::string getTxAntenna(size_t chan = 0);
 
+  /** return whether user drives synchronization of Tx/Rx of USRP */
+  bool requiresRadioAlign();
+
   /** Return internal status values */
   inline double getTxFreq(size_t chan = 0) { return 0; }
   inline double getRxFreq(size_t chan = 0) { return 0; }
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp
index c3063ff..a377436 100644
--- a/Transceiver52M/radioInterface.cpp
+++ b/Transceiver52M/radioInterface.cpp
@@ -145,16 +145,31 @@
   return mRadio->setRxFreq(freq, chan);
 }
 
+/** synchronization thread loop */
+void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
+{
+  while (1) {
+    sleep(60);
+    radioInterface->alignRadio();
+    pthread_testcancel();
+  }
+  return NULL;
+}
+
+void RadioInterface::alignRadio() {
+  mRadio->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000);
+}
+
 bool RadioInterface::start()
 {
   if (mOn)
     return true;
 
   LOG(INFO) << "Starting radio device";
-#ifdef DEVICE_USRP1
-  mAlignRadioServiceLoopThread.start((void * (*)(void*))AlignRadioServiceLoopAdapter,
-                                     (void*)this);
-#endif
+  if (mRadio->requiresRadioAlign())
+        mAlignRadioServiceLoopThread.start(
+                                (void * (*)(void*))AlignRadioServiceLoopAdapter,
+                                (void*)this);
 
   if (!mRadio->start())
     return false;
@@ -190,22 +205,6 @@
   mOn = false;
   return true;
 }
-
-#ifdef DEVICE_USRP1
-void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
-{
-  while (1) {
-    radioInterface->alignRadio();
-    pthread_testcancel();
-  }
-  return NULL;
-}
-
-void RadioInterface::alignRadio() {
-  sleep(60);
-  mRadio->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000);
-}
-#endif
 
 void RadioInterface::driveTransmitRadio(std::vector<signalVector *> &bursts,
                                         std::vector<bool> &zeros)
diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h
index e05d871..6b482d1 100644
--- a/Transceiver52M/radioInterface.h
+++ b/Transceiver52M/radioInterface.h
@@ -133,20 +133,12 @@
   /** get transport window type of attached device */ 
   enum RadioDevice::TxWindowType getWindowType() { return mRadio->getWindowType(); }
 
-#if DEVICE_USRP1
 protected:
-
   /** drive synchronization of Tx/Rx of USRP */
   void alignRadio();
 
   friend void *AlignRadioServiceLoopAdapter(RadioInterface*);
-#endif
 };
-
-#if DEVICE_USRP1
-/** synchronization thread loop */
-void *AlignRadioServiceLoopAdapter(RadioInterface*);
-#endif
 
 class RadioInterfaceResamp : public RadioInterface {
 private:

-- 
To view, visit https://gerrit.osmocom.org/7915
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id104e1edef02f863b6465ced5b4241050dc188f9
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list