Instrument Neutral Distributed Interface INDI  1.9.2
Classes | Macros | Enumerations | Functions | Variables
indidriver.c File Reference
#include "indidriver.h"
#include "base64.h"
#include "indicom.h"
#include "indidevapi.h"
#include "locale_compat.h"
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include "userio.h"
#include "indiuserio.h"

Go to the source code of this file.

Classes

struct  ROSC
 

Macros

#define MAXRBUF   2048
 

Enumerations

enum  {
  INDI_NUMBER, INDI_SWITCH, INDI_TEXT, INDI_LIGHT,
  INDI_BLOB, INDI_UNKNOWN
}
 

Functions

void IDDeleteVA (const char *dev, const char *name, const char *fmt, va_list ap)
 
void IDDelete (const char *dev, const char *name, const char *fmt,...)
 
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 ISSnoopDevice. More...
 
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. More...
 
int IUUpdateSwitch (ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
 Update all switches in a switch vector property. More...
 
int IUUpdateNumber (INumberVectorProperty *nvp, double values[], char *names[], int n)
 Update all numbers in a number vector property. More...
 
int IUUpdateText (ITextVectorProperty *tvp, char *texts[], char *names[], int n)
 Update all text members in a text vector property. More...
 
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. More...
 
int IUSaveBLOB (IBLOB *bp, int size, int blobsize, char *blob, char *format)
 Function to save blob metadata in the corresponding blob. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int IUSnoopNumber (XMLEle *root, INumberVectorProperty *nvp)
 Update a snooped number vector property from the given XML root element. More...
 
int IUSnoopText (XMLEle *root, ITextVectorProperty *tvp)
 Update a snooped text vector property from the given XML root element. More...
 
int IUSnoopLight (XMLEle *root, ILightVectorProperty *lvp)
 Update a snooped light vector property from the given XML root element. More...
 
int IUSnoopSwitch (XMLEle *root, ISwitchVectorProperty *svp)
 Update a snooped switch vector property from the given XML root element. More...
 
int IUSnoopBLOB (XMLEle *root, IBLOBVectorProperty *bvp)
 Update a snooped BLOB vector property from the given XML root element. More...
 
int dispatch (XMLEle *root, char msg[])
 
int IUReadConfig (const char *filename, const char *dev, const char *property, int silent, char errmsg[])
 Loads and processes a configuration file. More...
 
int IUSaveDefaultConfig (const char *source_config, const char *dest_config, const char *dev)
 Copies an existing configuration file into a default configuration file. More...
 
int IUGetConfigOnSwitch (const ISwitchVectorProperty *property, int *index)
 IUGetConfigOnSwitch Opens configuration file and reads a single switch vector property to find the index of the first ON switch element. More...
 
int IUGetConfigSwitch (const char *dev, const char *property, const char *member, ISState *value)
 IUGetConfigSwitch Opens configuration file and reads single switch property. More...
 
int IUGetConfigOnSwitchIndex (const char *dev, const char *property, int *index)
 IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch index, if any. More...
 
int IUGetConfigOnSwitchLabel (const char *dev, const char *property, char *label, size_t size)
 IUGetConfigOnSwitchLabel Opens configuration file and reads single switch property to find ON switch index, if any. More...
 
int IUGetConfigNumber (const char *dev, const char *property, const char *member, double *value)
 IUGetConfigNumber Opens configuration file and reads single number property. More...
 
int IUGetConfigText (const char *dev, const char *property, const char *member, char *value, int len)
 IUGetConfigText Opens configuration file and reads single text property. More...
 
void IDMessageVA (const char *dev, const char *fmt, va_list ap)
 
void IDMessage (const char *dev, const char *fmt,...)
 
int IUPurgeConfig (const char *filename, const char *dev, char errmsg[])
 
FILE * IUGetConfigFP (const char *filename, const char *dev, const char *mode, char errmsg[])
 Open a configuration file for writing and return a configuration file FILE pointer. More...
 
void IUSaveConfigTag (FILE *fp, int ctag, const char *dev, int silent)
 Add opening or closing tag to a configuration file. More...
 
void IDDefTextVA (const ITextVectorProperty *tvp, const char *fmt, va_list ap)
 
void IDDefText (const ITextVectorProperty *tvp, const char *fmt,...)
 
void IDDefNumberVA (const INumberVectorProperty *nvp, const char *fmt, va_list ap)
 
void IDDefNumber (const INumberVectorProperty *nvp, const char *fmt,...)
 
void IDDefSwitchVA (const ISwitchVectorProperty *svp, const char *fmt, va_list ap)
 
void IDDefSwitch (const ISwitchVectorProperty *svp, const char *fmt,...)
 
void IDDefLightVA (const ILightVectorProperty *lvp, const char *fmt, va_list ap)
 
void IDDefLight (const ILightVectorProperty *lvp, const char *fmt,...)
 
void IDDefBLOBVA (const IBLOBVectorProperty *bvp, const char *fmt, va_list ap)
 
void IDDefBLOB (const IBLOBVectorProperty *bvp, const char *fmt,...)
 
void IDSetTextVA (const ITextVectorProperty *tvp, const char *fmt, va_list ap)
 
void IDSetText (const ITextVectorProperty *tvp, const char *fmt,...)
 
void IDSetNumberVA (const INumberVectorProperty *nvp, const char *fmt, va_list ap)
 
void IDSetNumber (const INumberVectorProperty *nvp, const char *fmt,...)
 
void IDSetSwitchVA (const ISwitchVectorProperty *svp, const char *fmt, va_list ap)
 
void IDSetSwitch (const ISwitchVectorProperty *svp, const char *fmt,...)
 
void IDSetLightVA (const ILightVectorProperty *lvp, const char *fmt, va_list ap)
 
void IDSetLight (const ILightVectorProperty *lvp, const char *fmt,...)
 
void IDSetBLOBVA (const IBLOBVectorProperty *bvp, const char *fmt, va_list ap)
 
void IDSetBLOB (const IBLOBVectorProperty *bvp, const char *fmt,...)
 
void IUUpdateMinMax (const INumberVectorProperty *nvp)
 Function to update the min and max elements of a number in the client. More...
 
int IUFindIndex (const char *needle, char **hay, unsigned int n)
 Returns the index of the string in a string array. More...
 

Variables

int verbose
 
char * me = ""
 

Macro Definition Documentation

◆ MAXRBUF

#define MAXRBUF   2048

Definition at line 52 of file indidriver.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

INDI property type

Enumerator
INDI_NUMBER 
INDI_SWITCH 
INDI_TEXT 
INDI_LIGHT 
INDI_BLOB 
INDI_UNKNOWN 

Definition at line 55 of file indidriver.c.

Function Documentation

◆ dispatch()

int dispatch ( XMLEle root,
char  msg[] 
)

Definition at line 747 of file indidriver.c.

◆ IDDefBLOB()

void IDDefBLOB ( const IBLOBVectorProperty bvp,
const char *  fmt,
  ... 
)

Definition at line 1735 of file indidriver.c.

◆ IDDefBLOBVA()

void IDDefBLOBVA ( const IBLOBVectorProperty bvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1720 of file indidriver.c.

◆ IDDefLight()

void IDDefLight ( const ILightVectorProperty lvp,
const char *  fmt,
  ... 
)

Definition at line 1711 of file indidriver.c.

◆ IDDefLightVA()

void IDDefLightVA ( const ILightVectorProperty lvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1699 of file indidriver.c.

◆ IDDefNumber()

void IDDefNumber ( const INumberVectorProperty nvp,
const char *  fmt,
  ... 
)

Definition at line 1666 of file indidriver.c.

◆ IDDefNumberVA()

void IDDefNumberVA ( const INumberVectorProperty nvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1651 of file indidriver.c.

◆ IDDefSwitch()

void IDDefSwitch ( const ISwitchVectorProperty svp,
const char *  fmt,
  ... 
)

Definition at line 1690 of file indidriver.c.

◆ IDDefSwitchVA()

void IDDefSwitchVA ( const ISwitchVectorProperty svp,
const char *  fmt,
va_list  ap 
)

Definition at line 1675 of file indidriver.c.

◆ IDDefText()

void IDDefText ( const ITextVectorProperty tvp,
const char *  fmt,
  ... 
)

Definition at line 1642 of file indidriver.c.

◆ IDDefTextVA()

void IDDefTextVA ( const ITextVectorProperty tvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1627 of file indidriver.c.

◆ IDDelete()

void IDDelete ( const char *  dev,
const char *  name,
const char *  fmt,
  ... 
)

Definition at line 126 of file indidriver.c.

◆ IDDeleteVA()

void IDDeleteVA ( const char *  dev,
const char *  name,
const char *  fmt,
va_list  ap 
)

Definition at line 113 of file indidriver.c.

◆ IDMessage()

void IDMessage ( const char *  dev,
const char *  fmt,
  ... 
)

Definition at line 1521 of file indidriver.c.

◆ IDMessageVA()

void IDMessageVA ( const char *  dev,
const char *  fmt,
va_list  ap 
)

Definition at line 1506 of file indidriver.c.

◆ IDSetBLOB()

void IDSetBLOB ( const IBLOBVectorProperty bvp,
const char *  fmt,
  ... 
)

Definition at line 1840 of file indidriver.c.

◆ IDSetBLOBVA()

void IDSetBLOBVA ( const IBLOBVectorProperty bvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1828 of file indidriver.c.

◆ IDSetLight()

void IDSetLight ( const ILightVectorProperty lvp,
const char *  fmt,
  ... 
)

Definition at line 1819 of file indidriver.c.

◆ IDSetLightVA()

void IDSetLightVA ( const ILightVectorProperty lvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1807 of file indidriver.c.

◆ IDSetNumber()

void IDSetNumber ( const INumberVectorProperty nvp,
const char *  fmt,
  ... 
)

Definition at line 1777 of file indidriver.c.

◆ IDSetNumberVA()

void IDSetNumberVA ( const INumberVectorProperty nvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1765 of file indidriver.c.

◆ IDSetSwitch()

void IDSetSwitch ( const ISwitchVectorProperty svp,
const char *  fmt,
  ... 
)

Definition at line 1798 of file indidriver.c.

◆ IDSetSwitchVA()

void IDSetSwitchVA ( const ISwitchVectorProperty svp,
const char *  fmt,
va_list  ap 
)

Definition at line 1786 of file indidriver.c.

◆ IDSetText()

void IDSetText ( const ITextVectorProperty tvp,
const char *  fmt,
  ... 
)

Definition at line 1756 of file indidriver.c.

◆ IDSetTextVA()

void IDSetTextVA ( const ITextVectorProperty tvp,
const char *  fmt,
va_list  ap 
)

Definition at line 1744 of file indidriver.c.

◆ IDSnoopBLOBs()

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.

Parameters
snooped_devicename of the device to snoop.
snooped_propertyname of property to snoop. If NULL, then all BLOBs from the given device are snooped.
bhHow drivers handle BLOBs incoming from snooping drivers.

Definition at line 157 of file indidriver.c.

◆ IDSnoopDevice()

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 ISSnoopDevice.

Parameters
snooped_devicename of the device to snoop.
snooped_propertyname of the snooped property in the device.

Definition at line 137 of file indidriver.c.

◆ IUFillBLOB()

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.

Parameters
bppointer a BLOB property to fill
namethe BLOB name
labelthe BLOB label
formatthe BLOB format.

Definition at line 390 of file indidriver.c.

◆ IUFillBLOBVector()

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.

Parameters
bvppointer a BLOB vector property to fill
bppointer to an array of BLOBs
nbpthe dimension of bp
devthe device name this vector property belongs to
namethe vector property name
labelthe vector property label
groupthe vector property group
pthe vector property permission
timeoutvector property timeout in seconds
sthe vector property initial state.

Definition at line 499 of file indidriver.c.

◆ IUFillLight()

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.

Parameters
lppointer a light property to fill
namethe light name
labelthe light label
sthe light state (IDLE, WARNING, OK, ALERT)

Definition at line 334 of file indidriver.c.

◆ IUFillLightVector()

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.

Parameters
lvppointer a light vector property to fill
lppointer to an array of lights
nlpthe dimension of lp
devthe device name this vector property belongs to
namethe vector property name
labelthe vector property label
groupthe vector property group
sthe vector property initial state.

Definition at line 435 of file indidriver.c.

◆ IUFillNumber()

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.

Parameters
nppointer a number property to fill
namethe number name
labelthe number label
formatthe number format in printf style (e.g. "%02d")
minthe minimum possible value
maxthe maximum possible value
stepthe step used to climb from minimum value to maximum value
valuethe number's current value

Definition at line 348 of file indidriver.c.

◆ IUFillNumberVector()

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.

Parameters
nvppointer a number vector property to fill
nppointer to an array of numbers
nnpthe dimension of np
devthe device name this vector property belongs to
namethe vector property name
labelthe vector property label
groupthe vector property group
pthe vector property permission
timeoutvector property timeout in seconds
sthe vector property initial state.

Definition at line 455 of file indidriver.c.

◆ IUFillSwitch()

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.

Parameters
sppointer a switch property to fill
namethe switch name
labelthe switch label
sthe switch state (ISS_ON or ISS_OFF)

Definition at line 320 of file indidriver.c.

◆ IUFillSwitchVector()

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.

Parameters
svppointer a switch vector property to fill
sppointer to an array of switches
nspthe dimension of sp
devthe device name this vector property belongs to
namethe vector property name
labelthe vector property label
groupthe vector property group
pthe vector property permission
rthe switches behavior
timeoutvector property timeout in seconds
sthe vector property initial state.

Definition at line 412 of file indidriver.c.

◆ IUFillText()

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.

Parameters
tppointer a text property to fill
namethe text name
labelthe text label
initialTextthe initial text

Definition at line 369 of file indidriver.c.

◆ IUFillTextVector()

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.

Parameters
tvppointer a text vector property to fill
tppointer to an array of texts
ntpthe dimension of tp
devthe device name this vector property belongs to
namethe vector property name
labelthe vector property label
groupthe vector property group
pthe vector property permission
timeoutvector property timeout in seconds
sthe vector property initial state.

Definition at line 477 of file indidriver.c.

◆ IUFindIndex()

int IUFindIndex ( const char *  needle,
char **  hay,
unsigned int  n 
)

Returns the index of the string in a string array.

Parameters
needlethe string to match against each element in the hay
haya pointer to a string array to search in
nthe size of hay
Returns
index of needle if found in the hay. Otherwise -1 if not found.

Definition at line 1860 of file indidriver.c.

◆ IUGetConfigFP()

FILE* IUGetConfigFP ( const char *  filename,
const char *  dev,
const char *  mode,
char  errmsg[] 
)

Open a configuration file for writing and return a configuration file FILE pointer.

Parameters
filenamefull path of the configuration file. If set, the function will attempt to open it for writing. If set to NULL, it will attempt to generate the filename as described in the Detailed Description introduction and then open it for writing.
devdevice name. This is used if the filename parameter is NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction.
modemode to open the file with (e.g. "w" or "r")
errmsgIn case of errors, store the error message in this buffer. The size of the buffer must be at least MAXRBUF.
Returns
pointer to FILE if configuration file is opened successful, otherwise NULL and errmsg is set.

Definition at line 1555 of file indidriver.c.

◆ IUGetConfigNumber()

int IUGetConfigNumber ( const char *  dev,
const char *  property,
const char *  member,
double *  value 
)

IUGetConfigNumber Opens configuration file and reads single number property.

Parameters
devname of device
propertyname of vector property
membername of member property
valuepointer to save value of property if found.
Returns
0 on success, -1 if not found.

Definition at line 1389 of file indidriver.c.

◆ IUGetConfigOnSwitch()

int IUGetConfigOnSwitch ( const ISwitchVectorProperty property,
int *  index 
)

IUGetConfigOnSwitch Opens configuration file and reads a single switch vector property to find the index of the first ON switch element.

Parameters
propertypointer to initialized switch vector property.
indexindex of first ON switch property. If none is found, it is set to -1
Returns
0 on success, -1 if not found.

Definition at line 1151 of file indidriver.c.

◆ IUGetConfigOnSwitchIndex()

int IUGetConfigOnSwitchIndex ( const char *  dev,
const char *  property,
int *  index 
)

IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch index, if any.

Parameters
devname of device
propertyname of vector property
indexpointer to save value of ON switch index, if found.
Returns
0 on success, -1 if not found.

Definition at line 1270 of file indidriver.c.

◆ IUGetConfigOnSwitchLabel()

int IUGetConfigOnSwitchLabel ( const char *  dev,
const char *  property,
char *  label,
size_t  size 
)

IUGetConfigOnSwitchLabel Opens configuration file and reads single switch property to find ON switch index, if any.

Parameters
devname of device
propertyname of vector property
labelof the ON switch index if any.
sizesize of label in bytes.
Returns
0 on success, -1 if not found.

Definition at line 1329 of file indidriver.c.

◆ IUGetConfigSwitch()

int IUGetConfigSwitch ( const char *  dev,
const char *  property,
const char *  member,
ISState value 
)

IUGetConfigSwitch Opens configuration file and reads single switch property.

Parameters
devname of device
propertyname of vector property
membername of member property
valuepointer to save value of property if found.
Returns
0 on success, -1 if not found.

Definition at line 1212 of file indidriver.c.

◆ IUGetConfigText()

int IUGetConfigText ( const char *  dev,
const char *  property,
const char *  member,
char *  value,
int  len 
)

IUGetConfigText Opens configuration file and reads single text property.

Parameters
devname of device
propertyname of vector property
membername of member property
valuepointer to save value of property if found.
lensize of char buffer (value)
Returns
0 on success, -1 if not found.

Definition at line 1447 of file indidriver.c.

◆ IUPurgeConfig()

int IUPurgeConfig ( const char *  filename,
const char *  dev,
char  errmsg[] 
)
Parameters
filenamefull path of the configuration file. If set, it will be deleted from disk. If set to NULL, it will attempt to generate the filename as described in the Detailed Description introduction and then delete it.
devdevice name. This is used if the filename parameter is NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction.
errmsgIn case of errors, store the error message in this buffer. The size of the buffer must be at least MAXRBUF.
Returns
0 on success, -1 on failure.

Definition at line 1529 of file indidriver.c.

◆ IUReadConfig()

int IUReadConfig ( const char *  filename,
const char *  dev,
const char *  property,
int  silent,
char  errmsg[] 
)

Loads and processes a configuration file.

Once a configuration file is successful loaded, the function will iterate over the enclosed newXXX commands, and dispatches each command to the driver. Subsequently, the driver receives the updated property value in the driver's ISNewXXX functions. The driver may call this function at any time. However, it is usually called either on driver startup or on device power up. By default, all the properties are read from the configuration file. To load a specific property, pass the property name, otherwise pass NULL to retrieve all properties.

Parameters
filenamefull path of the configuration file. If set, the function will attempt to load the file. If set to NULL, it will attempt to generate the filename as described in the Detailed Description introduction and then load it.
devdevice name. This is used if the filename parameter is NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction.
propertyProperty name to load configuration for. If NULL, all properties within the configuration file will be processed.
silentIf silent is 1, it will suppress any output messages to the driver.
errmsgIn case of errors, store the error message in this buffer. The size of the buffer must be at least MAXRBUF.
Returns
0 on successful, -1 if there is an error and errmsg is set.

Definition at line 1044 of file indidriver.c.

◆ IUSaveBLOB()

int IUSaveBLOB ( IBLOB bp,
int  size,
int  blobsize,
char *  blob,
char *  format 
)

Function to save blob metadata in the corresponding blob.

Parameters
bppointer to an IBLOB member.
sizesize of the blob buffer encoded in base64
blobsizeactual size of the buffer after base64 decoding. This is the actual byte count used in drivers.
blobpointer to the blob buffer
formatformat of the blob buffer
Note
Do not call this function directly, it is called internally by IUUpdateBLOB.

Definition at line 311 of file indidriver.c.

◆ IUSaveConfigTag()

void IUSaveConfigTag ( FILE *  fp,
int  ctag,
const char *  dev,
int  silent 
)

Add opening or closing tag to a configuration file.

A configuration file root XML element is <INDIDriver>. This functions add <INDIDriver> or </INDIDriver> as required.

Parameters
fpfile pointer to a configuration file.
ctagIf 0, <INDIDriver> is appened to the configuration file, otherwise </INDIDriver> is appeneded and the fp is closed.
devdevice name. Used only for sending notification to the driver if silent is set to 1.
silentIf silent is 1, it will suppress any output messages to the driver.

Definition at line 1604 of file indidriver.c.

◆ IUSaveDefaultConfig()

int IUSaveDefaultConfig ( const char *  source_config,
const char *  dest_config,
const char *  dev 
)

Copies an existing configuration file into a default configuration file.

If no default configuration file for the supplied dev exists, it gets created and its contentes copied from an exiting source configuration file. Usually, when the user saves the configuration file of a driver for the first time, IUSaveDefaultConfig is called to create the default configuration file. If the default configuration file already exists, the function performs no action and returns.

Parameters
source_configfull path of the source configuration file to read. If set, the function will attempt to load the file. If set to NULL, it will attempt to generate the filename as described in the Detailed Description introduction and then load it.
dest_configfull path of the destination default configuration file to write. If set, the function will attempt to load the file. If set to NULL, it will attempt to generate the filename as described in the Detailed Description introduction and then load it. If the file already exists, the function returns. If the file doesn't exist, it gets created and its contents copied from the source_config file.
devdevice name. This is used if either the source_config or desg_config are NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction.
Returns
0 is successful, -1 othereise.

Definition at line 1101 of file indidriver.c.

◆ IUSnoopBLOB()

int IUSnoopBLOB ( XMLEle root,
IBLOBVectorProperty bvp 
)

Update a snooped BLOB vector property from the given XML root element.

Parameters
rootXML root elememnt containing the snopped property content
bvpa pointer to the BLOB vector property to be updated.
Returns
0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.

Definition at line 696 of file indidriver.c.

◆ IUSnoopLight()

int IUSnoopLight ( XMLEle root,
ILightVectorProperty lvp 
)

Update a snooped light vector property from the given XML root element.

Parameters
rootXML root elememnt containing the snopped property content
lvpa pointer to the light vector property to be updated.
Returns
0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.

Definition at line 612 of file indidriver.c.

◆ IUSnoopNumber()

int IUSnoopNumber ( XMLEle root,
INumberVectorProperty nvp 
)

Update a snooped number vector property from the given XML root element.

Parameters
rootXML root elememnt containing the snopped property content
nvpa pointer to the number vector property to be updated.
Returns
0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.

Definition at line 531 of file indidriver.c.

◆ IUSnoopSwitch()

int IUSnoopSwitch ( XMLEle root,
ISwitchVectorProperty svp 
)

Update a snooped switch vector property from the given XML root element.

Parameters
rootXML root elememnt containing the snopped property content
svpa pointer to the switch vector property to be updated.
Returns
0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.

Definition at line 654 of file indidriver.c.

◆ IUSnoopText()

int IUSnoopText ( XMLEle root,
ITextVectorProperty tvp 
)

Update a snooped text vector property from the given XML root element.

Parameters
rootXML root elememnt containing the snopped property content
tvpa pointer to the text vector property to be updated.
Returns
0 if cracking the XML element and updating the property proceeded without errors, -1 if trouble.

Definition at line 576 of file indidriver.c.

◆ IUUpdateBLOB()

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.

Parameters
bvpa pointer to a BLOB vector property.
sizessizes of the blobs.
blobsizessize of the blobs, raw without compression.
blobsa pointer to the BLOB members
namesthe names of the IBLOB members to update.
formatsThe blob format or extension.
nthe number of IBLOB members to update.
Returns
0 if update successful, -1 otherwise. Update will fail in case of property name mismatch.

Definition at line 285 of file indidriver.c.

◆ IUUpdateMinMax()

void IUUpdateMinMax ( const INumberVectorProperty nvp)

Function to update the min and max elements of a number in the client.

Parameters
nvppointer to an INumberVectorProperty.
Warning
This call is not INDI protocol compliant. It sends setNumberVector along with updated Min/Max/Step values so that the client updates the range accordingly for this property. In the INDI-compliant paradigm, it is NOT possible to update min/max/step step of an existing number property and the only way is to do so is to delete and redefine the number property again. However, due to the many problems with approach in device drivers, INDI Library defines this function to simplify the update process without requiring a complete delete/define cycle.

Definition at line 1849 of file indidriver.c.

◆ IUUpdateNumber()

int IUUpdateNumber ( INumberVectorProperty nvp,
double  values[],
char *  names[],
int  n 
)

Update all numbers in a number vector property.

Parameters
nvpa pointer to a number vector property.
valuesthe states of the new INumber members.
namesthe names of the INumber members to update.
nthe number of INumber members to update.
Returns
0 if update successful, -1 otherwise. Update will fail if values are out of scope, or in case of property name mismatch.

Definition at line 225 of file indidriver.c.

◆ IUUpdateSwitch()

int IUUpdateSwitch ( ISwitchVectorProperty svp,
ISState states,
char *  names[],
int  n 
)

Update all switches in a switch vector property.

Parameters
svpa pointer to a switch vector property.
statesthe states of the new ISwitch members.
namesthe names of the ISwtich members to update.
nthe number of ISwitch members to update.
Returns
0 if update successful, -1 otherwise.

Definition at line 171 of file indidriver.c.

◆ IUUpdateText()

int IUUpdateText ( ITextVectorProperty tvp,
char *  texts[],
char *  names[],
int  n 
)

Update all text members in a text vector property.

Parameters
tvpa pointer to a text vector property.
textsa pointer to the text members
namesthe names of the IText members to update.
nthe number of IText members to update.
Returns
0 if update successful, -1 otherwise. Update will fail in case of property name mismatch.

Definition at line 259 of file indidriver.c.

Variable Documentation

◆ me

char* me = ""

Definition at line 50 of file indidriver.c.

◆ verbose

int verbose

Definition at line 49 of file indidriver.c.