Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radiosonde: Fix pressure calculation. #2394

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions sdrbase/util/radiosonde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ QString RS41Frame::toHex()
return m_bytes.toHex();
}

int16_t RS41Frame::getInt16(const QByteArray ba, int offset) const
{
return (ba[offset] & 0xff)
| ((ba[offset+1] & 0xff) << 8);
}

uint16_t RS41Frame::getUInt16(const QByteArray ba, int offset) const
{
return (ba[offset] & 0xff)
Expand Down Expand Up @@ -130,7 +136,7 @@ void RS41Frame::decodeMeas(const QByteArray ba)
m_pressureMain = getUInt24(ba, 0x1b);
m_pressureRef1 = getUInt24(ba, 0x1e);
m_pressureRef2 = getUInt24(ba, 0x21);
m_pressureTemp = getUInt16(ba, 0x26) / 100.0f;
m_pressureTemp = getInt16(ba, 0x26) / 100.0f;
}

void RS41Frame::decodeGPSInfo(const QByteArray ba)
Expand Down Expand Up @@ -187,7 +193,7 @@ static float waterVapourSaturationPressure(float tCelsius)
return p / 100.0f;
}

static float calcT(int f, int f1, int f2, float r1, float r2, float *poly, float *cal)
static float calcT(int f, int f1, int f2, float r1, float r2, const float *poly, const float *cal)
{
/*float g = (float)(f2-f1) / (r2-r1); // gain
float Rb = (f1*r2-f2*r1) / (float)(f2-f1); // offset
Expand Down Expand Up @@ -219,7 +225,7 @@ static float calcT(int f, int f1, int f2, float r1, float r2, float *poly, float
return tCal;
}

static float calcU(int cInt, int cMin, int cMax, float c1, float c2, float T, float HT, float *capCal, float *matrixCal, float height, float *vectorPCal, float *matrixPCal)
static float calcU(int cInt, int cMin, int cMax, float c1, float c2, float T, float HT, const float *capCal, const float *matrixCal, float height, const float *vectorPCal, const float *matrixPCal)
{
//qDebug() << "cInt " << cInt << " cMin " << cMin << " cMax " << cMax << " c1 " << c1 << " c2 " << c2 << " T " << T << " HT " << HT << " capCal[0] " << capCal[0] << " capCal[1] " << capCal[1] << "height" << height;

Expand Down Expand Up @@ -302,7 +308,7 @@ static float calcU(int cInt, int cMin, int cMax, float c1, float c2, float T, fl
return uCal;
}

static float calcP(int f, int f1, int f2, float pressureTemp, float *cal)
static float calcP(int f, int f1, int f2, float pressureTemp, const float *cal)
{
// Convert integer measurement to scale factor
float s = (f-f1) / (float)(f2-f1);
Expand Down
1 change: 1 addition & 0 deletions sdrbase/util/radiosonde.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class SDRBASE_API RS41Frame {
static int getFrameLength(int frameType);

protected:
int16_t getInt16(const QByteArray ba, int offset) const;
uint16_t getUInt16(const QByteArray ba, int offset) const;
uint32_t getUInt24(const QByteArray ba, int offset) const;
uint32_t getUInt32(const QByteArray ba, int offset) const;
Expand Down
Loading