Instrument Neutral Distributed Interface INDI  1.9.2
Functions | Variables
indidriver.h File Reference
#include "indiapi.h"
#include "lilxml.h"
#include <stdio.h>

Go to the source code of this file.

Functions

int dispatch (XMLEle *root, char msg[])
 
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...
 
int IUPurgeConfig (const char *filename, const char *dev, char errmsg[])
 
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...
 
void IUSaveConfigTag (FILE *fp, int ctag, const char *dev, int silent)
 Add opening or closing tag to a configuration file. More...
 
void IUSaveConfigNumber (FILE *fp, const INumberVectorProperty *nvp)
 Add a number vector property value to the configuration file. More...
 
void IUSaveConfigText (FILE *fp, const ITextVectorProperty *tvp)
 Add a text vector property value to the configuration file. More...
 
void IUSaveConfigSwitch (FILE *fp, const ISwitchVectorProperty *svp)
 Add a switch vector property value to the configuration file. More...
 
void IUSaveConfigBLOB (FILE *fp, const IBLOBVectorProperty *bvp)
 Add a BLOB vector property value to the configuration file. 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 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 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 IUGetConfigText (const char *dev, const char *property, const char *member, char *value, int len)
 IUGetConfigText Opens configuration file and reads single text property. More...
 

Variables

int verbose
 
char * me
 

Function Documentation

◆ dispatch()

int dispatch ( XMLEle root,
char  msg[] 
)

Definition at line 747 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.

◆ IUSaveConfigBLOB()

void IUSaveConfigBLOB ( FILE *  fp,
const IBLOBVectorProperty bvp 
)

Add a BLOB vector property value to the configuration file.

Parameters
fpfile pointer to a configuration file.
bvppointer to a BLOB vector property.
Note
If the BLOB size is large, this function will block until the BLOB contents are written to the file.

Definition at line 1449 of file indicom.c.

◆ IUSaveConfigNumber()

void IUSaveConfigNumber ( FILE *  fp,
const INumberVectorProperty nvp 
)

Add a number vector property value to the configuration file.

Parameters
fpfile pointer to a configuration file.
nvppointer to a number vector property.

Definition at line 1434 of file indicom.c.

◆ IUSaveConfigSwitch()

void IUSaveConfigSwitch ( FILE *  fp,
const ISwitchVectorProperty svp 
)

Add a switch vector property value to the configuration file.

Parameters
fpfile pointer to a configuration file.
svppointer to a switch vector property.

Definition at line 1444 of file indicom.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.

◆ IUSaveConfigText()

void IUSaveConfigText ( FILE *  fp,
const ITextVectorProperty tvp 
)

Add a text vector property value to the configuration file.

Parameters
fpfile pointer to a configuration file.
tvppointer to a text vector property.

Definition at line 1439 of file indicom.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.

Variable Documentation

◆ me

char* me

Definition at line 50 of file indidriver.c.

◆ verbose

int verbose

Definition at line 49 of file indidriver.c.