Instrument Neutral Distributed Interface INDI  1.5.0
indidevapi.h
Go to the documentation of this file.
1 #if 0
2 INDI
3 Copyright (C) 2003 - 2006 Elwood C. Downey
4 
5 Modified by Jasem Mutlaq (2003 - 2015)
6 
7 This library is free software;
8 you can redistribute it and / or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation;
11 either
12 version 2.1 of the License, or (at your option) any later version.
13 
14 This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY;
16 without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library;
22 if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
24 
25 #endif
26 
27 #pragma once
28 
92 /*******************************************************************************
93  * get the data structures
94  */
95 
96 #include "indiapi.h"
97 #include "lilxml.h"
98 
99 /*******************************************************************************
100  *******************************************************************************
101  *
102  * Functions the INDI device driver framework defines which the Driver may call
103  *
104  *******************************************************************************
105  *******************************************************************************
106  */
107 
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
111 
130 
135 extern void IDDefText(const ITextVectorProperty *t, const char *msg, ...)
136 #ifdef __GNUC__
137  __attribute__((format(printf, 2, 3)))
138 #endif
139  ;
140 
145 extern void IDDefNumber(const INumberVectorProperty *n, const char *msg, ...)
146 #ifdef __GNUC__
147  __attribute__((format(printf, 2, 3)))
148 #endif
149  ;
150 
155 extern void IDDefSwitch(const ISwitchVectorProperty *s, const char *msg, ...)
156 #ifdef __GNUC__
157  __attribute__((format(printf, 2, 3)))
158 #endif
159  ;
160 
165 extern void IDDefLight(const ILightVectorProperty *l, const char *msg, ...)
166 #ifdef __GNUC__
167  __attribute__((format(printf, 2, 3)))
168 #endif
169  ;
170 
175 extern void IDDefBLOB(const IBLOBVectorProperty *b, const char *msg, ...)
176 #ifdef __GNUC__
177  __attribute__((format(printf, 2, 3)))
178 #endif
179  ;
180 
187 
192 extern void IDSetText(const ITextVectorProperty *t, const char *msg, ...)
193 #ifdef __GNUC__
194  __attribute__((format(printf, 2, 3)))
195 #endif
196  ;
197 
202 extern void IDSetNumber(const INumberVectorProperty *n, const char *msg, ...)
203 #ifdef __GNUC__
204  __attribute__((format(printf, 2, 3)))
205 #endif
206  ;
207 
212 extern void IDSetSwitch(const ISwitchVectorProperty *s, const char *msg, ...)
213 #ifdef __GNUC__
214  __attribute__((format(printf, 2, 3)))
215 #endif
216  ;
217 
222 extern void IDSetLight(const ILightVectorProperty *l, const char *msg, ...)
223 #ifdef __GNUC__
224  __attribute__((format(printf, 2, 3)))
225 #endif
226  ;
227 
232 extern void IDSetBLOB(const IBLOBVectorProperty *b, const char *msg, ...)
233 #ifdef __GNUC__
234  __attribute__((format(printf, 2, 3)))
235 #endif
236  ;
237 
244 
252 extern void IDMessage(const char *dev, const char *msg, ...)
253 #ifdef __GNUC__
254  __attribute__((format(printf, 2, 3)))
255 #endif
256  ;
257 
264 extern void IDDelete(const char *dev, const char *name, const char *msg, ...)
265 #ifdef __GNUC__
266  __attribute__((format(printf, 3, 4)))
267 #endif
268  ;
269 
276 extern void IDLog(const char *msg, ...)
277 #ifdef __GNUC__
278  __attribute__((format(printf, 1, 2)))
279 #endif
280  ;
281 
289 
292 typedef enum {
293  B_NEVER = 0,
296 } BLOBHandling;
297 
302 extern void IDSnoopDevice(const char *snooped_device, const char *snooped_property);
303 
309 extern void IDSnoopBLOBs(const char *snooped_device, const char *snooped_property, BLOBHandling bh);
310 
319 
320 /* signature of a callback, timout caller and work procedure function */
321 
324 typedef void(IE_CBF)(int readfiledes, void *userpointer);
325 
328 typedef void(IE_TCF)(void *userpointer);
329 
332 typedef void(IE_WPF)(void *userpointer);
333 
334 /* functions to add and remove callbacks, timers and work procedures */
335 
343 extern int IEAddCallback(int readfiledes, IE_CBF *fp, void *userpointer);
344 
349 extern void IERmCallback(int callbackid);
350 
360 extern int IEAddTimer(int millisecs, IE_TCF *fp, void *userpointer);
361 
366 extern void IERmTimer(int timerid);
367 
374 extern int IEAddWorkProc(IE_WPF *fp, void *userpointer);
375 
380 extern void IERmWorkProc(int workprocid);
381 
382 /* wait in-line for a flag to set, presumably by another event function */
383 
384 extern int IEDeferLoop(int maxms, int *flagp);
385 extern int IEDeferLoop0(int maxms, int *flagp);
386 
400 
407 extern IText *IUFindText(const ITextVectorProperty *tvp, const char *name);
408 
415 extern INumber *IUFindNumber(const INumberVectorProperty *nvp, const char *name);
416 
423 extern ISwitch *IUFindSwitch(const ISwitchVectorProperty *svp, const char *name);
424 
431 extern ILight *IUFindLight(const ILightVectorProperty *lvp, const char *name);
432 
439 extern IBLOB *IUFindBLOB(const IBLOBVectorProperty *bvp, const char *name);
440 
448 extern ISwitch *IUFindOnSwitch(const ISwitchVectorProperty *sp);
449 
457 extern int IUFindIndex(const char *needle, char **hay, unsigned int n);
458 
467 extern int IUFindOnSwitchIndex(const ISwitchVectorProperty *sp);
468 
479 extern const char *IUFindOnSwitchName(ISState *states, char *names[], int n);
480 
485 extern void IUResetSwitch(ISwitchVectorProperty *svp);
486 
495 extern int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n);
496 
505 extern int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n);
506 
515 extern int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n);
516 
528 extern int IUUpdateBLOB(IBLOBVectorProperty *bvp, int sizes[], int blobsizes[], char *blobs[], char *formats[],
529  char *names[], int n);
530 
539 extern int IUSaveBLOB(IBLOB *bp, int size, int blobsize, char *blob, char *format);
540 
544 extern void IUUpdateMinMax(const INumberVectorProperty *nvp);
545 
550 extern void IUSaveText(IText *tp, const char *newtext);
551 
558 extern void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s);
559 
566 extern void IUFillLight(ILight *lp, const char *name, const char *label, IPState s);
567 
578 extern void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max,
579  double step, double value);
580 
587 extern void IUFillText(IText *tp, const char *name, const char *label, const char *initialText);
588 
595 extern void IUFillBLOB(IBLOB *bp, const char *name, const char *label, const char *format);
596 
610 extern void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name,
611  const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s);
612 
623 extern void IUFillLightVector(ILightVectorProperty *lvp, ILight *lp, int nlp, const char *dev, const char *name,
624  const char *label, const char *group, IPState s);
625 
638 extern void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name,
639  const char *label, const char *group, IPerm p, double timeout, IPState s);
640 
653 extern void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name,
654  const char *label, const char *group, IPerm p, double timeout, IPState s);
655 
668 extern void IUFillBLOBVector(IBLOBVectorProperty *bvp, IBLOB *bp, int nbp, const char *dev, const char *name,
669  const char *label, const char *group, IPerm p, double timeout, IPState s);
670 
676 extern int IUSnoopNumber(XMLEle *root, INumberVectorProperty *nvp);
677 
683 extern int IUSnoopText(XMLEle *root, ITextVectorProperty *tvp);
684 
690 extern int IUSnoopLight(XMLEle *root, ILightVectorProperty *lvp);
691 
697 extern int IUSnoopSwitch(XMLEle *root, ISwitchVectorProperty *svp);
698 
704 extern int IUSnoopBLOB(XMLEle *root, IBLOBVectorProperty *bvp);
705 
708 /*******************************************************************************
709  *******************************************************************************
710  *
711  * Functions the INDI Device Driver framework calls which the Driver must
712  * define.
713  *
714  *******************************************************************************
715  *******************************************************************************
716  */
717 
726 
740 extern void ISGetProperties(const char *dev);
741 
750 extern void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
751 
760 extern void ISNewNumber(const char *dev, const char *name, double *values, char *names[], int n);
761 
770 extern void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
771 
785 extern void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
786  char *names[], int n);
787 
792 extern void ISSnoopDevice(XMLEle *root);
793 
796 /* Handy readability macro to avoid unused variables warnings */
797 #define INDI_UNUSED(x) (void)x
798 
808 extern int crackDN(XMLEle *root, char **dev, char **name, char msg[]);
809 
815 extern int crackIPState(const char *str, IPState *ip);
816 
822 extern int crackISState(const char *str, ISState *ip);
823 
829 extern int crackIPerm(const char *str, IPerm *ip);
830 
836 extern int crackISRule(const char *str, ISRule *ip);
837 
839 extern const char *pstateStr(IPState s);
841 extern const char *sstateStr(ISState s);
843 extern const char *ruleStr(ISRule r);
845 extern const char *permStr(IPerm p);
846 
847 extern void xmlv1();
848 
849 #ifdef __cplusplus
850 }
851 #endif
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
Definition: indicom.c:1327
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
Definition: indicom.c:1318
const char * pstateStr(IPState s)
Definition: indicom.c:1064
Light vector property descriptor.
Definition: indiapi.h:387
int IUSnoopText(XMLEle *root, ITextVectorProperty *tvp)
Update a snooped text vector property from the given XML root element.
Definition: indidriver.c:680
int IEDeferLoop0(int maxms, int *flagp)
Definition: indidriver.c:221
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL...
Definition: indidriver.c:545
void IDSetText(const ITextVectorProperty *t, const char *msg,...)
Tell client to update an existing text vector property.
Definition: indidriver.c:1796
ILight * IUFindLight(const ILightVectorProperty *lvp, const char *name)
Find an ILight member in a vector Light property.
Definition: indicom.c:1258
void IDSetSwitch(const ISwitchVectorProperty *s, const char *msg,...)
Tell client to update an existing switch vector property.
Definition: indidriver.c:1880
int crackISRule(const char *str, ISRule *ip)
Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
Definition: indicom.c:1127
IPState
Property state.
Definition: indiapi.h:133
One light descriptor.
Definition: indiapi.h:369
int IEAddWorkProc(IE_WPF *fp, void *userpointer)
Add a new work procedure, fp, to be called with ud when nothing else to do.
Definition: indidriver.c:206
void IDDefNumber(const INumberVectorProperty *n, const char *msg,...)
Tell client to create a number number property.
Definition: indidriver.c:1556
void IDMessage(const char *dev, const char *msg,...)
Function Drivers call to send log messages to Clients.
Definition: indidriver.c:1316
void ISNewNumber(const char *dev, const char *name, double *values, char *names[], int n)
Update the value of an existing number vector property.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
Definition: indidriver.c:227
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
Definition: indidriver.c:319
int IEAddTimer(int millisecs, IE_TCF *fp, void *userpointer)
Register a new timer function, fp, to be called with ud as argument after ms.
Definition: indidriver.c:196
One number descriptor.
Definition: indiapi.h:246
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
Definition: indidriver.c:283
int IUSnoopLight(XMLEle *root, ILightVectorProperty *lvp)
Update a snooped light vector property from the given XML root element.
Definition: indidriver.c:717
void IDSnoopBLOBs(const char *snooped_device, const char *snooped_property, BLOBHandling bh)
Function a Driver calls to control whether they will receive BLOBs from snooped devices.
Definition: indidriver.c:155
One Blob (Binary Large Object) descriptor.
Definition: indiapi.h:413
int crackIPerm(const char *str, IPerm *ip)
Extract property permission state (RW, RO, WO) from the supplied string.
Definition: indicom.c:1114
double max(void)
int IUSaveBLOB(IBLOB *bp, int size, int blobsize, char *blob, char *format)
Function to save blob metadata in the corresponding blob.
Definition: indidriver.c:375
void IDDefBLOB(const IBLOBVectorProperty *b, const char *msg,...)
Tell client to create a BLOB vector property.
Definition: indidriver.c:1734
void ISSnoopDevice(XMLEle *root)
Function defined by Drivers that is called when another Driver it is snooping (by having previously c...
void IUUpdateMinMax(const INumberVectorProperty *nvp)
Function to update the min and max elements of a number in the client.
Definition: indidriver.c:2038
void IERmTimer(int timerid)
Remove the timer with the given timerid, as returned from IEAddTimer.
Definition: indidriver.c:201
const char * name
Definition: indiserver.c:112
void IDSetNumber(const INumberVectorProperty *n, const char *msg,...)
Tell client to update an existing number vector property.
Definition: indidriver.c:1838
void( IE_CBF)(int readfiledes, void *userpointer)
Signature of a callback.
Definition: indidevapi.h:324
Switch vector property descriptor.
Definition: indiapi.h:337
Namespace to encapsulate INDI client, drivers, and mediator classes. Developers can subclass the base...
void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Update the value of an existing text vector property.
int IEDeferLoop(int maxms, int *flagp)
Definition: indidriver.c:216
const char * permStr(IPerm p)
Definition: indicom.c:1173
int IUSnoopNumber(XMLEle *root, INumberVectorProperty *nvp)
Update a snooped number vector property from the given XML root element.
Definition: indidriver.c:634
One switch descriptor.
Definition: indiapi.h:319
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
Definition: indicom.c:1222
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...
Definition: indidriver.c:445
void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Update the value of an existing switch vector property.
void IUFillBLOB(IBLOB *bp, const char *name, const char *label, const char *format)
Assign attributes for a BLOB property. The BLOB's data and auxiliary elements will be set to NULL...
Definition: indidriver.c:468
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL...
Definition: indidriver.c:384
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:441
BLOBHandling
How drivers handle BLOBs incoming from snooping drivers.
Definition: indidevapi.h:292
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
IBLOB * IUFindBLOB(const IBLOBVectorProperty *bvp, const char *name)
Find an IBLOB member in a vector BLOB property.
Definition: indicom.c:1270
void IERmCallback(int callbackid)
Remove a callback function.
Definition: indidriver.c:191
int crackDN(XMLEle *root, char **dev, char **name, char msg[])
Extract dev and name attributes from an XML element.
Definition: indicom.c:1198
const char * ruleStr(ISRule r)
Definition: indicom.c:1156
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL...
Definition: indidriver.c:420
void( IE_WPF)(void *userpointer)
Signature of a work procedure function.
Definition: indidevapi.h:332
int IUSnoopSwitch(XMLEle *root, ISwitchVectorProperty *svp)
Update a snooped switch vector property from the given XML root element.
Definition: indidriver.c:760
int crackISState(const char *str, ISState *ip)
Extract switch state (On or Off) from the supplied string.
Definition: indicom.c:1103
INumber * IUFindNumber(const INumberVectorProperty *nvp, const char *name)
Find an INumber member in a number text property.
Definition: indicom.c:1234
void IDSnoopDevice(const char *snooped_device, const char *snooped_property)
Function a Driver calls to snoop on another Device. Snooped messages will then arrive via ISSnoopDevi...
Definition: indidriver.c:140
void ISGetProperties(const char *dev)
Get Device Properties.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *sp)
Returns the index of first ON switch it finds in the vector switch property.
Definition: indicom.c:1296
Number vector property descriptor.
Definition: indiapi.h:289
int crackIPState(const char *str, IPState *ip)
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
Definition: indicom.c:1085
int IUSnoopBLOB(XMLEle *root, IBLOBVectorProperty *bvp)
Update a snooped BLOB vector property from the given XML root element.
Definition: indidriver.c:803
One text descriptor.
Definition: indiapi.h:196
void IDSetBLOB(const IBLOBVectorProperty *b, const char *msg,...)
Tell client to update an existing BLOB vector property.
Definition: indidriver.c:1961
void IDDefLight(const ILightVectorProperty *l, const char *msg,...)
Tell client to create a light vector property.
Definition: indidriver.c:1691
void IERmWorkProc(int workprocid)
Remove a work procedure.
Definition: indidriver.c:211
void IDSetLight(const ILightVectorProperty *l, const char *msg,...)
Tell client to update an existing light vector property.
Definition: indidriver.c:1922
int IEAddCallback(int readfiledes, IE_CBF *fp, void *userpointer)
Register a new callback, fp, to be called with userpointer as argument when readfiledes is ready...
Definition: indidriver.c:186
void( IE_TCF)(void *userpointer)
Signature of a timeout caller.
Definition: indidevapi.h:328
int IUFindIndex(const char *needle, char **hay, unsigned int n)
Returns the index of the string in a string array.
Definition: indidriver.c:2071
void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Update data of an existing blob vector property.
void IDLog(const char *msg,...)
Function Drivers call to log a message locally.
Definition: indicom.c:287
void IUFillBLOBVector(IBLOBVectorProperty *bvp, IBLOB *bp, int nbp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a BLOB vector property. The vector's auxiliary elements will be set to NULL...
Definition: indidriver.c:597
const char * IUFindOnSwitchName(ISState *states, char *names[], int n)
Returns the name of the first ON switch it finds in the supplied arguments.
Definition: indicom.c:1307
IPerm
Permission hint, with respect to client.
Definition: indiapi.h:154
ISState
Switch state.
Definition: indiapi.h:124
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL...
Definition: indidriver.c:494
A little DOM-style library to handle parsing and processing an XML file.
ISwitch * IUFindSwitch(const ISwitchVectorProperty *svp, const char *name)
Find an ISwitch member in a vector switch property.
Definition: indicom.c:1246
ISwitch * IUFindOnSwitch(const ISwitchVectorProperty *sp)
Returns the first ON switch it finds in the vector switch property.
Definition: indicom.c:1284
void xmlv1()
Definition: indicom.c:1190
const char * sstateStr(ISState s)
Definition: indicom.c:1141
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...
Definition: indidriver.c:571
void IDDelete(const char *dev, const char *name, const char *msg,...)
Function Drivers call to inform Clients a Property is no longer available, or the entire device is go...
Definition: indidriver.c:112
enum @61 __attribute__
double min(void)
Text vector property descriptor.
Definition: indiapi.h:216
void IUFillLightVector(ILightVectorProperty *lvp, ILight *lp, int nlp, const char *dev, const char *name, const char *label, const char *group, IPState s)
Assign attributes for a light vector property. The vector's auxiliary elements will be set to NULL...
Definition: indidriver.c:521
int IUUpdateBLOB(IBLOBVectorProperty *bvp, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Update all BLOB members in a BLOB vector property.
Definition: indidriver.c:347
ISRule
Switch vector rule hint.
Definition: indiapi.h:144
void IDDefSwitch(const ISwitchVectorProperty *s, const char *msg,...)
Tell client to create a switch vector property.
Definition: indidriver.c:1626
void IDDefText(const ITextVectorProperty *t, const char *msg,...)
Tell client to create a text vector property.
Definition: indidriver.c:1493
void IUFillLight(ILight *lp, const char *name, const char *label, IPState s)
Assign attributes for a light property. The light's auxiliary elements will be set to NULL...
Definition: indidriver.c:402