Skip to content

Commit

Permalink
Make readTemperature always return false, when lock is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-englmaier committed Jan 30, 2024
1 parent c9c7586 commit 55297df
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions drivers/focuser/alluna_tcs2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
* - add handybox add/remove
* - create a python client looking like tcs2control
* - make serial port selection easier
*
* KNOWN PROBLEMS:
* https://indilib.org/forum/focusers-filter-wheels/14173-new-zwo-eaf-first-use-experience-and-questions.html#98014
* Note: When I try to enable Debug in the IndiControlPanel it immediately sets it to Disable?
* Debug is controlled (set on/off) in Ekos and these individual driver debug buttons no longer work. This behaviour is "as expected".
*
*/

#include "alluna_tcs2.h"
Expand Down Expand Up @@ -58,6 +64,7 @@ AllunaTCS2::AllunaTCS2() //: DustCapInterface()
FOCUSER_CAN_REL_MOVE ); //FIXME: maybe remove CAN_REL_MOVE
}


bool AllunaTCS2::initProperties()
{
INDI::Focuser::initProperties();
Expand Down Expand Up @@ -122,7 +129,7 @@ bool AllunaTCS2::updateProperties()
{
// turn on green Connected-LED
if (sendCommand("Connect 1\n"))
LOG_INFO("Turned on Connected-LED¨");
;//LOG_INFO("Turned on Connected-LED¨");
else
LOG_ERROR("Cannot turn on Connected-LED");

Expand Down Expand Up @@ -364,9 +371,9 @@ bool AllunaTCS2::ISNewSwitch(const char * dev, const char * name, ISState * stat
{
// turn off green Connected-LED
if (sendCommand("Connect 0\n"))
LOG_INFO("XTurned off Connected-LED");
LOG_DEBUG("Turned off Connected-LED");
else
LOG_ERROR("XCannot turn off Connected-LED");
LOG_ERROR("Cannot turn off Connected-LED");
}
// Stepping Mode?
if (!strcmp(name, SteppingModeSP.name))
Expand Down Expand Up @@ -480,7 +487,7 @@ bool AllunaTCS2::AbortFocuser()

void AllunaTCS2::TimerHit()
{
LOG_DEBUG("TimerHit");
//LOG_INFO("TimerHit");
if (!isConnected())
return; // No need to reset timer if we are not connected anymore

Expand Down Expand Up @@ -623,7 +630,12 @@ bool AllunaTCS2::readTemperature()
std::chrono::duration<double> seconds = std::chrono::system_clock::now() - last_temp_update;
if ( !first_run && seconds.count() < 300 ) // update all 300 seconds
{
return true; // use cached value
if (tcs.try_lock()) {
tcs.unlock(); // we need to get lock, to make TimerHit behave the same when we block reading temperature
return true; // return true, if we could get the lock
} else {
return false; // return false, if we could not get the lock
}
}
else if ( sendCommandOnly("GetTemperatures\n") )
{
Expand Down

0 comments on commit 55297df

Please sign in to comment.