Skip to content

Commit

Permalink
Sim crash fix - looks like found root cause (#2147)
Browse files Browse the repository at this point in the history
* Fixed crash due not checking boundary values of the axis

* Workaround of stange crash

* Read fix of the issues - not initialized values

* Code review fix
  • Loading branch information
artyom-beilis authored Nov 6, 2024
1 parent 220efb4 commit cef7d28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions drivers/telescope/scopesim_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,21 @@ void Axis::update() // called about once a second to update the position
//LOGF_DEBUG("move %s: change %f, position %f", b, change, position.Degrees());
}

int rate = std::max(-4,std::min(4,mcRate));
if(rate != mcRate) {
LOGF_ERROR("Invalid mcRate Detected = %d",mcRate);
}

// handle the motion control
if (mcRate < 0)
if (rate < 0)
{
change = -mcRates[-mcRate].Degrees() * interval;
change = -mcRates[-rate].Degrees() * interval;
//LOGF_DEBUG("mcRate %d, rate %f, change %f", mcRate, mcRates[-mcRate].Degrees(), change);
position += change;
}
else if (mcRate > 0)
else if (rate > 0)
{
change = mcRates[mcRate].Degrees() * interval;
change = mcRates[rate].Degrees() * interval;
//LOGF_DEBUG("mcRate %d, rate %f, change %f", mcRate, mcRates[mcRate].Degrees(), change);
position += change;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/telescope/scopesim_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Axis
guideDuration = 0;
}

bool isSlewing;
bool isSlewing = false;

bool isTracking()
{
Expand Down Expand Up @@ -328,7 +328,7 @@ class Axis
return guideDuration > 0;
}

int mcRate; // int -4 to 4 sets move rate, zero is stopped
int mcRate = 0; // int -4 to 4 sets move rate, zero is stopped

void update(); // called about once a second to update the position and mode

Expand All @@ -346,13 +346,13 @@ class Axis
0, 0
};

bool tracking; // this allows the tracking state and rate to be set independently
bool tracking = false; // this allows the tracking state and rate to be set independently

AXIS_TRACK_RATE trackingRate { AXIS_TRACK_RATE::OFF };

Angle rotateCentre { 90.0 };

double guideDuration;
double guideDuration = 0;
Angle guideRateDegSec;

// rates are angles in degrees per second derived from the values in indicom.h
Expand Down

0 comments on commit cef7d28

Please sign in to comment.