diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-07-04 13:02:12 +0200 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2019-07-19 11:44:13 +0000 |
commit | 7ee2d10113700f0b3711ba99dfe1cd6abd4407b9 (patch) | |
tree | 38e50a4c4d520dc739a34cbdcb5485eb04a7693f /Transceiver52M | |
parent | 252564b50ea585c02d30d422aa3afcff9df9a7f8 (diff) |
sigProcLib: detectAnyBurst() family: Use struct to gather all out params
Currently we have 2 out parameters, but in forthcoming commits will add
a third one. All those functions already have too many parameters, so
let's put together all the output params in a struct to pass them easily
and make it easier to understand they are the estimated output values.
Related: OS#4006
Change-Id: I05cfa0ceaa2e633a5e6e404e2eae497ff4442dea
Diffstat (limited to 'Transceiver52M')
-rw-r--r-- | Transceiver52M/Transceiver.cpp | 10 | ||||
-rw-r--r-- | Transceiver52M/sigProcLib.cpp | 63 | ||||
-rw-r--r-- | Transceiver52M/sigProcLib.h | 17 |
3 files changed, 45 insertions, 45 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 4462cdd..5c5707b 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -575,8 +575,8 @@ void writeToFile(radioVector *radio_burst, size_t chan) bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi) { int rc; - complex amp; - float toa, max = -1.0, avg = 0.0; + struct estim_burst_params ebp; + float max = -1.0, avg = 0.0; unsigned max_toa; int max_i = -1; signalVector *burst; @@ -654,7 +654,7 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi) mMaxExpectedDelayAB : mMaxExpectedDelayNB; /* Detect normal or RACH bursts */ - rc = detectAnyBurst(*burst, mTSC, BURST_THRESH, mSPSRx, type, amp, toa, max_toa); + rc = detectAnyBurst(*burst, mTSC, BURST_THRESH, mSPSRx, type, max_toa, &ebp); if (rc <= 0) { if (rc == -SIGERR_CLIP) LOG(WARNING) << "Clipping detected on received RACH or Normal Burst"; @@ -664,8 +664,8 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi) } type = (CorrType) rc; - bi->toa = toa; - rxBurst = demodAnyBurst(*burst, mSPSRx, amp, toa, type); + bi->toa = ebp.toa; + rxBurst = demodAnyBurst(*burst, mSPSRx, ebp.amp, ebp.toa, type); /* EDGE demodulator returns 444 (gSlotLen * 3) bits */ if (rxBurst->size() == EDGE_BURST_NBITS) diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index cff7825..52a6701 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -1463,8 +1463,8 @@ static signalVector *downsampleBurst(const signalVector &burst) */ static int detectBurst(const signalVector &burst, signalVector &corr, CorrelationSequence *sync, - float thresh, int sps, complex *amp, float *toa, - int start, int len) + float thresh, int sps, int start, int len, + struct estim_burst_params *ebp) { const signalVector *corr_in; signalVector *dec = NULL; @@ -1490,23 +1490,23 @@ static int detectBurst(const signalVector &burst, sps = 1; /* Peak detection - place restrictions at correlation edges */ - *amp = fastPeakDetect(corr, toa); + ebp->amp = fastPeakDetect(corr, &ebp->toa); - if ((*toa < 3 * sps) || (*toa > len - 3 * sps)) + if ((ebp->toa < 3 * sps) || (ebp->toa > len - 3 * sps)) return 0; /* Peak -to-average ratio */ - if (computePeakRatio(&corr, sps, *toa, *amp) < thresh) + if (computePeakRatio(&corr, sps, ebp->toa, ebp->amp) < thresh) return 0; /* Compute peak-to-average ratio. Reject if we don't have enough values */ - *amp = peakDetect(corr, toa, NULL); + ebp->amp = peakDetect(corr, &ebp->toa, NULL); /* Normalize our channel gain */ - *amp = *amp / sync->gain; + ebp->amp = ebp->amp / sync->gain; /* Compensate for residuate time lag */ - *toa = *toa - sync->toa; + ebp->toa = ebp->toa - sync->toa; return 1; } @@ -1532,13 +1532,10 @@ static float maxAmplitude(const signalVector &burst) * head: Search symbols before target * tail: Search symbols after target */ -static int detectGeneralBurst(const signalVector &rxBurst, - float thresh, - int sps, - complex &, - float &toa, +static int detectGeneralBurst(const signalVector &rxBurst, float thresh, int sps, int target, int head, int tail, - CorrelationSequence *sync) + CorrelationSequence *sync, + struct estim_burst_params *ebp) { int rc, start, len; bool clipping = false; @@ -1560,17 +1557,17 @@ static int detectGeneralBurst(const signalVector &rxBurst, signalVector corr(len); rc = detectBurst(rxBurst, corr, sync, - thresh, sps, &, &toa, start, len); + thresh, sps, start, len, ebp); if (rc < 0) { return -SIGERR_INTERNAL; } else if (!rc) { - amp = 0.0f; - toa = 0.0f; + ebp->amp = 0.0f; + ebp->toa = 0.0f; return clipping?-SIGERR_CLIP:SIGERR_NONE; } /* Subtract forward search bits from delay */ - toa -= head; + ebp->toa -= head; return 1; } @@ -1585,7 +1582,7 @@ static int detectGeneralBurst(const signalVector &rxBurst, * tail: Search 8 symbols + maximum expected delay */ static int detectRACHBurst(const signalVector &burst, float threshold, int sps, - complex &litude, float &toa, unsigned max_toa, bool ext) + unsigned max_toa, bool ext, struct estim_burst_params *ebp) { int rc, target, head, tail; int i, num_seq; @@ -1596,8 +1593,8 @@ static int detectRACHBurst(const signalVector &burst, float threshold, int sps, num_seq = ext ? 3 : 1; for (i = 0; i < num_seq; i++) { - rc = detectGeneralBurst(burst, threshold, sps, amplitude, toa, - target, head, tail, gRACHSequences[i]); + rc = detectGeneralBurst(burst, threshold, sps, target, head, tail, + gRACHSequences[i], ebp); if (rc > 0) break; } @@ -1614,7 +1611,7 @@ static int detectRACHBurst(const signalVector &burst, float threshold, int sps, * tail: Search 6 symbols + maximum expected delay */ static int analyzeTrafficBurst(const signalVector &burst, unsigned tsc, float threshold, - int sps, complex &litude, float &toa, unsigned max_toa) + int sps, unsigned max_toa, struct estim_burst_params *ebp) { int rc, target, head, tail; CorrelationSequence *sync; @@ -1627,13 +1624,12 @@ static int analyzeTrafficBurst(const signalVector &burst, unsigned tsc, float th tail = 6 + max_toa; sync = gMidambles[tsc]; - rc = detectGeneralBurst(burst, threshold, sps, amplitude, toa, - target, head, tail, sync); + rc = detectGeneralBurst(burst, threshold, sps, target, head, tail, sync, ebp); return rc; } static int detectEdgeBurst(const signalVector &burst, unsigned tsc, float threshold, - int sps, complex &litude, float &toa, unsigned max_toa) + int sps, unsigned max_toa, struct estim_burst_params *ebp) { int rc, target, head, tail; CorrelationSequence *sync; @@ -1646,33 +1642,30 @@ static int detectEdgeBurst(const signalVector &burst, unsigned tsc, float thresh tail = 6 + max_toa; sync = gEdgeMidambles[tsc]; - rc = detectGeneralBurst(burst, threshold, sps, amplitude, toa, - target, head, tail, sync); + rc = detectGeneralBurst(burst, threshold, sps, + target, head, tail, sync, ebp); return rc; } int detectAnyBurst(const signalVector &burst, unsigned tsc, float threshold, - int sps, CorrType type, complex &, float &toa, - unsigned max_toa) + int sps, CorrType type, unsigned max_toa, + struct estim_burst_params *ebp) { int rc = 0; switch (type) { case EDGE: - rc = detectEdgeBurst(burst, tsc, threshold, sps, - amp, toa, max_toa); + rc = detectEdgeBurst(burst, tsc, threshold, sps, max_toa, ebp); if (rc > 0) break; else type = TSC; case TSC: - rc = analyzeTrafficBurst(burst, tsc, threshold, sps, - amp, toa, max_toa); + rc = analyzeTrafficBurst(burst, tsc, threshold, sps, max_toa, ebp); break; case EXT_RACH: case RACH: - rc = detectRACHBurst(burst, threshold, sps, amp, toa, - max_toa, type == EXT_RACH); + rc = detectRACHBurst(burst, threshold, sps, max_toa, type == EXT_RACH, ebp); break; default: LOG(ERR) << "Invalid correlation type"; diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h index bae2127..8442cfc 100644 --- a/Transceiver52M/sigProcLib.h +++ b/Transceiver52M/sigProcLib.h @@ -101,15 +101,23 @@ void scaleVector(signalVector &x, */ float energyDetect(const signalVector &rxBurst, unsigned windowLength); + +/** Struct used to fill out parameters in detectAnyBurst(): estimated burst parameters +@param amplitude The estimated amplitude of received TSC burst. +@param toa The estimated time-of-arrival of received TSC burst (in symbols). +*/ +struct estim_burst_params { + complex amp; + float toa; +}; /** 8-PSK/GMSK/RACH burst detector @param burst The received GSM burst of interest @param tsc Midamble type (0..7) also known as TSC @param threshold The threshold that the received burst's post-correlator SNR is compared against to determine validity. @param sps The number of samples per GSM symbol. - @param amplitude The estimated amplitude of received TSC burst. - @param toa The estimate time-of-arrival of received TSC burst (in symbols). @param max_toa The maximum expected time-of-arrival (in symbols). + @param ebp The estimated parameters of the detected burst. @return positive value (CorrType) if threshold value is reached, negative value (-SignalError) on error, zero (SIGERR_NONE) if no burst is detected @@ -119,9 +127,8 @@ int detectAnyBurst(const signalVector &burst, float threshold, int sps, CorrType type, - complex &, - float &toa, - unsigned max_toa); + unsigned max_toa, + struct estim_burst_params *ebp); /** Demodulate burst basde on type and output soft bits */ SoftVector *demodAnyBurst(const signalVector &burst, int sps, |