diff options
-rw-r--r-- | Transceiver52M/Transceiver.cpp | 33 | ||||
-rw-r--r-- | Transceiver52M/Transceiver.h | 12 | ||||
-rw-r--r-- | Transceiver52M/sigProcLib.cpp | 46 |
3 files changed, 55 insertions, 36 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 587ade6..9fc335a 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -534,9 +534,9 @@ Transceiver::CorrType Transceiver::expectedCorrType(GSM::Time currTime, * Detect RACH synchronization sequence within a burst. No equalization * is used or available on the RACH channel. */ -bool Transceiver::detectRACH(TransceiverState *state, - signalVector &burst, - complex &, float &toa) +int Transceiver::detectRACH(TransceiverState *state, + signalVector &burst, + complex &, float &toa) { float threshold = 6.0; @@ -548,9 +548,10 @@ bool Transceiver::detectRACH(TransceiverState *state, * state information and channel estimate if necessary. Equalization * is currently disabled. */ -bool Transceiver::detectTSC(TransceiverState *state, signalVector &burst, - complex &, float &toa, GSM::Time &time) +int Transceiver::detectTSC(TransceiverState *state, signalVector &burst, + complex &, float &toa, GSM::Time &time) { + int success; int tn = time.TN(); float chanOffset, threshold = 5.0; bool noise, needDFE = false, estimateChan = false; @@ -568,10 +569,11 @@ bool Transceiver::detectTSC(TransceiverState *state, signalVector &burst, } /* Detect normal burst midambles */ - if (!analyzeTrafficBurst(burst, mTSC, threshold, mSPSRx, &, - &toa, mMaxExpectedDelay, estimateChan, - &chanResp, &chanOffset)) { - return false; + success = analyzeTrafficBurst(burst, mTSC, threshold, mSPSRx, &, + &toa, mMaxExpectedDelay, estimateChan, + &chanResp, &chanOffset); + if (success <= 0) { + return success; } noise = state->mNoiseLev; @@ -591,7 +593,7 @@ bool Transceiver::detectTSC(TransceiverState *state, signalVector &burst, state->chanEstimateTime[tn] = time; } - return true;; + return 1; } /* @@ -622,7 +624,8 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, double &RSSI, double &timingOffset, double &noise, size_t chan) { - bool success, equalize = false; + int success; + bool equalize = false; complex amp; float toa, pow, max = -1.0, avg = 0.0; int max_i = -1; @@ -673,12 +676,12 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, double &RSSI, /* Update noise average if no bust detected or alert on error */ if (success <= 0) { - if (!success) { + if (success == SIGERR_NONE) { state->mNoises.insert(avg); } else if (success == -SIGERR_CLIP) { - LOG(ALERT) << "Clipping detected on RACH input"; - } else if (success < 0) { - LOG(ALERT) << "Unhandled RACH error"; + LOG(WARNING) << "Clipping detected on received RACH or Normal Burst"; + } else { + LOG(WARNING) << "Unhandled RACH or Normal Burst detection error"; } delete radio_burst; diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h index 1639d0d..a7b04ed 100644 --- a/Transceiver52M/Transceiver.h +++ b/Transceiver52M/Transceiver.h @@ -209,14 +209,14 @@ private: void writeClockInterface(void); /** Detect RACH bursts */ - bool detectRACH(TransceiverState *state, - signalVector &burst, - complex &, float &toa); + int detectRACH(TransceiverState *state, + signalVector &burst, + complex &, float &toa); /** Detect normal bursts */ - bool detectTSC(TransceiverState *state, - signalVector &burst, - complex &, float &toa, GSM::Time &time); + int detectTSC(TransceiverState *state, + signalVector &burst, + complex &, float &toa, GSM::Time &time); /** Demodulat burst and output soft bits */ SoftVector *demodulate(TransceiverState *state, diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index 9d8410b..42b4e6e 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -28,6 +28,7 @@ #include "sigProcLib.h" #include "GSMCommon.h" +#include "Logger.h" extern "C" { #include "convolve.h" @@ -1372,16 +1373,17 @@ static int detectBurst(signalVector &burst, return 1; } -static int detectClipping(signalVector &burst, float thresh) +static float maxAmplitude(signalVector &burst) { - for (size_t i = 0; i < burst.size(); i++) { - if (fabs(burst[i].real()) > thresh) - return 1; - if (fabs(burst[i].imag()) > thresh) - return 1; - } - - return 0; + float max = 0.0; + for (size_t i = 0; i < burst.size(); i++) { + if (fabs(burst[i].real()) > max) + max = fabs(burst[i].real()); + if (fabs(burst[i].imag()) > max) + max = fabs(burst[i].imag()); + } + + return max; } /* @@ -1399,6 +1401,7 @@ int detectRACHBurst(signalVector &rxBurst, float *toa) { int rc, start, target, head, tail, len; + bool clipping = false; float _toa; complex _amp; signalVector *corr; @@ -1407,8 +1410,14 @@ int detectRACHBurst(signalVector &rxBurst, if ((sps != 1) && (sps != 4)) return -SIGERR_UNSUPPORTED; - if (detectClipping(rxBurst, CLIP_THRESH)) - return -SIGERR_CLIP; + // Detect potential clipping + // We still may be able to demod the burst, so we'll give it a try + // and only report clipping if we can't demod. + float maxAmpl = maxAmplitude(rxBurst); + if (maxAmpl > CLIP_THRESH) { + LOG(DEBUG) << "max burst amplitude: " << maxAmpl << " is above the clipping threshold: " << CLIP_THRESH << std::endl; + clipping = true; + } target = 8 + 40; head = 4; @@ -1430,7 +1439,7 @@ int detectRACHBurst(signalVector &rxBurst, *amp = 0.0f; if (toa) *toa = 0.0f; - return 0; + return clipping?-SIGERR_CLIP:SIGERR_NONE; } /* Subtract forward search bits from delay */ @@ -1455,6 +1464,7 @@ int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh, bool chan_req, signalVector **chan, float *chan_offset) { int rc, start, target, head, tail, len; + bool clipping = false; complex _amp; float _toa; signalVector *corr; @@ -1463,8 +1473,14 @@ int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh, if ((tsc < 0) || (tsc > 7) || ((sps != 1) && (sps != 4))) return -SIGERR_UNSUPPORTED; - if (detectClipping(rxBurst, CLIP_THRESH)) - return -SIGERR_CLIP; + // Detect potential clipping + // We still may be able to demod the burst, so we'll give it a try + // and only report clipping if we can't demod. + float maxAmpl = maxAmplitude(rxBurst); + if (maxAmpl > CLIP_THRESH) { + LOG(DEBUG) << "max burst amplitude: " << maxAmpl << " is above the clipping threshold: " << CLIP_THRESH << std::endl; + clipping = true; + } target = 3 + 58 + 16 + 5; head = 4; @@ -1486,7 +1502,7 @@ int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh, *amp = 0.0f; if (toa) *toa = 0.0f; - return 0; + return clipping?-SIGERR_CLIP:SIGERR_NONE; } /* Subtract forward search bits from delay */ |