Skip to content

Commit

Permalink
StarGO 1.8 | Configurable delay between mount commands (#12)
Browse files Browse the repository at this point in the history
* Make mount command delay configurable

* Wait configurable delay after each mount command
  • Loading branch information
sterne-jaeger authored and knro committed Nov 2, 2019
1 parent e596269 commit b309217
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
6 changes: 6 additions & 0 deletions debian/indi-avalon/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
indi-avalon (1.8) buster; urgency=medium

* Make mount command delay configurable

-- Wolfgang Reissenberger <[email protected]> Sat, 19 Oct 2019 22:16:11 +0200

indi-avalon (1.7) stretch; urgency=medium

* Retrying once reading the motor state to capture timeouts
Expand Down
2 changes: 1 addition & 1 deletion indi-avalon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include_directories(${NOVA_INCLUDE_DIR})
include(CMakeCommon)

set(AVALON_VERSION_MAJOR 1)
set(AVALON_VERSION_MINOR 7)
set(AVALON_VERSION_MINOR 8)

set(INDI_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/indi")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
Expand Down
32 changes: 26 additions & 6 deletions indi-avalon/lx200stargo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ bool LX200StarGo::ISNewNumber(const char *dev, const char *name, double values[]
// sync home position
if (!strcmp(name, GuidingSpeedNP.name))
{
int raSpeed = round(values[0] * 100);
int decSpeed = round(values[1] * 100);
int raSpeed = static_cast<int>(round(values[0] * 100.0));
int decSpeed = static_cast<int>(round(values[1] * 100.0));
bool result = setGuidingSpeeds(raSpeed, decSpeed);

if(result)
Expand All @@ -355,6 +355,16 @@ bool LX200StarGo::ISNewNumber(const char *dev, const char *name, double values[]
}
IDSetNumber(&GuidingSpeedNP, nullptr);
return result;
} else if (!strcmp(name, MountRequestDelayNP.name))
{
int secs = static_cast<int>(floor(values[0] / 1000.0));
long nsecs = static_cast<long>(round((values[0] - 1000.0 * secs) * 1000000.0));
setMountRequestDelay(secs, nsecs);

MountRequestDelayN[0].value = secs*1000 + nsecs/1000000;
MountRequestDelayNP.s = IPS_OK;
IDSetNumber(&MountRequestDelayNP, nullptr);
return true;
}
}

Expand Down Expand Up @@ -417,6 +427,10 @@ bool LX200StarGo::initProperties()
IUFillSwitch(&MeridianFlipModeS[2], "MERIDIAN_FLIP_FORCED", "forced", ISS_OFF);
IUFillSwitchVector(&MeridianFlipModeSP, MeridianFlipModeS, 3, getDeviceName(), "MERIDIAN_FLIP_MODE", "Meridian Flip", RA_DEC_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE);

// mount command delay
IUFillNumber(&MountRequestDelayN[0], "MOUNT_REQUEST_DELAY", "Request Delay (ms)", "%.0f", 0.0, 1000, 1.0, 50.0);
IUFillNumberVector(&MountRequestDelayNP, MountRequestDelayN, 1, getDeviceName(), "REQUEST_DELAY", "StarGO", RA_DEC_TAB, IP_RW, 60, IPS_OK);

// focuser on AUX1 port
focuserAux1->initProperties("AUX1 Focuser");

Expand All @@ -440,6 +454,7 @@ bool LX200StarGo::updateProperties()
defineSwitch(&KeypadStatusSP);
defineSwitch(&SystemSpeedSlewSP);
defineSwitch(&MeridianFlipModeSP);
defineNumber(&MountRequestDelayNP);
defineText(&MountFirmwareInfoTP);
}
else
Expand All @@ -453,6 +468,7 @@ bool LX200StarGo::updateProperties()
deleteProperty(KeypadStatusSP.name);
deleteProperty(SystemSpeedSlewSP.name);
deleteProperty(MeridianFlipModeSP.name);
deleteProperty(MountRequestDelayNP.name);
deleteProperty(MountFirmwareInfoTP.name);
}

Expand Down Expand Up @@ -1064,6 +1080,7 @@ bool LX200StarGo::saveConfigItems(FILE *fp)
LOG_DEBUG(__FUNCTION__);
IUSaveConfigText(fp, &SiteNameTP);
IUSaveConfigSwitch(fp, &Aux1FocuserSP);
IUSaveConfigNumber(fp, &MountRequestDelayNP);

focuserAux1->saveConfigItems(fp);

Expand Down Expand Up @@ -1098,6 +1115,8 @@ bool LX200StarGo::sendQuery(const char* cmd, char* response, char end, int wait)
if(!transmit(cmd))
{
LOGF_ERROR("Command <%s> failed.", cmd);
// sleep for 50 mseconds to avoid flooding the mount with commands
nanosleep(&mount_request_delay, nullptr);
return false;
}
lresponse[0] = '\0';
Expand All @@ -1117,6 +1136,10 @@ bool LX200StarGo::sendQuery(const char* cmd, char* response, char end, int wait)
}
}
flush();

// sleep for 50 mseconds to avoid flooding the mount with commands
nanosleep(&mount_request_delay, nullptr);

return true;
}

Expand Down Expand Up @@ -1761,6 +1784,7 @@ bool LX200StarGo::transmit(const char* buffer)
int bytesWritten = 0;
flush();
int returnCode = tty_write_string(PortFD, buffer, &bytesWritten);

if (returnCode != TTY_OK)
{
char errorString[MAXRBUF];
Expand Down Expand Up @@ -2226,10 +2250,6 @@ int LX200StarGo::SendPulseCmd(int8_t direction, uint32_t duration_msec)
}
bool success = !sendQuery(cmd, response, 0); // no response expected

const struct timespec timeout = {0, 50000000L};
// sleep for 50 mseconds to avoid flooding the mount with commands
nanosleep(&timeout, nullptr);

return success;
}

Expand Down
7 changes: 7 additions & 0 deletions indi-avalon/lx200stargo.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ class LX200StarGo : public LX200Telescope
ISwitchVectorProperty MeridianFlipForcedSP;
ISwitch MeridianFlipForcedS[2];

// configurable delay between two commands to avoid flooding StarGO
INumberVectorProperty MountRequestDelayNP;
INumber MountRequestDelayN[1];

int controller_format { LX200_LONG_FORMAT };

// override LX200Generic
Expand All @@ -170,6 +174,9 @@ class LX200StarGo : public LX200Telescope
bool getSystemSlewSpeedMode (int *index);
bool setSystemSlewSpeedMode(int index);

struct timespec mount_request_delay = {0, 50000000L};
void setMountRequestDelay(int secs, long nanosecs) {mount_request_delay.tv_sec = secs; mount_request_delay.tv_nsec = nanosecs; };

// autoguiding
virtual bool setGuidingSpeeds(int raSpeed, int decSpeed);

Expand Down

0 comments on commit b309217

Please sign in to comment.