mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-18 06:12:47 -04:00
Fix linux errors
This commit is contained in:
parent
32c94dccc3
commit
59472e5b5b
@ -176,7 +176,6 @@ void RadiosondeDemodSink::processOneSample(Complex &ci)
|
|||||||
// Try to see if starting at a later sample improves correlation
|
// Try to see if starting at a later sample improves correlation
|
||||||
int maxCorrOffset = 0;
|
int maxCorrOffset = 0;
|
||||||
Real maxCorr;
|
Real maxCorr;
|
||||||
Real initCorr = fabs(corr);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
maxCorr = fabs(corr);
|
maxCorr = fabs(corr);
|
||||||
@ -201,9 +200,7 @@ void RadiosondeDemodSink::processOneSample(Complex &ci)
|
|||||||
// Attempt to demodulate
|
// Attempt to demodulate
|
||||||
uint64_t bits = 0;
|
uint64_t bits = 0;
|
||||||
int bitCount = 0;
|
int bitCount = 0;
|
||||||
int onesCount = 0;
|
|
||||||
int byteCount = 0;
|
int byteCount = 0;
|
||||||
int symbolPrev = 0;
|
|
||||||
QList<int> sampleIdxs;
|
QList<int> sampleIdxs;
|
||||||
for (int sampleIdx = 0; sampleIdx < m_rxBufLength; sampleIdx += m_samplesPerSymbol)
|
for (int sampleIdx = 0; sampleIdx < m_rxBufLength; sampleIdx += m_samplesPerSymbol)
|
||||||
{
|
{
|
||||||
@ -238,17 +235,16 @@ void RadiosondeDemodSink::processOneSample(Complex &ci)
|
|||||||
bits = 0;
|
bits = 0;
|
||||||
bitCount = 0;
|
bitCount = 0;
|
||||||
|
|
||||||
if (byteCount >= RADIOSONDE_LENGTH_STD)
|
if (byteCount >= RS41_LENGTH_STD)
|
||||||
{
|
{
|
||||||
// Get expected length of frame
|
// Get expected length of frame
|
||||||
uint8_t frameType = m_bytes[RADIOSONDE_OFFSET_FRAME_TYPE] ^ m_descramble[RADIOSONDE_OFFSET_FRAME_TYPE];
|
uint8_t frameType = m_bytes[RS41_OFFSET_FRAME_TYPE] ^ m_descramble[RS41_OFFSET_FRAME_TYPE];
|
||||||
int length = RS41Frame::getFrameLength(frameType);
|
int length = RS41Frame::getFrameLength(frameType);
|
||||||
|
|
||||||
// Have we received a complete frame?
|
// Have we received a complete frame?
|
||||||
if (byteCount == length)
|
if (byteCount == length)
|
||||||
{
|
{
|
||||||
int firstError;
|
bool ok = processFrame(length, corr, sampleIdx);
|
||||||
bool ok = processFrame(length, corr, sampleIdx, &firstError);
|
|
||||||
scopeCRCValid = ok;
|
scopeCRCValid = ok;
|
||||||
scopeCRCInvalid = !ok;
|
scopeCRCInvalid = !ok;
|
||||||
break;
|
break;
|
||||||
@ -405,7 +401,7 @@ Real RadiosondeDemodSink::correlate(int idx) const
|
|||||||
return corr;
|
return corr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadiosondeDemodSink::processFrame(int length, float corr, int sampleIdx, int *firstError)
|
bool RadiosondeDemodSink::processFrame(int length, float corr, int sampleIdx)
|
||||||
{
|
{
|
||||||
// Descramble
|
// Descramble
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
@ -438,24 +434,24 @@ bool RadiosondeDemodSink::processFrame(int length, float corr, int sampleIdx, in
|
|||||||
// Returns number of errors corrected, or -1 if there are uncorrectable errors
|
// Returns number of errors corrected, or -1 if there are uncorrectable errors
|
||||||
int RadiosondeDemodSink::reedSolomonErrorCorrection()
|
int RadiosondeDemodSink::reedSolomonErrorCorrection()
|
||||||
{
|
{
|
||||||
ReedSolomon::RS<RADIOSONDE_RS_N,RADIOSONDE_RS_K> rs;
|
ReedSolomon::RS<RS41_RS_N,RS41_RS_K> rs;
|
||||||
int errorsCorrected = 0;
|
int errorsCorrected = 0;
|
||||||
|
|
||||||
for (int i = 0; (i < RADIOSONDE_RS_INTERLEAVE) && (errorsCorrected >= 0); i++)
|
for (int i = 0; (i < RS41_RS_INTERLEAVE) && (errorsCorrected >= 0); i++)
|
||||||
{
|
{
|
||||||
// Deinterleave and reverse order
|
// Deinterleave and reverse order
|
||||||
uint8_t rsData[RADIOSONDE_RS_N];
|
uint8_t rsData[RS41_RS_N];
|
||||||
|
|
||||||
memset(rsData, 0, RADIOSONDE_RS_PAD);
|
memset(rsData, 0, RS41_RS_PAD);
|
||||||
for (int j = 0; j < RADIOSONDE_RS_DATA; j++) {
|
for (int j = 0; j < RS41_RS_DATA; j++) {
|
||||||
rsData[RADIOSONDE_RS_K-1-j] = m_bytes[RADIOSONDE_OFFSET_FRAME_TYPE+j*RADIOSONDE_RS_INTERLEAVE+i];
|
rsData[RS41_RS_K-1-j] = m_bytes[RS41_OFFSET_FRAME_TYPE+j*RS41_RS_INTERLEAVE+i];
|
||||||
}
|
}
|
||||||
for (int j = 0; j < RADIOSONDE_RS_2T; j++) {
|
for (int j = 0; j < RS41_RS_2T; j++) {
|
||||||
rsData[RADIOSONDE_RS_N-1-j] = m_bytes[RADIOSONDE_OFFSET_RS+i*RADIOSONDE_RS_2T+j];
|
rsData[RS41_RS_N-1-j] = m_bytes[RS41_OFFSET_RS+i*RS41_RS_2T+j];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect and correct errors
|
// Detect and correct errors
|
||||||
int errors = rs.decode(&rsData[0], RADIOSONDE_RS_K); // FIXME: Indicate 0 padding?
|
int errors = rs.decode(&rsData[0], RS41_RS_K); // FIXME: Indicate 0 padding?
|
||||||
if (errors >= 0) {
|
if (errors >= 0) {
|
||||||
errorsCorrected += errors;
|
errorsCorrected += errors;
|
||||||
} else {
|
} else {
|
||||||
@ -464,8 +460,8 @@ int RadiosondeDemodSink::reedSolomonErrorCorrection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore corrected data
|
// Restore corrected data
|
||||||
for (int j = 0; j < RADIOSONDE_RS_DATA; j++) {
|
for (int j = 0; j < RS41_RS_DATA; j++) {
|
||||||
m_bytes[RADIOSONDE_OFFSET_FRAME_TYPE+j*RADIOSONDE_RS_INTERLEAVE+i] = rsData[RADIOSONDE_RS_K-1-j];
|
m_bytes[RS41_OFFSET_FRAME_TYPE+j*RS41_RS_INTERLEAVE+i] = rsData[RS41_RS_K-1-j];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -476,9 +472,8 @@ int RadiosondeDemodSink::reedSolomonErrorCorrection()
|
|||||||
// We could pass partial frames that have some correct CRCs, but for now, whole frame has to be correct
|
// We could pass partial frames that have some correct CRCs, but for now, whole frame has to be correct
|
||||||
bool RadiosondeDemodSink::checkCRCs(int length)
|
bool RadiosondeDemodSink::checkCRCs(int length)
|
||||||
{
|
{
|
||||||
for (int i = RADIOSONDE_OFFSET_BLOCK_0; i < length; )
|
for (int i = RS41_OFFSET_BLOCK_0; i < length; )
|
||||||
{
|
{
|
||||||
uint8_t blockID = m_bytes[i+0];
|
|
||||||
uint8_t blockLength = m_bytes[i+1];
|
uint8_t blockLength = m_bytes[i+1];
|
||||||
uint16_t rxCrc = m_bytes[i+2+blockLength] | (m_bytes[i+2+blockLength+1] << 8);
|
uint16_t rxCrc = m_bytes[i+2+blockLength] | (m_bytes[i+2+blockLength+1] << 8);
|
||||||
// CRC doesn't include ID/len - so these can be wrong
|
// CRC doesn't include ID/len - so these can be wrong
|
||||||
|
@ -134,7 +134,7 @@ private:
|
|||||||
MessageQueue *getMessageQueueToChannel() { return m_messageQueueToChannel; }
|
MessageQueue *getMessageQueueToChannel() { return m_messageQueueToChannel; }
|
||||||
void processOneSample(Complex &ci);
|
void processOneSample(Complex &ci);
|
||||||
Real correlate(int idx) const;
|
Real correlate(int idx) const;
|
||||||
bool processFrame(int length, float corr, int sampleIdx, int *firstError);
|
bool processFrame(int length, float corr, int sampleIdx);
|
||||||
int reedSolomonErrorCorrection();
|
int reedSolomonErrorCorrection();
|
||||||
bool checkCRCs(int length);
|
bool checkCRCs(int length);
|
||||||
void sampleToScope(Complex sample);
|
void sampleToScope(Complex sample);
|
||||||
|
@ -38,8 +38,8 @@ RS41Frame::RS41Frame(const QByteArray ba) :
|
|||||||
m_longitude(0.0),
|
m_longitude(0.0),
|
||||||
m_height(0.0),
|
m_height(0.0),
|
||||||
m_bytes(ba),
|
m_bytes(ba),
|
||||||
m_temperatureCalibrated(false),
|
|
||||||
m_pressureCalibrated(false),
|
m_pressureCalibrated(false),
|
||||||
|
m_temperatureCalibrated(false),
|
||||||
m_humidityTemperatureCalibrated(false),
|
m_humidityTemperatureCalibrated(false),
|
||||||
m_humidityCalibrated(false)
|
m_humidityCalibrated(false)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user