try to find dead-lock

mcc_telemetry.h: use mutex-free non-timedout implementation
This commit is contained in:
2026-10-12 11:10:40 +03:00
parent cd97ed875f
commit 42f43cc1a1

View File

@@ -290,6 +290,82 @@ public:
}
},
_updatingStopSource.get_token(), hardware, pcm);
_updateFunc = [hw = hardware, pcm_ptr = pcm, this](telemetry_data_t* tdata) {
if (_tdataPtr != nullptr && hw && pcm_ptr) {
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
// get hardware state (coordinates, speeds and so on)
auto hw_err = hw->hardwareGetState(&_tdataPtr->hwState);
if (hw_err) {
_lastUpdateError = mcc_deduced_err(hw_err, MccTelemetryErrorCode::ERROR_HARDWARE_GETSTATE);
} else {
// compute PCM corrections and observed (corrected for PCM) mount coordinates
auto pcm_err =
pcm_ptr->computePCM(_tdataPtr->hwState.XY, &(_tdataPtr->pcmCorrection), &(_tdataPtr->mountPos));
if (!pcm_err) {
// set target coordinates
if (_enteredTargetPos.pairKind() == MccCoordPairKind::COORDS_KIND_XY) {
// hardware coordinates
MccGenXY xy;
auto ccte_err = _enteredTargetPos.toAtSameEpoch(xy);
if (!ccte_err) {
decltype(_tdataPtr->pcmCorrection) pcm_corr;
pcm_err = pcm_ptr->computePCM(xy, &pcm_corr, &_tdataPtr->targetPos);
if (pcm_err) {
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
}
_tdataPtr->pcmReverseCorrection.pcmX = -pcm_corr.pcmX;
_tdataPtr->pcmReverseCorrection.pcmY = -pcm_corr.pcmY;
} else {
_lastUpdateError =
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
}
} else { // observed, apparent or ICRS
// _tdataPtr->targetPos = _enteredTargetPos;
using pcm_t = std::remove_pointer_t<decltype(pcm_ptr)>;
std::conditional_t<
mcc_is_equatorial_mount<pcm_t::pcmMountType>, MccSkyHADEC_OBS,
std::conditional_t<mcc_is_altaz_mount<pcm_t::pcmMountType>, MccSkyAZZD, std::nullptr_t>>
cp;
static_assert(!std::is_null_pointer_v<decltype(cp)>, "UNKNOW MOUNT TYPE!");
// calculate target celestial coordinates (of the same type as .mountPos) at the
// epoch of the current mount position
cp.setEpoch(_tdataPtr->mountPos.epoch());
auto ccte_err = _enteredTargetPos.to(cp);
if (ccte_err) {
_lastUpdateError =
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
} else {
_tdataPtr->targetPos.from(cp);
// calculate reverse PCM corrections for the current target position and
// its encoder XY
auto pcm_err = pcm_ptr->computeInversePCM(
_tdataPtr->targetPos, &_tdataPtr->pcmReverseCorrection, &_tdataPtr->targetXY);
if (pcm_err) {
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
}
}
}
} else {
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
}
}
} else {
_lastUpdateError = MccTelemetryErrorCode::ERROR_NULLPTR;
}
};
}
MccTelemetry(MccTelemetry&&) = default;
@@ -354,6 +430,11 @@ public:
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
// 12.10.2026: try to catch dead-lock
// use here mutex-free non-timedout implementation
_updateFunc(tdata);
return _lastUpdateError;
_tdataPtr = tdata;
// trigger updating
@@ -406,7 +487,7 @@ private:
// HARDWARE_T* _hardware{nullptr};
MccSkyPoint _enteredTargetPos{};
// std::function<error_t(telemetry_data_t*)> _updateFunc{};
std::function<error_t(telemetry_data_t*)> _updateFunc{};
telemetry_data_t* _tdataPtr;
std::unique_ptr<std::atomic_flag> _dataUpdatingRequested{new std::atomic_flag{}};