Change in osmo-trx[master]: lms,uhd: Validate band of RxFreq too

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

pespin gerrit-no-reply at lists.osmocom.org
Tue Sep 21 12:14:57 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/25522 )


Change subject: lms,uhd: Validate band of RxFreq too
......................................................................

lms,uhd: Validate band of RxFreq too

So far the validation is only done on TxFreq for all TRX. Let's also do
it for RxFreq.

Change-Id: I30eef2727ee96b1344aa1416edd66e2302b88964
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/uhd/UHDDevice.cpp
2 files changed, 34 insertions(+), 0 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 30fd665..7aa8aa6 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -1026,8 +1026,25 @@
 
 bool LMSDevice::setRxFreq(double wFreq, size_t chan)
 {
+	uint16_t req_arfcn;
+	enum gsm_band req_band;
+
 	LOGCHAN(chan, DDEV, NOTICE) << "Setting Rx Freq to " << wFreq << " Hz";
 
+	req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100 , 0);
+	if (req_arfcn == 0xffff) {
+		LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Tx Frequency " << wFreq / 1000 << " kHz";
+		return false;
+	}
+	if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) {
+		LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Tx Frequency " << wFreq
+					   << " Hz (ARFCN " << req_arfcn << " )";
+		return false;
+	}
+
+	if (!set_band(req_band))
+		return false;
+
 	if (LMS_SetLOFrequency(m_lms_dev, LMS_CH_RX, chan, wFreq) < 0) {
 		LOGCHAN(chan, DDEV, ERROR) << "Error setting Rx Freq to " << wFreq << " Hz";
 		return false;
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 5486822..dd0a420 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -1102,12 +1102,29 @@
 
 bool uhd_device::setRxFreq(double wFreq, size_t chan)
 {
+	uint16_t req_arfcn;
+	enum gsm_band req_band;
+
 	if (chan >= rx_freqs.size()) {
 		LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
 		return false;
 	}
 	ScopedLock lock(tune_lock);
 
+	req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100 , 1);
+	if (req_arfcn == 0xffff) {
+		LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Rx Frequency " << wFreq / 1000 << " kHz";
+		return false;
+	}
+	if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) {
+		LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Rx Frequency " << wFreq
+					   << " Hz (ARFCN " << req_arfcn << " )";
+		return false;
+	}
+
+	if (!set_band(req_band))
+		return false;
+
 	return set_freq(wFreq, chan, false);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/25522
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I30eef2727ee96b1344aa1416edd66e2302b88964
Gerrit-Change-Number: 25522
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210921/ce1ae3cc/attachment.htm>


More information about the gerrit-log mailing list