source: BAORadio/libindi/libindi/indidevapi.h @ 645

Last change on this file since 645 was 501, checked in by frichard, 14 years ago

-BAOControl : petite interface permettant de contrôler les antennes via le pilote indi_BAO
-Le pilote indi_BAO utilise désormais libindi v 0.7

File size: 34.5 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 Reset all switches in a switch vector property to OFF.
453*
454* \param svp a pointer to a switch vector property.
455*/
456extern void IUResetSwitch(ISwitchVectorProperty *svp);
457
458/** \brief Update all switches in a switch vector property.
459*
460* \param svp a pointer to a switch vector property.
461* \param states the states of the new ISwitch members.
462* \param names the names of the ISwtich members to update.
463* \param n the number of ISwitch members to update.
464* \return 0 if update successful, -1 otherwise.
465*/
466extern int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n);
467
468/** \brief Update all numbers in a number vector property.
469*
470* \param nvp a pointer to a number vector property.
471* \param values the states of the new INumber members.
472* \param names the names of the INumber members to update.
473* \param n the number of INumber members to update.
474* \return 0 if update successful, -1 otherwise. Update will fail if values are out of scope, or in case of property name mismatch.
475*/
476extern int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n);
477
478/** \brief Update all text members in a text vector property.
479*
480* \param tvp a pointer to a text vector property.
481* \param texts a pointer to the text members
482* \param names the names of the IText members to update.
483* \param n the number of IText members to update.
484* \return 0 if update successful, -1 otherwise. Update will fail in case of property name mismatch.
485*/
486extern int IUUpdateText(ITextVectorProperty *tvp, char * texts[], char *names[], int n);
487
488/** \brief Function to update the min and max elements of a number in the client
489    \param nvp pointer to an INumberVectorProperty.
490 */
491extern void IUUpdateMinMax(const INumberVectorProperty *nvp);
492
493/** \brief Function to reliably save new text in a IText.
494    \param tp pointer to an IText member.
495    \param newtext the new text to be saved     
496*/
497extern void IUSaveText (IText *tp, const char *newtext);
498
499/** \brief Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
500    \param sp pointer a switch property to fill
501    \param name the switch name
502    \param label the switch label
503    \param s the switch state (ISS_ON or ISS_OFF)
504*/
505extern void IUFillSwitch(ISwitch *sp, const char *name, const char * label, ISState s);
506
507/** \brief Assign attributes for a light property. The light's auxiliary elements will be set to NULL.
508    \param lp pointer a light property to fill
509    \param name the light name
510    \param label the light label
511    \param s the light state (IDLE, WARNING, OK, ALERT)
512*/
513extern void IUFillLight(ILight *lp, const char *name, const char * label, IPState s);
514
515/** \brief Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
516    \param np pointer a number property to fill
517    \param name the number name
518    \param label the number label
519    \param format the number format in printf style (e.g. "%02d")
520    \param min  the minimum possible value
521    \param max the maximum possible value
522    \param step the step used to climb from minimum value to maximum value
523    \param value the number's current value
524*/
525extern void IUFillNumber(INumber *np, const char *name, const char * label, const char *format, double min, double max, double step, double value);
526
527/** \brief Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
528    \param tp pointer a text property to fill
529    \param name the text name
530    \param label the text label
531    \param initialText the initial text
532*/
533extern void IUFillText(IText *tp, const char *name, const char * label, const char *initialText);
534
535/** \brief Assign attributes for a BLOB property. The BLOB's data and auxiliary elements will be set to NULL.
536    \param bp pointer a BLOB property to fill
537    \param name the BLOB name
538    \param label the BLOB label
539    \param format the BLOB format.
540*/
541extern void IUFillBLOB(IBLOB *bp, const char *name, const char * label, const char *format);
542
543/** \brief Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
544    \param svp pointer a switch vector property to fill
545    \param sp pointer to an array of switches
546    \param nsp the dimension of sp
547    \param dev the device name this vector property belongs to
548    \param name the vector property name
549    \param label the vector property label
550    \param group the vector property group
551    \param p the vector property permission
552    \param r the switches behavior
553    \param timeout vector property timeout in seconds
554    \param s the vector property initial state.
555*/
556extern 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);
557
558/** \brief Assign attributes for a light vector property. The vector's auxiliary elements will be set to NULL.
559    \param lvp pointer a light vector property to fill
560    \param lp pointer to an array of lights
561    \param nlp the dimension of lp
562    \param dev the device name this vector property belongs to
563    \param name the vector property name
564    \param label the vector property label
565    \param group the vector property group
566    \param s the vector property initial state.
567*/
568extern void IUFillLightVector(ILightVectorProperty *lvp, ILight *lp, int nlp, const char * dev, const char *name, const char *label, const char *group, IPState s);
569
570/** \brief Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
571    \param nvp pointer a number vector property to fill
572    \param np pointer to an array of numbers
573    \param nnp the dimension of np
574    \param dev the device name this vector property belongs to
575    \param name the vector property name
576    \param label the vector property label
577    \param group the vector property group
578    \param p the vector property permission
579    \param timeout vector property timeout in seconds
580    \param s the vector property initial state.
581*/
582extern 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);
583
584/** \brief Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
585    \param tvp pointer a text vector property to fill
586    \param tp pointer to an array of texts
587    \param ntp the dimension of tp
588    \param dev the device name this vector property belongs to
589    \param name the vector property name
590    \param label the vector property label
591    \param group the vector property group
592    \param p the vector property permission
593    \param timeout vector property timeout in seconds
594    \param s the vector property initial state.
595*/
596extern 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);
597
598/** \brief Assign attributes for a BLOB vector property. The vector's auxiliary elements will be set to NULL.
599    \param bvp pointer a BLOB vector property to fill
600    \param bp pointer to an array of BLOBs
601    \param nbp the dimension of bp
602    \param dev the device name this vector property belongs to
603    \param name the vector property name
604    \param label the vector property label
605    \param group the vector property group
606    \param p the vector property permission
607    \param timeout vector property timeout in seconds
608    \param s the vector property initial state.
609*/
610extern 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);
611
612
613/** \brief Update a snooped number vector property from the given XML root element.
614    \param root XML root elememnt containing the snopped property content
615    \param nvp a pointer to the number vector property to be updated.
616    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
617*/
618extern int IUSnoopNumber (XMLEle *root, INumberVectorProperty *nvp);
619
620/** \brief Update a snooped text vector property from the given XML root element.
621    \param root XML root elememnt containing the snopped property content
622    \param tvp a pointer to the text vector property to be updated.
623    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
624*/
625extern int IUSnoopText (XMLEle *root, ITextVectorProperty *tvp);
626
627/** \brief Update a snooped light vector property from the given XML root element.
628    \param root XML root elememnt containing the snopped property content
629    \param lvp a pointer to the light vector property to be updated.
630    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
631*/
632extern int IUSnoopLight (XMLEle *root, ILightVectorProperty *lvp);
633
634/** \brief Update a snooped switch vector property from the given XML root element.
635    \param root XML root elememnt containing the snopped property content
636    \param svp a pointer to the switch vector property to be updated.
637    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
638*/
639extern int IUSnoopSwitch (XMLEle *root, ISwitchVectorProperty *svp);
640
641/** \brief Update a snooped BLOB vector property from the given XML root element.
642    \param root XML root elememnt containing the snopped property content
643    \param bvp a pointer to the BLOB vector property to be updated.
644    \return 0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.
645*/
646extern int IUSnoopBLOB (XMLEle *root, IBLOBVectorProperty *bvp);
647
648/*@}*/
649
650/*******************************************************************************
651 *******************************************************************************
652 *
653 *   Functions the INDI Device Driver framework calls which the Driver must
654 *   define.
655 *
656 *******************************************************************************
657 *******************************************************************************
658 */
659
660
661
662/**
663 * \defgroup dcuFunctions IS Functions: Functions all drivers must define.
664 
665This section defines functions that must be defined in each driver. These
666functions are never called by the driver, but are called by the driver
667framework. These must always be defined even if they do nothing.
668*/
669/*@{*/
670
671/** \brief Get Device Properties
672    \param dev the name of the device.
673
674This function is called by the framework whenever the driver has received a
675getProperties message from an INDI client. The argument \param dev is either a
676string containing the name of the device specified within the message, or NULL
677if no device was specified. If the driver does not recognize the device, it
678should ignore the message and do nothing. If dev matches the device the driver
679is implementing, or dev is NULL, the driver must respond by sending one defXXX
680message to describe each property defined by this device, including its
681current (or initial) value. The recommended way to send these messages is to
682call the appropriate IDDef functions.
683*/ 
684extern void ISGetProperties (const char *dev);
685
686
687/** \brief Update the value of an existing text vector property.
688    \param dev the name of the device.
689    \param name the name of the text vector property to update.
690    \param texts an array of text values.
691    \param names parallel names to the array of text values.
692    \param n the dimension of texts[].
693    \note You do not need to call this function, it is called by INDI when new text values arrive from the client.
694*/
695extern void ISNewText (const char *dev, const char *name, char *texts[],
696    char *names[], int n); 
697
698/** \brief Update the value of an existing number vector property.
699    \param dev the name of the device.
700    \param name the name of the number vector property to update.
701    \param doubles an array of number values.
702    \param names parallel names to the array of number values.
703    \param n the dimension of doubles[].
704    \note You do not need to call this function, it is called by INDI when new number values arrive from the client.
705*/
706extern void ISNewNumber (const char *dev, const char *name, double *doubles,
707    char *names[], int n); 
708
709/** \brief Update the value of an existing switch vector property.
710    \param dev the name of the device.
711    \param name the name of the switch vector property to update.
712    \param states an array of switch states.
713    \param names parallel names to the array of switch states.
714    \param n the dimension of states[].
715    \note You do not need to call this function, it is called by INDI when new switch values arrive from the client.
716*/
717extern void ISNewSwitch (const char *dev, const char *name, ISState *states,
718    char *names[], int n); 
719
720/** \brief Update data of an existing blob vector property.
721    \param dev the name of the device.
722    \param name the name of the blob vector property to update.
723    \param sizes an array of base64 blob sizes in bytes \e before decoding.
724    \param blobsizes an array of the sizes of blobs \e after decoding from base64.
725    \param blobs an array of decoded data. Each blob size is found in \e blobsizes array.
726    \param formats Blob data format (e.g. fits.z).
727    \param names names of blob members to update.
728    \param n the number of blobs to update.
729    \note You do not need to call this function, it is called by INDI when new blob values arrive from the client.
730          e.g. BLOB element with name names[0] has data located in blobs[0] with size sizes[0] and format formats[0].
731*/
732
733extern void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n); 
734
735/** \brief Function defined by Drivers that is called when another Driver it is snooping (by having previously called IDSnoopDevice()) sent any INDI message.
736    \param root The argument contains the full message exactly as it was sent by the driver.
737    \e Hint: use the IUSnoopXXX utility functions to help crack the message if it was one of setXXX or defXXX.
738*/
739extern void ISSnoopDevice (XMLEle *root);
740
741/*@}*/
742
743/* Handy readability macro to avoid unused variables warnings */
744#define INDI_UNUSED(x) (void) x
745
746/** \brief Extract dev and name attributes from an XML element.
747    \param root The XML element to be parsed.
748    \param dev pointer to an allocated buffer to save the extracted element device name attribute.
749           The buffer size must be at least MAXINDIDEVICE bytes.
750    \param name pointer to an allocated buffer to save the extracted elemented name attribute.
751           The buffer size must be at least MAXINDINAME bytes.
752    \param msg pointer to an allocated char buffer to store error messages. The minimum buffer size is MAXRBUF.
753    \return 0 if successful, -1 if error is encountered and msg is set.
754*/
755extern int crackDN (XMLEle *root, char **dev, char **name, char msg[]);
756
757/** \brief Extract property state (Idle, OK, Busy, Alert) from the supplied string.
758    \param str A string representation of the state.
759    \param ip Pointer to IPState structure to store the extracted property state.
760    \return 0 if successful, -1 if error is encountered.
761*/
762extern int crackIPState (const char *str, IPState *ip);
763
764/** \brief Extract switch state (On or Off) from the supplied string.
765    \param str A string representation of the switch state.
766    \param ip Pointer to ISState structure to store the extracted switch state.
767    \return 0 if successful, -1 if error is encountered.
768*/
769extern int crackISState (const char *str, ISState *ip);
770
771/** \brief Extract property permission state (RW, RO, WO) from the supplied string.
772    \param str A string representation of the permission state.
773    \param ip Pointer to IPerm structure to store the extracted permission state.
774    \return 0 if successful, -1 if error is encountered.
775*/
776extern int crackIPerm (const char *str, IPerm *ip);
777
778/** \brief Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
779    \param str A string representation of the switch rule.
780    \param ip Pointer to ISRule structure to store the extracted switch rule.
781    \return 0 if successful, -1 if error is encountered.
782*/
783extern int crackISRule (const char *str, ISRule *ip);
784
785/** \return Returns a string representation of the supplied property state. */
786extern const char *pstateStr(IPState s);
787/** \return Returns a string representation of the supplied switch status. */
788extern const char *sstateStr(ISState s);
789/** \return Returns a string representation of the supplied switch rule. */
790extern const char *ruleStr(ISRule r);
791/** \return Returns a string representation of the supplied permission value. */
792extern const char *permStr(IPerm p);
793
794extern void xmlv1(void);
795
796#ifdef __cplusplus
797}
798#endif
799
800#endif
Note: See TracBrowser for help on using the repository browser.