source: BAORadio/libindi/libindi/indidevapi.h

Last change on this file was 697, checked in by frichard, 12 years ago

-Passage de la version 0.9 à la version 0.9.5 de la biliothèque libindi
-correction d'un bug affectant la commande 'm'
-vérification des fuites de mémoire et débogage complet

File size: 36.0 KB
Line 
1#if 0
2    INDI
3    Copyright (C) 2003-2006 Elwood C. Downey
4
5                        Modified by Jasem Mutlaq (2003-2006)
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
21#endif
22
23#ifndef INDI_DEVAPI_H
24#define INDI_DEVAPI_H
25
26/** \file indidevapi.h
27    \brief Interface to the reference INDI C API device implementation on the Device Driver side.
28    \author Elwood C. Downey
29    \author Jasem Mutlaq
30     
31     This file is divided into two main sections:\n
32     <ol><li> Functions the INDI device driver framework defines which the Driver may
33     call:</li>
34 
35      <ul><li>IDxxx functions to send messages to an INDI client.</li>
36      <li>IExxx functions to implement the event driven model.</li>
37      <li>IUxxx functions to perform handy utility functions.</li></ul>
38 
39     <li>Functions the INDI device driver framework calls which the Driver must
40    define:</li>
41 
42     <ul><li>ISxxx to respond to messages from a Client.</li></ul></ol>
43
44<p>These functions are the interface to the INDI C-language Device Driver
45reference implementation library. Any driver that uses this interface is
46expected to #include "indidevapi.h" and to link with indidrivermain.o and
47eventloop.o. Indidevapi.h further includes indiapi.h. The former contains
48the prototypes for the functions documented here, although many functions
49take arguments defined in the latter.</p>
50
51<p>These functions make it much easier to write a compliant INDI driver than
52starting from scratch, and also serve as a concrete
53example of the interactions an INDI driver, in any language, is expected to
54accommodate.</p>
55
56<p>The reference driver framework and the optimizations made within the reference
57indiserver both assume and require that one driver program implements exactly
58one logical INDI device.</p>
59
60<p>The functions in this framework fall into two broad categories. Some are
61functions that a driver must define because they are called by the reference
62framework; these functions begin with IS. The remaining functions are library
63utilities a driver may use to do important operations.</p>
64
65<p>A major point to realize is that an INDI driver built with this framework
66does not contain the C main() function. As soon as a driver begins executing,
67it listens on stdin for INDI messages. Only when a valid and appropriate
68message is received will it then call the driver via one of the IS functions.
69The driver is then expected to respond promptly by calling one of the ID
70library functions. It may also use any of the IU utility functions as desired
71to make processing a message easier.</p>
72
73<p>Rather separate from these IS, ID and IU functions are a collection of
74functions that utilize the notion of a callback. In a callback design,
75the driver registers a function with the framework to be called under
76certain circumstances. When said circumstances occur, the framework will
77call the callback function. The driver never calls these callbacks directly.
78These callback functions begin with IE. They can arrange for a callback
79function to be called under three kinds of circumstances: when a given file
80descriptor may be read without blocking (because either data is available
81or EOF has been encountered), when a given time interval has elapsed, or
82when the framework has nothing urgent to do. The callback functions for each
83circumstance must be written according to a well defined prototype since,
84after all, the framework must know how to call the callback correctlty.</p>
85
86*/
87 
88
89/*******************************************************************************
90 * get the data structures
91 */
92
93#include "indiapi.h"
94#include "lilxml.h"
95
96/*******************************************************************************
97 *******************************************************************************
98 *
99 *  Functions the INDI device driver framework defines which the Driver may call
100 *
101 *******************************************************************************
102 *******************************************************************************
103 */
104
105#ifdef __cplusplus
106extern "C" {
107#endif
108
109/**
110 * \defgroup d2cFunctions IDDef Functions: Functions drivers call to define their properties to clients.
111
112<p>Each of the following functions creates the appropriate XML formatted
113INDI message from its arguments and writes it to stdout. From there, is it
114typically read by indiserver which then sends it to the clients that have
115expressed interest in messages from the Device indicated in the message.</p>
116
117<p>In addition to type-specific arguments, all end with a printf-style format
118string, and appropriate subsequent arguments, that form the \param msg
119attribute within the INDI message. If the format argument is NULL, no message
120attribute is included with the message. Note that a \e timestamp
121attribute is also always added automatically based on the clock on the
122computer on which this driver is running.</p>
123
124*/
125
126
127/*@{*/
128
129/** \brief Tell client to create a text vector property.
130    \param t pointer to the vector text property to be defined.
131    \param msg message in printf style to send to the client. May be NULL.
132*/
133extern void IDDefText (const ITextVectorProperty *t, const char *msg, ...)
134#ifdef __GNUC__
135        __attribute__ ( ( format( printf, 2, 3 ) ) )
136#endif
137;
138
139/** \brief Tell client to create a number number property.
140    \param n pointer to the vector number property to be defined.
141    \param msg message in printf style to send to the client. May be NULL.
142*/
143extern void IDDefNumber (const INumberVectorProperty *n, const char *msg, ...)
144#ifdef __GNUC__
145        __attribute__ ( ( format( printf, 2, 3 ) ) )
146#endif
147;
148
149/** \brief Tell client to create a switch vector property.
150    \param s pointer to the vector switch property to be defined.
151    \param msg message in printf style to send to the client. May be NULL.
152*/
153extern void IDDefSwitch (const ISwitchVectorProperty *s, const char *msg, ...)
154#ifdef __GNUC__
155        __attribute__ ( ( format( printf, 2, 3 ) ) )
156#endif
157;
158
159/** \brief Tell client to create a light vector property.
160    \param l pointer to the vector light property to be defined.
161    \param msg message in printf style to send to the client. May be NULL.
162*/
163extern void IDDefLight (const ILightVectorProperty *l, const char *msg, ...)
164#ifdef __GNUC__
165        __attribute__ ( ( format( printf, 2, 3 ) ) )
166#endif
167;
168
169/** \brief Tell client to create a BLOB vector property.
170    \param b pointer to the vector BLOB property to be defined.
171    \param msg message in printf style to send to the client. May be NULL.
172 */
173extern void IDDefBLOB (const IBLOBVectorProperty *b, const char *msg, ...)
174#ifdef __GNUC__
175    __attribute__ ( ( format( printf, 2, 3 ) ) )
176#endif
177;
178
179
180/*@}*/
181
182/**
183 * \defgroup d2cuFunctions IDSet Functions: Functions drivers call to tell clients of new values for existing properties.
184 */
185/*@{*/
186
187/** \brief Tell client to update an existing text vector property.
188    \param t pointer to the vector text property.
189    \param msg message in printf style to send to the client. May be NULL.
190*/
191extern void IDSetText (const ITextVectorProperty *t, const char *msg, ...)
192#ifdef __GNUC__
193        __attribute__ ( ( format( printf, 2, 3 ) ) )
194#endif
195;
196
197/** \brief Tell client to update an existing number vector property.
198    \param n pointer to the vector number property.
199    \param msg message in printf style to send to the client. May be NULL.
200*/
201extern void IDSetNumber (const INumberVectorProperty *n, const char *msg, ...)
202#ifdef __GNUC__
203        __attribute__ ( ( format( printf, 2, 3 ) ) )
204#endif
205;
206
207/** \brief Tell client to update an existing switch vector property.
208    \param s pointer to the vector switch property.
209    \param msg message in printf style to send to the client. May be NULL.
210*/
211extern void IDSetSwitch (const ISwitchVectorProperty *s, const char *msg, ...)
212#ifdef __GNUC__
213        __attribute__ ( ( format( printf, 2, 3 ) ) )
214#endif
215;
216
217/** \brief Tell client to update an existing light vector property.
218    \param l pointer to the vector light property.
219    \param msg message in printf style to send to the client. May be NULL.
220*/
221extern void IDSetLight (const ILightVectorProperty *l, const char *msg, ...)
222#ifdef __GNUC__
223        __attribute__ ( ( format( printf, 2, 3 ) ) )
224#endif
225;
226
227/** \brief Tell client to update an existing BLOB vector property.
228    \param b pointer to the vector BLOB property.
229    \param msg message in printf style to send to the client. May be NULL.
230 */
231extern void IDSetBLOB (const IBLOBVectorProperty *b, const char *msg, ...)
232#ifdef __GNUC__
233    __attribute__ ( ( format( printf, 2, 3 ) ) )
234#endif
235;
236
237/*@}*/
238
239/**
240 * \defgroup d2duFunctions ID Functions: Functions to delete properties, and log messages locally or remotely.
241 */
242/*@{*/
243
244
245/** \brief Function Drivers call to send log messages to Clients.
246 
247    If dev is specified the Client shall associate the message with that device; if dev is NULL the Client shall treat the message as generic from no specific Device.
248   
249    \param dev device name
250    \param msg message in printf style to send to the client.
251*/
252extern void IDMessage (const char *dev, const char *msg, ...)
253#ifdef __GNUC__
254        __attribute__ ( ( format( printf, 2, 3 ) ) )
255#endif
256;
257
258/** \brief Function Drivers call to inform Clients a Property is no longer available, or the entire device is gone if name is NULL.
259
260    \param dev device name. If device name is NULL, the entire device will be deleted.
261    \param name property name to be deleted.
262    \param msg message in printf style to send to the client.
263*/
264extern void IDDelete (const char *dev, const char *name, const char *msg, ...)
265#ifdef __GNUC__
266        __attribute__ ( ( format( printf, 3, 4 ) ) )
267#endif
268;
269
270/** \brief Function Drivers call to log a message locally.
271 
272    The message is not sent to any Clients.
273   
274    \param msg message in printf style to send to the client.
275*/
276extern void IDLog (const char *msg, ...)
277#ifdef __GNUC__
278        __attribute__ ( ( format( printf, 1, 2 ) ) )
279#endif
280;
281
282/*@}*/
283
284/**
285 * \defgroup snoopFunctions ISnoop Functions: Functions drivers call to snoop on other drivers.
286 
287 */
288/*@{*/
289
290
291/** \typedef BLOBHandling
292    \brief How drivers handle BLOBs incoming from snooping drivers */
293typedef enum 
294{
295  B_NEVER=0,    /*!< Never receive BLOBs */
296  B_ALSO,       /*!< Receive BLOBs along with normal messages */
297  B_ONLY        /*!< ONLY receive BLOBs from drivers, ignore all other traffic */
298} BLOBHandling;
299
300/** \brief Function a Driver calls to snoop on another Device. Snooped messages will then arrive via ISSnoopDevice.
301    \param snooped_device name of the device to snoop.
302    \param snooped_property name of the snooped property in the device.
303*/
304extern void IDSnoopDevice (const char *snooped_device, const char *snooped_property);
305
306/** \brief Function a Driver calls to control whether they will receive BLOBs from snooped devices.
307    \param snooped_device name of the device to snoop.
308    \param bh How drivers handle BLOBs incoming from snooping drivers.
309*/
310extern void IDSnoopBLOBs (const char *snooped_device, BLOBHandling bh);
311
312/*@}*/
313
314/**
315 * \defgroup deventFunctions IE Functions: Functions drivers call to register with the INDI event utilities.
316 
317     Callbacks are called when a read on a file descriptor will not block. Timers are called once after a specified interval. Workprocs are called when there is nothing else to do. The "Add" functions return a unique id for use with their corresponding "Rm" removal function. An arbitrary pointer may be specified when a function is registered which will be stored and forwarded unchanged when the function is later invoked.
318 */
319/*@{*/
320     
321 /* signature of a callback, timout caller and work procedure function */
322
323/** \typedef IE_CBF
324    \brief Signature of a callback. */
325typedef void (IE_CBF) (int readfiledes, void *userpointer);
326
327/** \typedef IE_TCF
328    \brief Signature of a timeout caller. */
329typedef void (IE_TCF) (void *userpointer);
330
331/** \typedef IE_WPF
332    \brief Signature of a work procedure function. */
333typedef void (IE_WPF) (void *userpointer);
334
335/* functions to add and remove callbacks, timers and work procedures */
336
337/** \brief Register a new callback, \e fp, to be called with \e userpointer as argument when \e readfiledes is ready.
338*
339* \param readfiledes file descriptor.
340* \param fp a pointer to the callback function.
341* \param userpointer a pointer to be passed to the callback function when called.
342* \return a unique callback id for use with IERmCallback().
343*/
344extern int  IEAddCallback (int readfiledes, IE_CBF *fp, void *userpointer);
345
346/** \brief Remove a callback function.
347*
348* \param callbackid the callback ID returned from IEAddCallback()
349*/
350extern void IERmCallback (int callbackid);
351
352/** \brief Register a new timer function, \e fp, to be called with \e ud as argument after \e ms.
353 
354 Add to list in order of decreasing time from epoch, ie, last entry runs soonest. The timer will only invoke the callback function \b once. You need to call addTimer again if you want to repeat the process.
355*
356* \param millisecs timer period in milliseconds.
357* \param fp a pointer to the callback function.
358* \param userpointer a pointer to be passed to the callback function when called.
359* \return a unique id for use with IERmTimer().
360*/
361extern int  IEAddTimer (int millisecs, IE_TCF *fp, void *userpointer);
362
363/** \brief Remove the timer with the given \e timerid, as returned from IEAddTimer.
364*
365* \param timerid the timer callback ID returned from IEAddTimer().
366*/
367extern void IERmTimer (int timerid);
368
369/** \brief Add a new work procedure, fp, to be called with ud when nothing else to do.
370*
371* \param fp a pointer to the work procedure callback function.
372* \param userpointer a pointer to be passed to the callback function when called.
373* \return a unique id for use with IERmWorkProc().
374*/
375extern int  IEAddWorkProc (IE_WPF *fp, void *userpointer);
376
377/** \brief Remove a work procedure.
378*
379* \param workprocid The unique ID for the work procedure to be removed.
380*/
381extern void IERmWorkProc (int workprocid);
382
383/* wait in-line for a flag to set, presumably by another event function */
384
385extern int IEDeferLoop (int maxms, int *flagp);
386extern int IEDeferLoop0 (int maxms, int *flagp);
387
388/*@}*/
389
390/**
391 * \defgroup dutilFunctions IU Functions: Functions drivers call to perform handy utility routines.
392
393<p>This section describes handy utility functions that are provided by the
394framework for tasks commonly required in the processing of client
395messages. It is not strictly necessary to use these functions, but it
396both prudent and efficient to do so.</P>
397
398<p>These do not communicate with the Client in any way.</p>
399 */
400/*@{*/
401
402
403/** \brief Find an IText member in a vector text property.
404*
405* \param tvp a pointer to a text vector property.
406* \param name the name of the member to search for.
407* \return a pointer to an IText member on match, or NULL if nothing is found.
408*/
409extern IText   *IUFindText  (const ITextVectorProperty *tvp, const char *name);
410
411/** \brief Find an INumber member in a number text property.
412*
413* \param nvp a pointer to a number vector property.
414* \param name the name of the member to search for.
415* \return a pointer to an INumber member on match, or NULL if nothing is found.
416*/
417extern INumber *IUFindNumber(const INumberVectorProperty *nvp, const char *name);
418
419/** \brief Find an ISwitch member in a vector switch property.
420*
421* \param svp a pointer to a switch vector property.
422* \param name the name of the member to search for.
423* \return a pointer to an ISwitch member on match, or NULL if nothing is found.
424*/
425extern ISwitch *IUFindSwitch(const ISwitchVectorProperty *svp, const char *name);
426
427/** \brief Find an ILight member in a vector Light property.
428*
429* \param lvp a pointer to a Light vector property.
430* \param name the name of the member to search for.
431* \return a pointer to an ILight member on match, or NULL if nothing is found.
432*/
433extern ILight *IUFindLight(const ILightVectorProperty *lvp, const char *name);
434
435/** \brief Find an IBLOB member in a vector BLOB property.
436*
437* \param bvp a pointer to a BLOB vector property.
438* \param name the name of the member to search for.
439* \return a pointer to an IBLOB member on match, or NULL if nothing is found.
440*/
441extern IBLOB *IUFindBLOB(const IBLOBVectorProperty *bvp, const char *name);
442
443/** \brief Returns the first ON switch it finds in the vector switch property.
444
445*   \note This is only valid for ISR_1OFMANY mode. That is, when only one switch out of many is allowed to be ON. Do not use this function if you can have multiple ON switches in the same vector property.
446*       
447* \param sp a pointer to a switch vector property.
448* \return a pointer to the \e first ON ISwitch member if found. If all switches are off, NULL is returned.
449*/
450extern ISwitch *IUFindOnSwitch (const ISwitchVectorProperty *sp);
451
452/** \brief Returns the index of first ON switch it finds in the vector switch property.
453
454*   \note This is only valid for ISR_1OFMANY mode. That is, when only one switch out of many is allowed to be ON. Do not use this function if you can have multiple ON switches in the same vector property.
455*
456* \param sp a pointer to a switch vector property.
457* \return index to the \e first ON ISwitch member if found. If all switches are off, -1 is returned.
458*/
459
460extern int IUFindOnSwitchIndex (const ISwitchVectorProperty *sp);
461
462/** \brief Reset all switches in a switch vector property to OFF.
463*
464* \param svp a pointer to a switch vector property.
465*/
466extern void IUResetSwitch(ISwitchVectorProperty *svp);
467
468/** \brief Update all switches in a switch vector property.
469*
470* \param svp a pointer to a switch vector property.
471* \param states the states of the new ISwitch members.
472* \param names the names of the ISwtich members to update.
473* \param n the number of ISwitch members to update.
474* \return 0 if update successful, -1 otherwise.
475*/
476extern int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n);
477
478/** \brief Update all numbers in a number vector property.
479*
480* \param nvp a pointer to a number vector property.
481* \param values the states of the new INumber members.
482* \param names the names of the INumber members to update.
483* \param n the number of INumber members to update.
484* \return 0 if update successful, -1 otherwise. Update will fail if values are out of scope, or in case of property name mismatch.
485*/
486extern int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n);
487
488/** \brief Update all text members in a text vector property.
489*
490* \param tvp a pointer to a text vector property.
491* \param texts a pointer to the text members
492* \param names the names of the IText members to update.
493* \param n the number of IText members to update.
494* \return 0 if update successful, -1 otherwise. Update will fail in case of property name mismatch.
495*/
496extern int IUUpdateText(ITextVectorProperty *tvp, char * texts[], char *names[], int n);
497
498/** \brief Update all BLOB members in a BLOB vector property.
499*
500* \param bvp a pointer to a BLOB vector property.
501* \param BLOBs a pointer to the BLOB members
502* \param names the names of the IBLOB members to update.
503* \param n the number of IBLOB members to update.
504* \return 0 if update successful, -1 otherwise. Update will fail in case of property name mismatch.
505*/
506extern int IUUpdateBLOB(IBLOBVectorProperty *bvp, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n);
507
508/** \brief Function to save blob metadata in the corresponding blob.
509    \param tb pointer to an IBLOB member.
510    \param size size of the blob buffer encoded in base64
511    \param blobsize actual size of the buffer after base64 decoding. This is the actual byte count used in drivers.
512    \param blob pointer to the blob buffer
513    \param format format of the blob buffer
514    \note Do not call this function directly, it is called internally by IUUpdateBLOB.
515    */
516extern int IUSaveBLOB(IBLOB *bp, int size, int blobsize, char *blob, char *format);
517
518/** \brief Function to update the min and max elements of a number in the client
519    \param nvp pointer to an INumberVectorProperty.
520 */
521extern void IUUpdateMinMax(const INumberVectorProperty *nvp);
522
523/** \brief Function to reliably save new text in a IText.
524    \param tp pointer to an IText member.
525    \param newtext the new text to be saved     
526*/
527extern void IUSaveText (IText *tp, const char *newtext);
528
529/** \brief Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
530    \param sp pointer a switch property to fill
531    \param name the switch name
532    \param label the switch label
533    \param s the switch state (ISS_ON or ISS_OFF)
534*/
535extern void IUFillSwitch(ISwitch *sp, const char *name, const char * label, ISState s);
536
537/** \brief Assign attributes for a light property. The light's auxiliary elements will be set to NULL.
538    \param lp pointer a light property to fill
539    \param name the light name
540    \param label the light label
541    \param s the light state (IDLE, WARNING, OK, ALERT)
542*/
543extern void IUFillLight(ILight *lp, const char *name, const char * label, IPState s);
544
545/** \brief Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
546    \param np pointer a number property to fill
547    \param name the number name
548    \param label the number label
549    \param format the number format in printf style (e.g. "%02d")
550    \param min  the minimum possible value
551    \param max the maximum possible value
552    \param step the step used to climb from minimum value to maximum value
553    \param value the number's current value
554*/
555extern void IUFillNumber(INumber *np, const char *name, const char * label, const char *format, double min, double max, double step, double value);
556
557/** \brief Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
558    \param tp pointer a text property to fill
559    \param name the text name
560    \param label the text label
561    \param initialText the initial text
562*/
563extern void IUFillText(IText *tp, const char *name, const char * label, const char *initialText);
564
565/** \brief Assign attributes for a BLOB property. The BLOB's data and auxiliary elements will be set to NULL.
566    \param bp pointer a BLOB property to fill
567    \param name the BLOB name
568    \param label the BLOB label
569    \param format the BLOB format.
570*/
571extern void IUFillBLOB(IBLOB *bp, const char *name, const char * label, const char *format);
572
573/** \brief Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
574    \param svp pointer a switch vector property to fill
575    \param sp pointer to an array of switches
576    \param nsp the dimension of sp
577    \param dev the device name this vector property belongs to
578    \param name the vector property name
579    \param label the vector property label
580    \param group the vector property group
581    \param p the vector property permission
582    \param r the switches behavior
583    \param timeout vector property timeout in seconds
584    \param s the vector property initial state.
585*/
586extern 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);
587
588/** \brief Assign attributes for a light vector property. The vector's auxiliary elements will be set to NULL.
589    \param lvp pointer a light vector property to fill
590    \param lp pointer to an array of lights
591    \param nlp the dimension of lp
592    \param dev the device name this vector property belongs to
593    \param name the vector property name
594    \param label the vector property label
595    \param group the vector property group
596    \param s the vector property initial state.
597*/
598extern void IUFillLightVector(ILightVectorProperty *lvp, ILight *lp, int nlp, const char * dev, const char *name, const char *label, const char *group, IPState s);
599
600/** \brief Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
601    \param nvp pointer a number vector property to fill
602    \param np pointer to an array of numbers
603    \param nnp the dimension of np
604    \param dev the device name this vector property belongs to
605    \param name the vector property name
606    \param label the vector property label
607    \param group the vector property group
608    \param p the vector property permission
609    \param timeout vector property timeout in seconds
610    \param s the vector property initial state.
611*/
612extern 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);
613
614/** \brief Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
615    \param tvp pointer a text vector property to fill
616    \param tp pointer to an array of texts
617    \param ntp the dimension of tp
618    \param dev the device name this vector property belongs to
619    \param name the vector property name
620    \param label the vector property label
621    \param group the vector property group
622    \param p the vector property permission
623    \param timeout vector property timeout in seconds
624    \param s the vector property initial state.
625*/
626extern 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);
627
628/** \brief Assign attributes for a BLOB vector property. The vector's auxiliary elements will be set to NULL.
629    \param bvp pointer a BLOB vector property to fill
630    \param bp pointer to an array of BLOBs
631    \param nbp the dimension of bp
632    \param dev the device name this vector property belongs to
633    \param name the vector property name
634    \param label the vector property label
635    \param group the vector property group
636    \param p the vector property permission
637    \param timeout vector property timeout in seconds
638    \param s the vector property initial state.
639*/
640extern 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);
641
642
643/** \brief Update a snooped number vector property from the given XML root element.
644    \param root XML root elememnt containing the snopped property content
645    \param nvp a pointer to the number vector property to be updated.
646    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
647*/
648extern int IUSnoopNumber (XMLEle *root, INumberVectorProperty *nvp);
649
650/** \brief Update a snooped text vector property from the given XML root element.
651    \param root XML root elememnt containing the snopped property content
652    \param tvp a pointer to the text vector property to be updated.
653    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
654*/
655extern int IUSnoopText (XMLEle *root, ITextVectorProperty *tvp);
656
657/** \brief Update a snooped light vector property from the given XML root element.
658    \param root XML root elememnt containing the snopped property content
659    \param lvp a pointer to the light vector property to be updated.
660    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
661*/
662extern int IUSnoopLight (XMLEle *root, ILightVectorProperty *lvp);
663
664/** \brief Update a snooped switch vector property from the given XML root element.
665    \param root XML root elememnt containing the snopped property content
666    \param svp a pointer to the switch vector property to be updated.
667    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
668*/
669extern int IUSnoopSwitch (XMLEle *root, ISwitchVectorProperty *svp);
670
671/** \brief Update a snooped BLOB vector property from the given XML root element.
672    \param root XML root elememnt containing the snopped property content
673    \param bvp a pointer to the BLOB vector property to be updated.
674    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
675*/
676extern int IUSnoopBLOB (XMLEle *root, IBLOBVectorProperty *bvp);
677
678/*@}*/
679
680/*******************************************************************************
681 *******************************************************************************
682 *
683 *   Functions the INDI Device Driver framework calls which the Driver must
684 *   define.
685 *
686 *******************************************************************************
687 *******************************************************************************
688 */
689
690
691
692/**
693 * \defgroup dcuFunctions IS Functions: Functions all drivers must define.
694 
695This section defines functions that must be defined in each driver. These
696functions are never called by the driver, but are called by the driver
697framework. These must always be defined even if they do nothing.
698*/
699/*@{*/
700
701/** \brief Get Device Properties
702    \param dev the name of the device.
703
704This function is called by the framework whenever the driver has received a
705getProperties message from an INDI client. The argument \param dev is either a
706string containing the name of the device specified within the message, or NULL
707if no device was specified. If the driver does not recognize the device, it
708should ignore the message and do nothing. If dev matches the device the driver
709is implementing, or dev is NULL, the driver must respond by sending one defXXX
710message to describe each property defined by this device, including its
711current (or initial) value. The recommended way to send these messages is to
712call the appropriate IDDef functions.
713*/ 
714extern void ISGetProperties (const char *dev);
715
716
717/** \brief Update the value of an existing text vector property.
718    \param dev the name of the device.
719    \param name the name of the text vector property to update.
720    \param texts an array of text values.
721    \param names parallel names to the array of text values.
722    \param n the dimension of texts[].
723    \note You do not need to call this function, it is called by INDI when new text values arrive from the client.
724*/
725extern void ISNewText (const char *dev, const char *name, char *texts[],
726    char *names[], int n); 
727
728/** \brief Update the value of an existing number vector property.
729    \param dev the name of the device.
730    \param name the name of the number vector property to update.
731    \param doubles an array of number values.
732    \param names parallel names to the array of number values.
733    \param n the dimension of doubles[].
734    \note You do not need to call this function, it is called by INDI when new number values arrive from the client.
735*/
736extern void ISNewNumber (const char *dev, const char *name, double *doubles,
737    char *names[], int n); 
738
739/** \brief Update the value of an existing switch vector property.
740    \param dev the name of the device.
741    \param name the name of the switch vector property to update.
742    \param states an array of switch states.
743    \param names parallel names to the array of switch states.
744    \param n the dimension of states[].
745    \note You do not need to call this function, it is called by INDI when new switch values arrive from the client.
746*/
747extern void ISNewSwitch (const char *dev, const char *name, ISState *states,
748    char *names[], int n); 
749
750/** \brief Update data of an existing blob vector property.
751    \param dev the name of the device.
752    \param name the name of the blob vector property to update.
753    \param sizes an array of base64 blob sizes in bytes \e before decoding.
754    \param blobsizes an array of the sizes of blobs \e after decoding from base64.
755    \param blobs an array of decoded data. Each blob size is found in \e blobsizes array.
756    \param formats Blob data format (e.g. fits.z).
757    \param names names of blob members to update.
758    \param n the number of blobs to update.
759    \note You do not need to call this function, it is called by INDI when new blob values arrive from the client.
760          e.g. BLOB element with name names[0] has data located in blobs[0] with size sizes[0] and format formats[0].
761*/
762
763extern void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n); 
764
765/** \brief Function defined by Drivers that is called when another Driver it is snooping (by having previously called IDSnoopDevice()) sent any INDI message.
766    \param root The argument contains the full message exactly as it was sent by the driver.
767    \e Hint: use the IUSnoopXXX utility functions to help crack the message if it was one of setXXX or defXXX.
768*/
769extern void ISSnoopDevice (XMLEle *root);
770
771/*@}*/
772
773/* Handy readability macro to avoid unused variables warnings */
774#define INDI_UNUSED(x) (void) x
775
776/** \brief Extract dev and name attributes from an XML element.
777    \param root The XML element to be parsed.
778    \param dev pointer to an allocated buffer to save the extracted element device name attribute.
779           The buffer size must be at least MAXINDIDEVICE bytes.
780    \param name pointer to an allocated buffer to save the extracted elemented name attribute.
781           The buffer size must be at least MAXINDINAME bytes.
782    \param msg pointer to an allocated char buffer to store error messages. The minimum buffer size is MAXRBUF.
783    \return 0 if successful, -1 if error is encountered and msg is set.
784*/
785extern int crackDN (XMLEle *root, char **dev, char **name, char msg[]);
786
787/** \brief Extract property state (Idle, OK, Busy, Alert) from the supplied string.
788    \param str A string representation of the state.
789    \param ip Pointer to IPState structure to store the extracted property state.
790    \return 0 if successful, -1 if error is encountered.
791*/
792extern int crackIPState (const char *str, IPState *ip);
793
794/** \brief Extract switch state (On or Off) from the supplied string.
795    \param str A string representation of the switch state.
796    \param ip Pointer to ISState structure to store the extracted switch state.
797    \return 0 if successful, -1 if error is encountered.
798*/
799extern int crackISState (const char *str, ISState *ip);
800
801/** \brief Extract property permission state (RW, RO, WO) from the supplied string.
802    \param str A string representation of the permission state.
803    \param ip Pointer to IPerm structure to store the extracted permission state.
804    \return 0 if successful, -1 if error is encountered.
805*/
806extern int crackIPerm (const char *str, IPerm *ip);
807
808/** \brief Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
809    \param str A string representation of the switch rule.
810    \param ip Pointer to ISRule structure to store the extracted switch rule.
811    \return 0 if successful, -1 if error is encountered.
812*/
813extern int crackISRule (const char *str, ISRule *ip);
814
815/** \return Returns a string representation of the supplied property state. */
816extern const char *pstateStr(IPState s);
817/** \return Returns a string representation of the supplied switch status. */
818extern const char *sstateStr(ISState s);
819/** \return Returns a string representation of the supplied switch rule. */
820extern const char *ruleStr(ISRule r);
821/** \return Returns a string representation of the supplied permission value. */
822extern const char *permStr(IPerm p);
823
824extern void xmlv1(void);
825
826#ifdef __cplusplus
827}
828#endif
829
830#endif
Note: See TracBrowser for help on using the repository browser.