47 static std::unique_ptr<ScopeScript> scope_script(
new ScopeScript());
56 return (
const char *)
"Telescope Scripting Gateway";
63 #if defined(__APPLE__)
64 IUFillText(&ScriptsT[0],
"FOLDER",
"Folder",
"/usr/local/share/indi/scripts");
66 IUFillText(&ScriptsT[0],
"FOLDER",
"Folder",
"/usr/share/indi/scripts");
112 bool ScopeScript::RunScript(
int script, ...)
115 strncpy(tmp, ScriptsT[script].text,
sizeof(tmp));
117 char **args = (
char **)malloc(
MAXARGS *
sizeof(
char *));
123 char *pp = strstr(p,
" ");
131 va_start(ap, script);
134 char *pp = va_arg(ap,
char *);
141 snprintf(path,
sizeof(path),
"%s/%s", ScriptsT[0].text, tmp);
143 if (access(path, F_OK | X_OK) != 0)
151 snprintf(dbg,
sizeof(dbg),
"execvp('%s'", path);
152 for (
int i = 0; args[i]; i++)
155 strcat(dbg, args[i]);
158 strcat(dbg,
", nullptr)");
177 waitpid(pid, &status, 0);
178 LOGF_DEBUG(
"Script %s returned %d", ScriptsT[script].text, status);
212 LOG_INFO(
"Successfully disconnected");
225 char tmpfile[] =
"/tmp/indi_telescope_script_status_XXXXXX";
226 int fd = mkstemp(tmpfile);
229 LOGF_ERROR(
"Temp file %s creation for status script failed, %s", tmpfile, strerror(
errno));
238 float ra = 0,
dec = 0;
239 FILE *file = fopen(tmpfile,
"r");
241 int rc = fscanf(file,
"%d %f %f", &parked, &
ra, &
dec);
250 LOG_INFO(
"Park successfully executed");
258 LOG_INFO(
"Unpark successfully executed");
272 char _ra[16], _dec[16];
273 snprintf(_ra, 16,
"%f",
ra);
274 snprintf(_dec, 16,
"%f",
dec);
275 bool status = RunScript(
SCRIPT_GOTO, _ra, _dec,
nullptr);
278 LOG_INFO(
"Goto successfully executed");
290 char _ra[16], _dec[16];
291 snprintf(_ra, 16,
"%f",
ra);
292 snprintf(_dec, 16,
"%f",
dec);
293 bool status = RunScript(
SCRIPT_SYNC, _ra, _dec,
nullptr);
296 LOG_INFO(
"Sync successfully executed");
330 _rate,
nullptr,
nullptr);
339 _rate,
nullptr,
nullptr);
const char * getDeviceName() const
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
void setDriverInterface(uint16_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
uint16_t getDriverInterface() const
void addDebugControl()
Add Debug control to the driver.
TelescopeStatus TrackState
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
bool isParked()
isParked is mount currently parked?
ISwitchVectorProperty SlewRateSP
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual const char * getDefaultName() override
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual bool Park() override
Park the telescope to its home position.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool Disconnect() override
Disconnect from device.
void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Update the value of an existing text vector property.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUSaveConfigText(FILE *fp, const ITextVectorProperty *tvp)
Add a text vector property value to the configuration file.
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)