Skip to content

Commit

Permalink
Fixed satellite config for OpenGD77. Addresses #497.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed Jan 12, 2025
1 parent ad89e0c commit 13e121f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/codeplug.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public:
/** Implements a simple increment. */
inline Bit operator+ (unsigned int bits) const {
unsigned int tmp = 8 * byte + (7-bit) + bits;
return {tmp/8, (7 - bit % 8)};
return {tmp/8, (7 - (tmp % 8))};
}

/** Implements a simple increment. */
inline Bit operator- (unsigned int bits) const {
unsigned int tmp = 8 * byte + (7-bit) - bits;
return {tmp/8, (7 - bit % 8)};
return {tmp/8, (7 - (tmp % 8))};
}
};
};
Expand Down
32 changes: 17 additions & 15 deletions lib/opengd77base_satelliteconfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::clear() {

void
OpenGD77BaseSatelliteConfig::SatelliteElement::writeDigit(const Offset::Bit &offset, uint8_t digit) {
// Must be bit 0 or 4 (BCD)
// Must be bit 0 or 3 (BCD)
if (offset.bit % 4)
return;

Expand All @@ -53,10 +53,7 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::writeInteger(const Offset::Bit &o

o += 4*(dec-1);
for (int i=dec; i>0; i--, o = o - 4) {
if (value)
writeDigit(offset + o, value % 10);
else
writeDigit(offset + o, 0xb);
writeDigit(offset + o, value % 10);
value /= 10;
}
}
Expand All @@ -71,11 +68,13 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::writeFractional(const Offset::Bit
if (0 == frac)
return;

if (sign && (0 > value))
writeDigit(offset + o, 0xc);
else
writeDigit(offset + o, 0xb);
o += 4;
if (sign) {
if (0 > value)
writeDigit(offset + o, 0xc);
else
writeDigit(offset + o, 0xb);
o += 4;
}

value -= int(value);
for (unsigned int i=0; i<frac; i++, o += 4) {
Expand Down Expand Up @@ -155,12 +154,12 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::setRevolutionNumber(unsigned int

void
OpenGD77BaseSatelliteConfig::SatelliteElement::setFMDownlink(const Frequency &f) {
setUInt32_le(Offset::fmDownlink(), f.inHz()/10);
setUInt32_le(Offset::fmDownlink(), f.inHz());
}

void
OpenGD77BaseSatelliteConfig::SatelliteElement::setFMUplink(const Frequency &f) {
setUInt32_le(Offset::fmUplink(), f.inHz()/10);
setUInt32_le(Offset::fmUplink(), f.inHz());
}

void
Expand All @@ -172,18 +171,18 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::setCTCSS(const SelectiveCall &cal

void
OpenGD77BaseSatelliteConfig::SatelliteElement::setAPRSDownlink(const Frequency &f) {
setUInt32_le(Offset::aprsDownlink(), f.inHz()/10);
setUInt32_le(Offset::aprsDownlink(), f.inHz());
}

void
OpenGD77BaseSatelliteConfig::SatelliteElement::setAPRSUplink(const Frequency &f) {
setUInt32_le(Offset::aprsUplink(), f.inHz()/10);
setUInt32_le(Offset::aprsUplink(), f.inHz());
}


void
OpenGD77BaseSatelliteConfig::SatelliteElement::setBeacon(const Frequency &f) {
setUInt32_le(Offset::beacon(), f.inHz()/10);
setUInt32_le(Offset::beacon(), f.inHz());
}


Expand All @@ -201,6 +200,7 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::encode(const Satellite &sat, cons
setName(sat.name());

// orbital elements
setEpoch(sat.epoch());
setMeanMotion(sat.meanMotion());
setMeanMotionDerivative(sat.meanMotionDerivative());
setInclination(sat.inclination());
Expand Down Expand Up @@ -258,6 +258,8 @@ OpenGD77BaseSatelliteConfig::SatelliteBankElement::satellite(unsigned int idx) {

bool
OpenGD77BaseSatelliteConfig::SatelliteBankElement::encode(SatelliteDatabase *db, const ErrorStack &err) {
clear();

for (unsigned int i=0; i<Limit::satellites(); i++) {
SatelliteElement el = satellite(i);
el.clear();
Expand Down
3 changes: 2 additions & 1 deletion lib/openuv380.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "openuv380.hh"
#include "opengd77_limits.hh"
#include "openuv380_satelliteconfig.hh"
#include "logger.hh"
#include "config.hh"


OpenUV380::OpenUV380(OpenGD77Interface *device, QObject *parent)
: OpenGD77Base(device, parent), _name("Open MD-UV380"), _codeplug(), _callsigns()
{
_satelliteConfig = new OpenGD77SatelliteConfig(this);
_satelliteConfig = new OpenUV380SatelliteConfig(this);
}


Expand Down
1 change: 1 addition & 0 deletions lib/openuv380_satelliteconfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ OpenUV380SatelliteConfig::encode(SatelliteDatabase *db, const ErrorStack &err) {
errMsg(err) << "Cannot encode satellite config for OpenUV380.";
return false;
}

return true;
}

0 comments on commit 13e121f

Please sign in to comment.