[MERGED] osmo-trx[master]: Move enums required by VTY to a separate header

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Mar 6 19:38:58 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: Move enums required by VTY to a separate header
......................................................................


Move enums required by VTY to a separate header

This patch is a preparation for next patches, which add full VTY cfg
support.

Change-Id: I3d5b0576aa96869756f1629a40306c0043b6304b
---
M CommonLibs/Makefile.am
A CommonLibs/config_defs.h
M Transceiver52M/Transceiver.cpp
M Transceiver52M/Transceiver.h
M Transceiver52M/osmo-trx.cpp
M Transceiver52M/radioDevice.h
6 files changed, 56 insertions(+), 41 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

Objections:
  Vadim Yanitskiy: I would prefer this is not merged as is



diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am
index 5d116f9..613af1e 100644
--- a/CommonLibs/Makefile.am
+++ b/CommonLibs/Makefile.am
@@ -52,4 +52,5 @@
 	Vector.h \
 	Logger.h \
 	trx_vty.h \
-	debug.h
+	debug.h \
+	config_defs.h
diff --git a/CommonLibs/config_defs.h b/CommonLibs/config_defs.h
new file mode 100644
index 0000000..8626166
--- /dev/null
+++ b/CommonLibs/config_defs.h
@@ -0,0 +1,20 @@
+#pragma once
+
+/*
+ * This file contains structures used by both VTY (C, dir CommonLibs) and
+ * osmo-trx (CXX, dir Transceiver52)
+ */
+
+enum FillerType {
+  FILLER_DUMMY,
+  FILLER_ZERO,
+  FILLER_NORM_RAND,
+  FILLER_EDGE_RAND,
+  FILLER_ACCESS_RAND,
+};
+
+enum ReferenceType {
+  REF_INTERNAL,
+  REF_EXTERNAL,
+  REF_GPS,
+};
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index d9c231d..8ebd9ed 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -71,7 +71,7 @@
   }
 }
 
-bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay)
+bool TransceiverState::init(FillerType filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay)
 {
   signalVector *burst;
 
@@ -81,19 +81,19 @@
   for (size_t n = 0; n < 8; n++) {
     for (size_t i = 0; i < 102; i++) {
       switch (filler) {
-      case Transceiver::FILLER_DUMMY:
+      case FILLER_DUMMY:
         burst = generateDummyBurst(sps, n);
         break;
-      case Transceiver::FILLER_NORM_RAND:
+      case FILLER_NORM_RAND:
         burst = genRandNormalBurst(rtsc, sps, n);
         break;
-      case Transceiver::FILLER_EDGE_RAND:
+      case FILLER_EDGE_RAND:
         burst = generateEdgeBurst(rtsc);
         break;
-      case Transceiver::FILLER_ACCESS_RAND:
+      case FILLER_ACCESS_RAND:
         burst = genRandAccessBurst(rach_delay, sps, n);
         break;
-      case Transceiver::FILLER_ZERO:
+      case FILLER_ZERO:
       default:
         burst = generateEmptyBurst(sps, n);
       }
@@ -102,8 +102,8 @@
       fillerTable[i][n] = burst;
     }
 
-    if ((filler == Transceiver::FILLER_NORM_RAND) ||
-        (filler == Transceiver::FILLER_EDGE_RAND)) {
+    if ((filler == FILLER_NORM_RAND) ||
+        (filler == FILLER_EDGE_RAND)) {
         chanType[n] = TSC;
     }
   }
@@ -161,7 +161,7 @@
  * are still expected to report clock indications through control channel
  * activity.
  */
-bool Transceiver::init(int filler, size_t rtsc, unsigned rach_delay, bool edge)
+bool Transceiver::init(FillerType filler, size_t rtsc, unsigned rach_delay, bool edge)
 {
   int d_srcport, d_dstport, c_srcport, c_dstport;
 
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index ad7a469..f9b54f0 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -30,6 +30,10 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
+extern "C" {
+#include "config_defs.h"
+}
+
 class Transceiver;
 
 /** Channel descriptor for transceiver object and channel number pair */
@@ -54,7 +58,7 @@
   ~TransceiverState();
 
   /* Initialize a multiframe slot in the filler table */
-  bool init(int filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay);
+  bool init(FillerType filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay);
 
   int chanType[8];
 
@@ -109,7 +113,7 @@
   ~Transceiver();
 
   /** Start the control loop */
-  bool init(int filler, size_t rtsc, unsigned rach_delay, bool edge);
+  bool init(FillerType filler, size_t rtsc, unsigned rach_delay, bool edge);
 
   /** attach the radioInterface receive FIFO */
   bool receiveFIFO(VectorFIFO *wFIFO, size_t chan)
@@ -143,14 +147,6 @@
     NONE,               ///< Channel is inactive, default
     LOOPBACK            ///< similar go VII, used in loopback testing
   } ChannelCombination;
-
-  enum FillerType {
-    FILLER_DUMMY,
-    FILLER_ZERO,
-    FILLER_NORM_RAND,
-    FILLER_EDGE_RAND,
-    FILLER_ACCESS_RAND,
-  };
 
 private:
   int mBasePort;
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index db0a813..dc4e1c8 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -91,7 +91,7 @@
 	unsigned rach_delay;
 	bool extref;
 	bool gpsref;
-	Transceiver::FillerType filler;
+	FillerType filler;
 	bool mcbts;
 	double offset;
 	double rssi_offset;
@@ -140,19 +140,19 @@
 		refstr = "Internal";
 
 	switch (config->filler) {
-	case Transceiver::FILLER_DUMMY:
+	case FILLER_DUMMY:
 		fillstr = "Dummy bursts";
 		break;
-	case Transceiver::FILLER_ZERO:
+	case FILLER_ZERO:
 		fillstr = "Disabled";
 		break;
-	case Transceiver::FILLER_NORM_RAND:
+	case FILLER_NORM_RAND:
 		fillstr = "Normal busrts with random payload";
 		break;
-	case Transceiver::FILLER_EDGE_RAND:
+	case FILLER_EDGE_RAND:
 		fillstr = "EDGE busrts with random payload";
 		break;
-	case Transceiver::FILLER_ACCESS_RAND:
+	case FILLER_ACCESS_RAND:
 		fillstr = "Access busrts with random payload";
 		break;
 	}
@@ -348,7 +348,7 @@
 	config->rach_delay = 0;
 	config->extref = false;
 	config->gpsref = false;
-	config->filler = Transceiver::FILLER_ZERO;
+	config->filler = FILLER_ZERO;
 	config->mcbts = false;
 	config->offset = 0.0;
 	config->rssi_offset = 0.0;
@@ -389,7 +389,7 @@
 			config->gpsref = true;
 			break;
 		case 'f':
-			config->filler = Transceiver::FILLER_DUMMY;
+			config->filler = FILLER_DUMMY;
 			break;
 		case 'o':
 			config->offset = atof(optarg);
@@ -402,11 +402,11 @@
 			break;
 		case 'r':
 			config->rtsc = atoi(optarg);
-			config->filler = Transceiver::FILLER_NORM_RAND;
+			config->filler = FILLER_NORM_RAND;
 			break;
 		case 'A':
 			config->rach_delay = atoi(optarg);
-			config->filler = Transceiver::FILLER_ACCESS_RAND;
+			config->filler = FILLER_ACCESS_RAND;
 			break;
 		case 'R':
 			config->rssi_offset = atof(optarg);
@@ -448,8 +448,8 @@
 		goto bad_config;
 	}
 
-	if (config->edge && (config->filler == Transceiver::FILLER_NORM_RAND))
-		config->filler = Transceiver::FILLER_EDGE_RAND;
+	if (config->edge && (config->filler == FILLER_NORM_RAND))
+		config->filler = FILLER_EDGE_RAND;
 
 	if ((config->tx_sps != 1) && (config->tx_sps != 4) &&
 	    (config->rx_sps != 1) && (config->rx_sps != 4)) {
@@ -521,11 +521,11 @@
 		iface = RadioDevice::MULTI_ARFCN;
 
 	if (config->extref)
-		ref = RadioDevice::REF_EXTERNAL;
+		ref = REF_EXTERNAL;
 	else if (config->gpsref)
-		ref = RadioDevice::REF_GPS;
+		ref = REF_GPS;
 	else
-		ref = RadioDevice::REF_INTERNAL;
+		ref = REF_INTERNAL;
 
 	usrp = RadioDevice::make(config->tx_sps, config->rx_sps, iface,
 				 config->chans, config->offset, config->tx_paths, config->rx_paths);
diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h
index dfa1c78..9913de0 100644
--- a/Transceiver52M/radioDevice.h
+++ b/Transceiver52M/radioDevice.h
@@ -18,6 +18,10 @@
 #include <string>
 #include <vector>
 
+extern "C" {
+#include "config_defs.h"
+}
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -41,12 +45,6 @@
     RESAMP_64M,
     RESAMP_100M,
     MULTI_ARFCN,
-  };
-
-  enum ReferenceType {
-    REF_INTERNAL,
-    REF_EXTERNAL,
-    REF_GPS,
   };
 
   static RadioDevice *make(size_t tx_sps, size_t rx_sps, InterfaceType type,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3d5b0576aa96869756f1629a40306c0043b6304b
Gerrit-PatchSet: 6
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list