Change in ...osmo-trx[master]: Transceiver: Clean up receival of downlink bursts

laforge gerrit-no-reply at lists.osmocom.org
Mon Aug 26 18:50:59 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-trx/+/15288 )

Change subject: Transceiver: Clean up receival of downlink bursts
......................................................................

Transceiver: Clean up receival of downlink bursts

Use a packed structure to clearly indicate what is contained in the
received buffer.

Change-Id: I4d8c0e3c0c717699889f79e50c778d14b6058f2d
---
M Transceiver52M/Transceiver.cpp
M Transceiver52M/proto_trxd.h
2 files changed, 31 insertions(+), 25 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 244f372..0a78c11 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -929,8 +929,8 @@
 {
   int msgLen;
   int burstLen;
-  char buffer[EDGE_BURST_NBITS + 50];
-  struct trxd_hdr_common *chdr;
+  struct trxd_hdr_v01_dl *dl;
+  char buffer[sizeof(*dl) + EDGE_BURST_NBITS];
   uint32_t fn;
 
   // check data socket
@@ -940,54 +940,53 @@
     return false;
   }
 
-  if (msgLen == gSlotLen + 1 + 4 + 1) {
-    burstLen = gSlotLen;
-  } else if (msgLen == EDGE_BURST_NBITS + 1 + 4 + 1) {
-    if (mSPSTx != 4)
+  switch (msgLen) {
+    case sizeof(*dl) + gSlotLen: /* GSM burst */
+      burstLen = gSlotLen;
+      break;
+    case sizeof(*dl) + EDGE_BURST_NBITS: /* EDGE burst */
+      if (mSPSTx != 4) {
+        LOG(ERR) << "EDGE burst received but SPS is set to " << mSPSTx;
+        return false;
+      }
+      burstLen = EDGE_BURST_NBITS;
+      break;
+    default:
+      LOG(ERR) << "badly formatted packet on GSM->TRX interface (len="<< msgLen << ")";
       return false;
-
-    burstLen = EDGE_BURST_NBITS;
-  } else {
-    LOG(ERR) << "badly formatted packet on GSM->TRX interface";
-    return false;
   }
 
-  /* Common header part: HDR version, TDMA TN & FN */
-  chdr = (struct trxd_hdr_common *) buffer;
+  dl = (struct trxd_hdr_v01_dl *) buffer;
 
   /* Convert TDMA FN to the host endianness */
-  fn = osmo_load32be(&chdr->fn);
+  fn = osmo_load32be(&dl->common.fn);
 
   /* Make sure we support the received header format */
-  switch (chdr->version) {
+  switch (dl->common.version) {
   case 0:
   /* Version 1 has the same format */
   case 1:
     break;
-
   default:
-    LOG(ERR) << "Rx TRXD message with unknown header version " << chdr->version;
+    LOG(ERR) << "Rx TRXD message with unknown header version " << dl->common.version;
     return false;
   }
 
-  LOG(DEBUG) << "Rx TRXD message (hdr_ver=" << chdr->version << "): "
-             << "fn=" << fn << ", tn=" << chdr->tn << ", "
+  LOG(DEBUG) << "Rx TRXD message (hdr_ver=" << dl->common.version << "): "
+             << "fn=" << fn << ", tn=" << dl->common.tn << ", "
              << "burst_len=" << burstLen;
 
-  int RSSI = (int) buffer[5];
   BitVector newBurst(burstLen);
   BitVector::iterator itr = newBurst.begin();
-  char *bufferItr = buffer+6;
+  uint8_t *bufferItr = dl->soft_bits;
   while (itr < newBurst.end())
     *itr++ = *bufferItr++;
 
-  GSM::Time currTime = GSM::Time(fn, chdr->tn);
+  GSM::Time currTime = GSM::Time(fn, dl->common.tn);
 
-  addRadioVector(chan, newBurst, RSSI, currTime);
+  addRadioVector(chan, newBurst, dl->tx_att, currTime);
 
   return true;
-
-
 }
 
 void Transceiver::driveReceiveRadio()
diff --git a/Transceiver52M/proto_trxd.h b/Transceiver52M/proto_trxd.h
index 7eb5dac..d72cfdd 100644
--- a/Transceiver52M/proto_trxd.h
+++ b/Transceiver52M/proto_trxd.h
@@ -66,6 +66,13 @@
 	uint8_t soft_bits[0];
 } __attribute__ ((packed));
 
+/* Downlink burst (BTS->TRX), v0 anf v1 use same format */
+struct trxd_hdr_v01_dl {
+	struct trxd_hdr_common common;
+	uint8_t tx_att; /* Tx Attentuation */
+	uint8_t soft_bits[0];
+} __attribute__ ((packed));
+
 
 #define TRXD_MODULATION_GMSK(ts_set) (0b0000 | (ts_set & 0b0011))
 #define TRXD_MODULATION_8PSK(ts_set) (0b0100 | (ts_set & 0b0001))

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

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I4d8c0e3c0c717699889f79e50c778d14b6058f2d
Gerrit-Change-Number: 15288
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190826/0dd03239/attachment.html>


More information about the gerrit-log mailing list