diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-07-01 17:55:01 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-07-02 15:05:17 +0200 |
commit | 7dc07b9425e2400c314248811f57091cb0ec7c07 (patch) | |
tree | 0313685667a05b2539506127430ff780522f15ce | |
parent | 07ddce5c1f7f68157a48da3b1e7513db45375da3 (diff) |
Transceiver: Get rid of SoftVector in struct trx_ul_burst_ind
Make the interface using trx_ul_burst_ind more implementation agnostic
as well as easier to use. For instance, we don't care about SoftVector
size one returned from pullRadioVector(); we want to use nbits instead.
As a result, we no longer spend time normalizing guard periods. While at
it, change vectorSLicer to return void since it always returns true.
Change-Id: I726e5a98a43367a22c9a4ca5cbd9eb87e6765c7a
-rw-r--r-- | Transceiver52M/Transceiver.cpp | 22 | ||||
-rw-r--r-- | Transceiver52M/Transceiver.h | 4 | ||||
-rw-r--r-- | Transceiver52M/sigProcLib.cpp | 22 | ||||
-rw-r--r-- | Transceiver52M/sigProcLib.h | 2 |
4 files changed, 29 insertions, 21 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 6e678ac..4fc277b 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -559,6 +559,7 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi) int max_i = -1; signalVector *burst; GSM::Time burstTime; + SoftVector *rxBurst; TransceiverState *state = &mStates[chan]; /* Blocking FIFO read */ @@ -644,17 +645,18 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi) } bi->toa = toa; - bi->rxBurst = demodAnyBurst(*burst, mSPSRx, amp, toa, type); + rxBurst = demodAnyBurst(*burst, mSPSRx, amp, toa, type); /* EDGE demodulator returns 444 (gSlotLen * 3) bits */ - if (bi->rxBurst->size() == EDGE_BURST_NBITS) + if (rxBurst->size() == EDGE_BURST_NBITS) bi->nbits = EDGE_BURST_NBITS; else /* size() here is actually gSlotLen + 8, due to guard periods */ bi->nbits = gSlotLen; // Convert -1..+1 soft bits to 0..1 soft bits - vectorSlicer(bi->rxBurst); + vectorSlicer(bi->rx_burst, rxBurst->begin(), bi->nbits); + delete rxBurst; delete radio_burst; return true; } @@ -914,6 +916,14 @@ void Transceiver::driveReceiveRadio() void Transceiver::logRxBurst(size_t chan, const struct trx_ul_burst_ind *bi) { + std::ostringstream os; + for (size_t i=0; i < bi->nbits; i++) { + if (bi->rx_burst[i] > 0.5) os << "1"; + else if (bi->rx_burst[i] > 0.25) os << "|"; + else if (bi->rx_burst[i] > 0.0) os << "'"; + else os << "-"; + } + LOG(DEBUG) << std::fixed << std::right << " chan: " << chan << " time: " << bi->tn << ":" << bi->fn @@ -922,7 +932,7 @@ void Transceiver::logRxBurst(size_t chan, const struct trx_ul_burst_ind *bi) << " noise: " << std::setw(5) << std::setprecision(1) << (bi->noise - rssiOffset) << "dBFS/" << std::setw(6) << -bi->noise << "dBm" << " TOA: " << std::setw(5) << std::setprecision(2) << bi->toa - << " bits: " << *(bi->rxBurst); + << " bits: " << os; } void Transceiver::driveReceiveFIFO(size_t chan) @@ -946,14 +956,12 @@ void Transceiver::driveReceiveFIFO(size_t chan) osmo_store32be(bi.fn, &pkt->common.fn); pkt->v0.rssi = bi.rssi; osmo_store16be(TOAint, &pkt->v0.toa); - SoftVector::iterator burstItr = bi.rxBurst->begin(); for (unsigned i = 0; i < bi.nbits; i++) - pkt->soft_bits[i] = (char) round((*burstItr++) * 255.0); + pkt->soft_bits[i] = (char) round(bi.rx_burst[i] * 255.0); /* +1: Historical reason. There's an uninitizalied byte in there: pkt->soft_bits[bi.nbits] */ pkt->soft_bits[bi.nbits + 1] = '\0'; - delete bi.rxBurst; mDataSockets[chan]->write(burstString, sizeof(struct trxd_hdr_v0) + bi.nbits + 2); } diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h index 9975823..80047b3 100644 --- a/Transceiver52M/Transceiver.h +++ b/Transceiver52M/Transceiver.h @@ -35,8 +35,10 @@ extern "C" { #include "config_defs.h" } +#define MAX_RX_BURST_BUF_SIZE EDGE_BURST_NBITS + struct trx_ul_burst_ind { - SoftVector *rxBurst; + float rx_burst[MAX_RX_BURST_BUF_SIZE]; /* soft bits normalized 0..1 */ unsigned nbits; // number of symbols per slot in rxBurst, not counting guard periods uint32_t fn; // TDMA frame number uint8_t tn; // TDMA time-slot number diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index fcda5fa..cff7825 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -530,19 +530,17 @@ static PulseSequence *generateGSMPulse(int sps) return pulse; } -bool vectorSlicer(SoftVector *x) +/* Convert -1..+1 soft bits to 0..1 soft bits */ +void vectorSlicer(float *dest, const float *src, size_t len) { - SoftVector::iterator xP = x->begin(); - SoftVector::iterator xPEnd = x->end(); - while (xP < xPEnd) { - *xP = 0.5 * (*xP + 1.0f); - if (*xP > 1.0) - *xP = 1.0; - if (*xP < 0.0) - *xP = 0.0; - xP++; - } - return true; + size_t i; + for (i = 0; i < len; i++) { + dest[i] = 0.5 * (src[i] + 1.0f); + if (dest[i] > 1.0) + dest[i] = 1.0; + else if (dest[i] < 0.0) + dest[i] = 0.0; + } } static signalVector *rotateBurst(const BitVector &wBurst, diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h index 79a5c3f..bae2127 100644 --- a/Transceiver52M/sigProcLib.h +++ b/Transceiver52M/sigProcLib.h @@ -59,7 +59,7 @@ bool sigProcLibSetup(); void sigProcLibDestroy(void); /** Operate soft slicer on a soft-bit vector */ -bool vectorSlicer(SoftVector *x); +void vectorSlicer(float *dest, const float *src, size_t len); /** GMSK modulate a GSM burst of bits */ signalVector *modulateBurst(const BitVector &wBurst, |