Skip to content

Commit

Permalink
Improved debug mode error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hjd1964 committed Jul 15, 2020
1 parent 6949b9b commit 36ea4ac
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 59 deletions.
16 changes: 8 additions & 8 deletions AlignEq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ void TGeoAlign::init() {
// remember the alignment between sessions
void TGeoAlign::readCoe() {
ax1Cor=nv.readFloat(EE_ax1Cor);
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DL("NV: bad ax1Cor"); } // valid ax1Cor?
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DL("ERR, readCoe(): bad NV ax1Cor"); }
ax2Cor=nv.readFloat(EE_ax2Cor);
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DL("NV: bad ax2Cor"); } // valid ax2Cor?
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DL("ERR, readCoe(): bad NV ax2Cor"); }
dfCor=nv.readFloat(EE_dfCor); // dfCor is ffCor for fork mounts
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DL("NV: bad dfCor"); } // valid dfCor?
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DL("ERR, readCoe(): bad NV dfCor"); }
tfCor=nv.readFloat(EE_tfCor);
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DL("NV: bad tfCor"); } // valid tfCor?
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DL("ERR, readCoe(): bad NV tfCor"); }
doCor=nv.readFloat(EE_doCor);
if (doCor < -10 || doCor > 10) { doCor=0.0; DL("NV: bad doCor"); } // valid doCor?
if (doCor < -10 || doCor > 10) { doCor=0.0; DL("ERR, readCoe(): bad NV doCor"); }
pdCor=nv.readFloat(EE_pdCor);
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DL("NV: bad pdCor"); } // valid pdCor?
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DL("ERR, readCoe(): bad NV pdCor"); }
altCor=nv.readFloat(EE_altCor);
if (altCor < -10 || altCor > 10) { altCor=0.0; DL("NV: bad altCor"); } // valid altCor?
if (altCor < -10 || altCor > 10) { altCor=0.0; DL("ERR, readCoe(): bad NV altCor"); }
azmCor=nv.readFloat(EE_azmCor);
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DL("NV: bad azmCor"); } // valid azmCor?
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DL("ERR, readCoe(): bad NV azmCor"); }
}

void TGeoAlign::writeCoe() {
Expand Down
16 changes: 8 additions & 8 deletions AlignHor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ void TGeoAlignH::init() {
// remember the alignment between sessions
void TGeoAlignH::readCoe() {
ax1Cor=nv.readFloat(EE_ax1Cor);
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DL("NV: bad ax1Cor"); } // valid ax1Cor?
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DL("ERR, readCoe(): bad NV ax1Cor"); }
ax2Cor=nv.readFloat(EE_ax2Cor);
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DL("NV: bad ax2Cor"); } // valid ax2Cor?
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DL("ERR, readCoe(): bad NV ax2Cor"); }
dfCor=nv.readFloat(EE_dfCor); // dfCor is ffCor for fork mounts
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DL("NV: bad dfCor"); } // valid dfCor?
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DL("ERR, readCoe(): bad NV dfCor"); }
tfCor=nv.readFloat(EE_tfCor);
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DL("NV: bad tfCor"); } // valid tfCor?
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DL("ERR, readCoe(): bad NV tfCor"); }
doCor=nv.readFloat(EE_doCor);
if (doCor < -10 || doCor > 10) { doCor=0.0; DL("NV: bad doCor"); } // valid doCor?
if (doCor < -10 || doCor > 10) { doCor=0.0; DL("ERR, readCoe(): bad NV doCor"); }
pdCor=nv.readFloat(EE_pdCor);
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DL("NV: bad pdCor"); } // valid pdCor?
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DL("ERR, readCoe(): bad NV pdCor"); }
altCor=nv.readFloat(EE_altCor);
if (altCor < -10 || altCor > 10) { altCor=0.0; DL("NV: bad altCor"); } // valid altCor?
if (altCor < -10 || altCor > 10) { altCor=0.0; DL("ERR, readCoe(): bad NV altCor"); }
azmCor=nv.readFloat(EE_azmCor);
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DL("NV: bad azmCor"); } // valid azmCor?
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DL("ERR, readCoe(): bad NV azmCor"); }
}

void TGeoAlignH::writeCoe() {
Expand Down
6 changes: 3 additions & 3 deletions Command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2117,13 +2117,13 @@ void processCommands() {
if (command[1] >= '0' && command[1] <= '3' && parameter[0] == 0) {
currentSite=command[1]-'0'; nv.update(EE_currentSite,currentSite); booleanReply=false;
double f=nv.readFloat(EE_sites+currentSite*25+0);
if (f < -90 || f > 90) { f=0.0; DL("NV: bad latitude"); } // valid latitude?
if (f < -90 || f > 90) { f=0.0; DL("ERR, processCommands(): bad NV latitude"); }
setLatitude(f);
longitude=nv.readFloat(EE_sites+currentSite*25+4);
if (longitude < -360 || longitude > 360) { longitude=0.0; DL("NV: bad longitude"); } // valid longitude?
if (longitude < -360 || longitude > 360) { longitude=0.0; DL("ERR, processCommands(): bad NV longitude"); }
timeZone=nv.read(EE_sites+currentSite*25+8)-128;
if (timeZone < -12 || timeZone > 14) { timeZone=0.0; DL("NV: bad timeZone"); } // valid time zone?
timeZone=decodeTimeZone(timeZone);
if (timeZone < -12 || timeZone > 14) { timeZone=0.0; DL("ERR, processCommands(): bad NV timeZone"); }
updateLST(jd2last(JD,UT1,false));
} else
if (command[1] == '?') {
Expand Down
4 changes: 2 additions & 2 deletions Home.ino
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ CommandErrors setHome() {

// reset PEC, unless we have an index to recover from this
pecRecorded=nv.read(EE_pecRecorded);
if (pecRecorded != true && pecRecorded != false) { pecRecorded=false; DL("NV: bad pecRecorded"); } // valid PEC recorded?
if (pecRecorded != true && pecRecorded != false) { pecRecorded=false; DL("ERR, setHome(): bad NV pecRecorded"); }
#if PEC_SENSE == OFF
pecStatus=IgnorePEC;
nv.write(EE_pecStatus,pecStatus);
#else
pecStatus=nv.read(EE_pecStatus);
if (pecStatus < PEC_STATUS_FIRST || pecStatus > PEC_STATUS_LAST) { pecStatus=IgnorePEC; DL("NV: bad pecStatus"); } // valid PEC status?
if (pecStatus < PEC_STATUS_FIRST || pecStatus > PEC_STATUS_LAST) { pecStatus=IgnorePEC; DL("ERR, setHome(): bad NV pecStatus"); }
#endif
if (!pecRecorded) pecStatus=IgnorePEC;

Expand Down
44 changes: 23 additions & 21 deletions Initialize.ino
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,23 @@ void initPins() {
}

void initReadNvValues() {
if (E2END < 1023) { DL("ERR, initReadNvValues(): bad NV size, < 1024 bytes"); }

// get the site information, if a GPS were attached we would use that here instead
currentSite=nv.read(EE_currentSite);
if (currentSite > 3) { currentSite=0; DL("NV: bad currentSite"); } // valid site index?
if (currentSite > 3) { currentSite=0; DL("ERR, initReadNvValues(): bad NV currentSite"); }

double f=nv.readFloat(EE_sites+currentSite*25+0);
if (f < -90 || f > 90) { f=0.0; DL("NV: bad latitude"); } // valid latitude?
if (f < -90 || f > 90) { f=0.0; DL("ERR, initReadNvValues(): bad NV latitude"); }
setLatitude(f);
longitude=nv.readFloat(EE_sites+currentSite*25+4);
if (longitude < -360 || longitude > 360) { longitude=0.0; DL("NV: bad longitude"); } // valid longitude?
if (longitude < -360 || longitude > 360) { longitude=0.0; DL("ERR, initReadNvValues(): bad NV longitude"); }
InitStartPosition();

// get date and time from EEPROM, start keeping time
timeZone=nv.read(EE_sites+currentSite*25+8)-128;
timeZone=decodeTimeZone(timeZone);
if (timeZone < -12 || timeZone > 14) { timeZone=0.0; DL("NV: bad timeZone"); } // valid time zone?
if (timeZone < -12 || timeZone > 14) { timeZone=0.0; DL("ERR, initReadNvValues(): bad NV timeZone"); }
nv.readString(EE_sites+currentSite*25+9,siteName);

JD=nv.readFloat(EE_JD);
Expand All @@ -311,7 +313,7 @@ void initReadNvValues() {
dateWasSet=true; timeWasSet=true;
}
if (JD < 2451544.5 || JD > 2816787.5) JD=2451544.5; // valid date?
if (LMT < 0 || LMT > 24) { LMT=0; DL("NV: bad LMT"); } // valid time?
if (LMT < 0 || LMT > 24) { LMT=0; DL("ERR, initReadNvValues(): bad NV LMT"); }

UT1=LMT+timeZone;
updateLST(jd2last(JD,UT1,false));
Expand All @@ -321,35 +323,35 @@ void initReadNvValues() {
int i=round(nv.read(EE_dpmE)-128);
if (i > 60) i=((i-90)*2)+60; else if (i < -60) i=((i+90)*2)-60;
degreesPastMeridianE=i;
if (degreesPastMeridianE < -180 || degreesPastMeridianE > 180) { degreesPastMeridianE=0.0; DL("NV: bad degreesPastMeridianE"); } // valid limit?
if (degreesPastMeridianE < -180 || degreesPastMeridianE > 180) { degreesPastMeridianE=0.0; DL("ERR, initReadNvValues(): bad NV degreesPastMeridianE"); }

i=round(nv.read(EE_dpmW)-128);
if (i > 60) i=((i-60)*2)+60; else if (i < -60) i=((i+60)*2)-60;
degreesPastMeridianW=i;
if (degreesPastMeridianW < -180 || degreesPastMeridianW > 180) { degreesPastMeridianW=0.0; DL("NV: bad degreesPastMeridianW"); } // valid limit?
if (degreesPastMeridianW < -180 || degreesPastMeridianW > 180) { degreesPastMeridianW=0.0; DL("ERR, initReadNvValues(): bad NV degreesPastMeridianW"); }
#endif

// get the min. and max altitude
minAlt=nv.read(EE_minAlt)-128;
if (minAlt < -30 || minAlt > 30) { minAlt=-10.0; DL("NV: bad minAlt"); } // valid limit?
if (minAlt < -30 || minAlt > 30) { minAlt=-10.0; DL("ERR, initReadNvValues(): bad NV minAlt"); }
maxAlt=nv.read(EE_maxAlt);
#if MOUNT_TYPE == ALTAZM
if (maxAlt > 87) maxAlt=87;
#endif
if (maxAlt < 60 || maxAlt > 90) { maxAlt=80.0; DL("NV: bad maxAlt"); } // valid limit?
if (maxAlt < 60 || maxAlt > 90) { maxAlt=80.0; DL("ERR, initReadNvValues(): bad NV maxAlt"); }

// get the backlash amounts
backlashAxis1=nv.readInt(EE_backlashAxis1);
if (backlashAxis1 < 0 ) { backlashAxis1=0; DL("NV: bad backlashAxis1"); } // valid backlash?
if (backlashAxis1 < 0 ) { backlashAxis1=0; DL("ERR, initReadNvValues(): bad NV backlashAxis1"); }
backlashAxis2=nv.readInt(EE_backlashAxis2);
if (backlashAxis2 < 0 ) { backlashAxis2=0; DL("NV: bad backlashAxis2"); } // valid backlash?
if (backlashAxis2 < 0 ) { backlashAxis2=0; DL("ERR, initReadNvValues(): bad NV backlashAxis2"); }

#if MOUNT_TYPE != ALTAZM
// get the PEC status
pecStatus =nv.read(EE_pecStatus);
if (pecStatus < PEC_STATUS_FIRST || pecStatus > PEC_STATUS_LAST) { pecStatus=IgnorePEC; DL("NV: bad pecStatus"); } // valid PEC status?
if (pecStatus < PEC_STATUS_FIRST || pecStatus > PEC_STATUS_LAST) { pecStatus=IgnorePEC; DL("ERR, initReadNvValues(): bad NV pecStatus"); }
pecRecorded=nv.read(EE_pecRecorded);
if (pecRecorded != true && pecRecorded != false) { pecRecorded=false; DL("NV: bad pecRecorded"); } // valid PEC recorded?
if (pecRecorded != true && pecRecorded != false) { pecRecorded=false; DL("ERR, initReadNvValues(): bad NV pecRecorded"); }
if (!pecRecorded) pecStatus=IgnorePEC;
for (int i=0; i < pecBufferSize; i++) pecBuffer[i]=nv.read(EE_pecTable+i);
wormSensePos=nv.readLong(EE_wormSensePos); // validation of this value is not useful
Expand All @@ -361,16 +363,16 @@ void initReadNvValues() {

// get the Park status
parkSaved=nv.read(EE_parkSaved);
if (parkSaved != true && parkSaved != false) { parkSaved=false; DL("NV: bad parkSaved"); } // valid park saved?
if (parkSaved != true && parkSaved != false) { parkSaved=false; DL("ERR, initReadNvValues(): bad NV parkSaved"); }
parkStatus=nv.read(EE_parkStatus);
if (parkStatus < PARK_STATUS_FIRST || parkStatus > PARK_STATUS_LAST) { parkStatus=NotParked; DL("NV: bad parkStatus"); } // valid park status?
if (parkStatus < PARK_STATUS_FIRST || parkStatus > PARK_STATUS_LAST) { parkStatus=NotParked; DL("ERR, initReadNvValues(): bad NV parkStatus"); }
// tried to park but crashed?
if (parkStatus == Parking) { parkStatus=ParkFailed; nv.write(EE_parkStatus,parkStatus); }

// get the pulse-guide rate
currentPulseGuideRate=nv.read(EE_pulseGuideRate);
if (currentPulseGuideRate < 0) { currentPulseGuideRate=0; DL("NV: bad currentPulseGuideRate"); } // valid pulse guide rate?
if (currentPulseGuideRate > GuideRate1x) { currentPulseGuideRate=GuideRate1x; DL("NV: bad currentPulseGuideRate"); }
if (currentPulseGuideRate < 0) { currentPulseGuideRate=0; DL("ERR, initReadNvValues(): bad NV currentPulseGuideRate"); }
if (currentPulseGuideRate > GuideRate1x) { currentPulseGuideRate=GuideRate1x; DL("ERR, initReadNvValues(): bad NV currentPulseGuideRate"); }

// set the default MaxRate based on the desired goto speed
MaxRateBaseActual=MaxRateBaseDesired;
Expand All @@ -382,8 +384,8 @@ void initReadNvValues() {
// check for flag that maxRate is stored in EE_maxRateL, if not move it there
if (maxRate == -16) maxRate=nv.readLong(EE_maxRateL); else { nv.writeInt(EE_maxRate,-1); nv.writeLong(EE_maxRateL,maxRate); }
// constrain values to the limits (1/2 to 2X the MaxRateBaseActual) and platform limits
if (maxRate < (long)(MaxRateBaseActual*8.0)) { maxRate=MaxRateBaseActual*8.0; DL("NV: maxRate warning (too low)"); }
if (maxRate > (long)(MaxRateBaseActual*32.0)) { maxRate=MaxRateBaseActual*32.0; DL("NV: maxRate warning (too high)"); }
if (maxRate < (long)(MaxRateBaseActual*8.0)) { maxRate=MaxRateBaseActual*8.0; DL("WRN, initReadNvValues(): NV maxRate (too low)"); }
if (maxRate > (long)(MaxRateBaseActual*32.0)) { maxRate=MaxRateBaseActual*32.0; DL("WRN, initReadNvValues(): NV maxRate (too high)"); }
if (maxRate < maxRateLowerLimit()) maxRate=maxRateLowerLimit();

#if SLEW_RATE_MEMORY == OFF
Expand All @@ -394,13 +396,13 @@ void initReadNvValues() {
// get autoMeridianFlip
#if MOUNT_TYPE == GEM && MFLIP_AUTOMATIC_MEMORY == ON
autoMeridianFlip=nv.read(EE_autoMeridianFlip);
if (autoMeridianFlip != 1 && autoMeridianFlip != 0) { autoMeridianFlip=0; DL("NV: bad autoMeridianFlip"); } // valid autoMeridianFlip saved?
if (autoMeridianFlip != 1 && autoMeridianFlip != 0) { autoMeridianFlip=0; DL("ERR, initReadNvValues(): bad NV autoMeridianFlip"); }
#endif

// get meridian flip pause at home
#if MOUNT_TYPE == GEM && MFLIP_PAUSE_HOME_MEMORY == ON
pauseHome=nv.read(EE_pauseHome);
if (pauseHome != 1 && pauseHome != 0) { pauseHome=0; DL("NV: bad pauseHome"); } // valid pauseHome saved?
if (pauseHome != 1 && pauseHome != 0) { pauseHome=0; DL("ERR, initReadNvValues(): bad NV pauseHome"); }
#endif

// set the default guide rate
Expand Down
2 changes: 1 addition & 1 deletion MoveTo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ long maxRateLowerLimit() {
r_us=(r_us_axis1+r_us_axis2/timerRateRatio)/2.0; // if Axis1 is 10000 step/deg & Axis2 is 20000 steps/deg, Axis2 needs to run 2x speed so we must slow down. 3.4 on one axis and 6.8 on the other for an average of 5.1

// the timer granulaity can start to make for some very abrupt rate changes below 0.25us
if (r_us < 0.25) r_us=0.25;
if (r_us < 0.25) { r_us=0.25; DL("WRN, maxRateLowerLimit(): r_us exceeds design limit"); }

// return rate in 1/16us units
return round(r_us*16.0);
Expand Down
2 changes: 1 addition & 1 deletion OnStep.ino
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void setup() {
// this sets up the sidereal timer and tracking rates
VLL("MSG: Init sidereal timer");
siderealInterval=nv.readLong(EE_siderealInterval); // the number of 16MHz clocks in one sidereal second (this is scaled to actual processor speed)
if (siderealInterval < 14360682L || siderealInterval > 17551944L) { siderealInterval=15956313L; DL("NV: bad siderealInterval"); } // valid siderealInterval?
if (siderealInterval < 14360682L || siderealInterval > 17551944L) { siderealInterval=15956313L; DL("ERR, setup(): bad NV siderealInterval"); }
SiderealRate=siderealInterval/StepsPerSecondAxis1;
timerRateAxis1=SiderealRate;
timerRateAxis2=SiderealRate;
Expand Down
Loading

0 comments on commit 36ea4ac

Please sign in to comment.