Instrument Neutral Distributed Interface INDI
2.0.2
|
#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"
#include "indidriverio.h"
Go to the source code of this file.
Classes | |
struct | ROSC |
Macros | |
#define | MAXRBUF 2048 |
#define | BLOB_PING_PATTERN "SetBLOB/%ld" |
Enumerations | |
enum | { INDI_NUMBER , INDI_SWITCH , INDI_TEXT , INDI_LIGHT , INDI_BLOB , INDI_UNKNOWN } |
Functions | |
void | waitPingReply (const char *) |
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 | 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. 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. More... | |
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. 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 | IUGetConfigOnSwitchName (const char *dev, const char *property, char *name, size_t size) |
IUGetConfigOnSwitchLabel Opens configuration file and returns the name of the ON switch property, 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. A configuration file root XML element is <INDIDriver>. This functions add <INDIDriver> or </INDIDriver> as required. 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 | 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... | |
Variables | |
int | verbose |
char * | me = "" |
#define BLOB_PING_PATTERN "SetBLOB/%ld" |
Definition at line 1260 of file indidriver.c.
#define MAXRBUF 2048 |
Definition at line 52 of file indidriver.c.
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.
int dispatch | ( | XMLEle * | root, |
char | msg[] | ||
) |
Definition at line 180 of file indidriver.c.
void IDDefBLOB | ( | const IBLOBVectorProperty * | bvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1171 of file indidriver.c.
void IDDefBLOBVA | ( | const IBLOBVectorProperty * | bvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1156 of file indidriver.c.
void IDDefLight | ( | const ILightVectorProperty * | lvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1147 of file indidriver.c.
void IDDefLightVA | ( | const ILightVectorProperty * | lvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1136 of file indidriver.c.
void IDDefNumber | ( | const INumberVectorProperty * | nvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1104 of file indidriver.c.
void IDDefNumberVA | ( | const INumberVectorProperty * | nvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1090 of file indidriver.c.
void IDDefSwitch | ( | const ISwitchVectorProperty * | svp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1127 of file indidriver.c.
void IDDefSwitchVA | ( | const ISwitchVectorProperty * | svp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1113 of file indidriver.c.
void IDDefText | ( | const ITextVectorProperty * | tvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1081 of file indidriver.c.
void IDDefTextVA | ( | const ITextVectorProperty * | tvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1066 of file indidriver.c.
void IDDelete | ( | const char * | dev, |
const char * | name, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 132 of file indidriver.c.
void IDDeleteVA | ( | const char * | dev, |
const char * | name, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 121 of file indidriver.c.
void IDMessage | ( | const char * | dev, |
const char * | fmt, | ||
... | |||
) |
Definition at line 960 of file indidriver.c.
void IDMessageVA | ( | const char * | dev, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 948 of file indidriver.c.
void IDSetBLOB | ( | const IBLOBVectorProperty * | bvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1287 of file indidriver.c.
void IDSetBLOBVA | ( | const IBLOBVectorProperty * | bvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1263 of file indidriver.c.
void IDSetLight | ( | const ILightVectorProperty * | lvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1251 of file indidriver.c.
void IDSetLightVA | ( | const ILightVectorProperty * | lvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1240 of file indidriver.c.
void IDSetNumber | ( | const INumberVectorProperty * | nvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1211 of file indidriver.c.
void IDSetNumberVA | ( | const INumberVectorProperty * | nvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1200 of file indidriver.c.
void IDSetSwitch | ( | const ISwitchVectorProperty * | svp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1231 of file indidriver.c.
void IDSetSwitchVA | ( | const ISwitchVectorProperty * | svp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1220 of file indidriver.c.
void IDSetText | ( | const ITextVectorProperty * | tvp, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1191 of file indidriver.c.
void IDSetTextVA | ( | const ITextVectorProperty * | tvp, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 1180 of file indidriver.c.
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.
snooped_device | name of the device to snoop. |
snooped_property | name of property to snoop. If NULL, then all BLOBs from the given device are snooped. |
bh | How drivers handle BLOBs incoming from snooping drivers. |
Definition at line 161 of file indidriver.c.
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.
snooped_device | name of the device to snoop. |
snooped_property | name of the snooped property in the device. |
Definition at line 143 of file indidriver.c.
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.
filename | full 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. |
dev | device name. This is used if the filename parameter is NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction. |
mode | mode to open the file with (e.g. "w" or "r") |
errmsg | In case of errors, store the error message in this buffer. The size of the buffer must be at least MAXRBUF. |
Definition at line 994 of file indidriver.c.
int IUGetConfigNumber | ( | const char * | dev, |
const char * | property, | ||
const char * | member, | ||
double * | value | ||
) |
IUGetConfigNumber Opens configuration file and reads single number property.
dev | name of device |
property | name of vector property |
member | name of member property |
value | pointer to save value of property if found. |
Definition at line 831 of file indidriver.c.
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.
property | pointer to initialized switch vector property. |
index | index of first ON switch property. If none is found, it is set to -1 |
Definition at line 592 of file indidriver.c.
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.
dev | name of device |
property | name of vector property |
index | pointer to save value of ON switch index, if found. |
Definition at line 711 of file indidriver.c.
int IUGetConfigOnSwitchName | ( | const char * | dev, |
const char * | property, | ||
char * | name, | ||
size_t | size | ||
) |
IUGetConfigOnSwitchLabel Opens configuration file and returns the name of the ON switch property, if any.
dev | name of device |
property | name of vector property |
name | of the ON switch, if any. |
size | size of name in bytes. |
Definition at line 771 of file indidriver.c.
int IUGetConfigSwitch | ( | const char * | dev, |
const char * | property, | ||
const char * | member, | ||
ISState * | value | ||
) |
IUGetConfigSwitch Opens configuration file and reads single switch property.
dev | name of device |
property | name of vector property |
member | name of member property |
value | pointer to save value of property if found. |
Definition at line 653 of file indidriver.c.
int IUGetConfigText | ( | const char * | dev, |
const char * | property, | ||
const char * | member, | ||
char * | value, | ||
int | len | ||
) |
IUGetConfigText Opens configuration file and reads single text property.
dev | name of device |
property | name of vector property |
member | name of member property |
value | pointer to save value of property if found. |
len | size of char buffer (value) |
Definition at line 889 of file indidriver.c.
int IUPurgeConfig | ( | const char * | filename, |
const char * | dev, | ||
char | errmsg[] | ||
) |
filename | full 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. |
dev | device name. This is used if the filename parameter is NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction. |
errmsg | In case of errors, store the error message in this buffer. The size of the buffer must be at least MAXRBUF. |
Definition at line 968 of file indidriver.c.
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.
filename | full 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. |
dev | device name. This is used if the filename parameter is NULL, and INDICONFIG environment variable is not set as described in the Detailed Description introduction. |
property | Property name to load configuration for. If NULL, all properties within the configuration file will be processed. |
silent | If silent is 1, it will suppress any output messages to the driver. |
errmsg | In case of errors, store the error message in this buffer. The size of the buffer must be at least MAXRBUF. |
Definition at line 485 of file indidriver.c.
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.
fp | file pointer to a configuration file. |
ctag | If 0, <INDIDriver> is appened to the configuration file, otherwise </INDIDriver> is appeneded and the fp is closed. |
dev | device name. Used only for sending notification to the driver if silent is set to 1. |
silent | If silent is 1, it will suppress any output messages to the driver. |
Definition at line 1043 of file indidriver.c.
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.
source_config | full 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_config | full 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. |
dev | device 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. |
Definition at line 542 of file indidriver.c.
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.
bvp | a pointer to a BLOB vector property. |
sizes | sizes of the blobs. |
blobsizes | size of the blobs, raw without compression. |
blobs | a pointer to the BLOB members |
names | the names of the IBLOB members to update. |
formats | The blob format or extension. |
n | the number of IBLOB members to update. |
Definition at line 1422 of file indidriver.c.
void IUUpdateMinMax | ( | const INumberVectorProperty * | nvp | ) |
Function to update the min and max elements of a number in the client.
nvp | pointer to an INumberVectorProperty. |
Definition at line 1296 of file indidriver.c.
int IUUpdateNumber | ( | INumberVectorProperty * | nvp, |
double | values[], | ||
char * | names[], | ||
int | n | ||
) |
Update all numbers in a number vector property.
nvp | a pointer to a number vector property. |
values | the states of the new INumber members. |
names | the names of the INumber members to update. |
n | the number of INumber members to update. |
Definition at line 1362 of file indidriver.c.
int IUUpdateSwitch | ( | ISwitchVectorProperty * | svp, |
ISState * | states, | ||
char * | names[], | ||
int | n | ||
) |
Update all switches in a switch vector property.
svp | a pointer to a switch vector property. |
states | the states of the new ISwitch members. |
names | the names of the ISwtich members to update. |
n | the number of ISwitch members to update. |
Definition at line 1308 of file indidriver.c.
int IUUpdateText | ( | ITextVectorProperty * | tvp, |
char * | texts[], | ||
char * | names[], | ||
int | n | ||
) |
Update all text members in a text vector property.
tvp | a pointer to a text vector property. |
texts | a pointer to the text members |
names | the names of the IText members to update. |
n | the number of IText members to update. |
Definition at line 1396 of file indidriver.c.
void waitPingReply | ( | const char * | uid | ) |
Definition at line 281 of file indidrivermain.c.
char* me = "" |
Definition at line 50 of file indidriver.c.
int verbose |
INDI Driver Functions Copyright (C) 2003 - 2015 Jasem Mutlaq Copyright (C) 2003 - 2006 Elwood C. Downey
This library is free software; you can redistribute it and / or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
Definition at line 49 of file indidriver.c.