Instrument Neutral Distributed Interface INDI
2.0.2
|
#include "indidevapi.h"
#include "indicom.h"
#include "locale_compat.h"
#include "base64.h"
#include "userio.h"
#include "indiuserio.h"
#include "indiutility.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
Go to the source code of this file.
Functions | |
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... | |
void | IUSaveText (IText *tp, const char *newtext) |
Function to reliably save new text in a IText. More... | |
int | IUSaveBLOB (IBLOB *bp, int size, int blobsize, char *blob, char *format) |
Function to save blob metadata in the corresponding blob. More... | |
IText * | IUFindText (const ITextVectorProperty *tvp, const char *name) |
Find an IText member in a vector text property. More... | |
INumber * | IUFindNumber (const INumberVectorProperty *nvp, const char *name) |
Find an INumber member in a number text property. More... | |
ISwitch * | IUFindSwitch (const ISwitchVectorProperty *svp, const char *name) |
Find an ISwitch member in a vector switch property. More... | |
ILight * | IUFindLight (const ILightVectorProperty *lvp, const char *name) |
Find an ILight member in a vector Light property. More... | |
IBLOB * | IUFindBLOB (const IBLOBVectorProperty *bvp, const char *name) |
Find an IBLOB member in a vector BLOB property. More... | |
ISwitch * | IUFindOnSwitch (const ISwitchVectorProperty *svp) |
Returns the first ON switch it finds in the vector switch property. More... | |
int | IUFindIndex (const char *needle, char **hay, unsigned int n) |
Returns the index of the string in a string array. More... | |
int | IUFindOnSwitchIndex (const ISwitchVectorProperty *svp) |
Returns the index of first ON switch it finds in the vector switch property. More... | |
const char * | IUFindOnSwitchName (ISState *states, char *names[], int n) |
Returns the name of the first ON switch it finds in the supplied arguments. More... | |
void | IUResetSwitch (ISwitchVectorProperty *svp) |
Reset all switches in a switch vector property to OFF. 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 | crackDN (XMLEle *root, char **dev, char **name, char msg[]) |
Extract dev and name attributes from an XML element. More... | |
int | crackIPState (const char *str, IPState *ip) |
Extract property state (Idle, OK, Busy, Alert) from the supplied string. More... | |
int | crackISState (const char *str, ISState *ip) |
Extract switch state (On or Off) from the supplied string. More... | |
int | crackIPerm (const char *str, IPerm *ip) |
Extract property permission state (RW, RO, WO) from the supplied string. More... | |
int | crackISRule (const char *str, ISRule *ip) |
Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string. More... | |
const char * | pstateStr (IPState s) |
const char * | sstateStr (ISState s) |
const char * | ruleStr (ISRule r) |
const char * | permStr (IPerm p) |
void | xmlv1 () |
print the boilerplate comment introducing xml More... | |
int crackDN | ( | XMLEle * | root, |
char ** | dev, | ||
char ** | name, | ||
char | msg[] | ||
) |
Extract dev and name attributes from an XML element.
Definition at line 553 of file indidevapi.c.
int crackIPerm | ( | const char * | str, |
IPerm * | ip | ||
) |
Extract property permission state (RW, RO, WO) from the supplied string.
str | A string representation of the permission state. |
ip | Pointer to IPerm structure to store the extracted permission state. |
Definition at line 602 of file indidevapi.c.
int crackIPState | ( | const char * | str, |
IPState * | ip | ||
) |
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
str | A string representation of the state. |
ip | Pointer to IPState structure to store the extracted property state. |
Definition at line 576 of file indidevapi.c.
int crackISRule | ( | const char * | str, |
ISRule * | ip | ||
) |
Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
str | A string representation of the switch rule. |
ip | Pointer to ISRule structure to store the extracted switch rule. |
Definition at line 615 of file indidevapi.c.
int crackISState | ( | const char * | str, |
ISState * | ip | ||
) |
Extract switch state (On or Off) from the supplied string.
str | A string representation of the switch state. |
ip | Pointer to ISState structure to store the extracted switch state. |
Definition at line 591 of file indidevapi.c.
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.
bp | pointer a BLOB property to fill |
name | the BLOB name |
label | the BLOB label |
format | the BLOB format. |
Definition at line 216 of file indidevapi.c.
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.
bvp | pointer a BLOB vector property to fill |
bp | pointer to an array of BLOBs |
nbp | the dimension of bp |
dev | the device name this vector property belongs to |
name | the vector property name |
label | the vector property label |
group | the vector property group |
p | the vector property permission |
timeout | vector property timeout in seconds |
s | the vector property initial state. |
Definition at line 310 of file indidevapi.c.
Assign attributes for a light property. The light's auxiliary elements will be set to NULL.
lp | pointer a light property to fill |
name | the light name |
label | the light label |
s | the light state (IDLE, WARNING, OK, ALERT) |
Definition at line 169 of file indidevapi.c.
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.
lvp | pointer a light vector property to fill |
lp | pointer to an array of lights |
nlp | the dimension of lp |
dev | the device name this vector property belongs to |
name | the vector property name |
label | the vector property label |
group | the vector property group |
s | the vector property initial state. |
Definition at line 255 of file indidevapi.c.
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.
np | pointer a number property to fill |
name | the number name |
label | the number label |
format | the number format in printf style (e.g. "%02d") |
min | the minimum possible value |
max | the maximum possible value |
step | the step used to climb from minimum value to maximum value |
value | the number's current value |
Definition at line 180 of file indidevapi.c.
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.
nvp | pointer a number vector property to fill |
np | pointer to an array of numbers |
nnp | the dimension of np |
dev | the device name this vector property belongs to |
name | the vector property name |
label | the vector property label |
group | the vector property group |
p | the vector property permission |
timeout | vector property timeout in seconds |
s | the vector property initial state. |
Definition at line 272 of file indidevapi.c.
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
Definition at line 158 of file indidevapi.c.
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.
svp | pointer a switch vector property to fill |
sp | pointer to an array of switches |
nsp | the dimension of sp |
dev | the device name this vector property belongs to |
name | the vector property name |
label | the vector property label |
group | the vector property group |
p | the vector property permission |
r | the switches behavior |
timeout | vector property timeout in seconds |
s | the vector property initial state. |
Definition at line 235 of file indidevapi.c.
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.
tp | pointer a text property to fill |
name | the text name |
label | the text label |
initialText | the initial text |
Definition at line 198 of file indidevapi.c.
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.
tvp | pointer a text vector property to fill |
tp | pointer to an array of texts |
ntp | the dimension of tp |
dev | the device name this vector property belongs to |
name | the vector property name |
label | the vector property label |
group | the vector property group |
p | the vector property permission |
timeout | vector property timeout in seconds |
s | the vector property initial state. |
Definition at line 291 of file indidevapi.c.
IBLOB* IUFindBLOB | ( | const IBLOBVectorProperty * | bvp, |
const char * | name | ||
) |
Find an IBLOB member in a vector BLOB property.
bvp | a pointer to a BLOB vector property. |
name | the name of the member to search for. |
Definition at line 96 of file indidevapi.c.
int IUFindIndex | ( | const char * | needle, |
char ** | hay, | ||
unsigned int | n | ||
) |
Returns the index of the string in a string array.
needle | the string to match against each element in the hay |
hay | a pointer to a string array to search in |
n | the size of hay |
Definition at line 117 of file indidevapi.c.
ILight* IUFindLight | ( | const ILightVectorProperty * | lvp, |
const char * | name | ||
) |
Find an ILight member in a vector Light property.
lvp | a pointer to a Light vector property. |
name | the name of the member to search for. |
Definition at line 86 of file indidevapi.c.
INumber* IUFindNumber | ( | const INumberVectorProperty * | nvp, |
const char * | name | ||
) |
Find an INumber member in a number text property.
nvp | a pointer to a number vector property. |
name | the name of the member to search for. |
Definition at line 66 of file indidevapi.c.
ISwitch* IUFindOnSwitch | ( | const ISwitchVectorProperty * | sp | ) |
Returns the first ON switch it finds in the vector switch property.
sp | a pointer to a switch vector property. |
Definition at line 108 of file indidevapi.c.
int IUFindOnSwitchIndex | ( | const ISwitchVectorProperty * | sp | ) |
Returns the index of first ON switch it finds in the vector switch property.
sp | a pointer to a switch vector property. |
Definition at line 128 of file indidevapi.c.
const char* IUFindOnSwitchName | ( | ISState * | states, |
char * | names[], | ||
int | n | ||
) |
Returns the name of the first ON switch it finds in the supplied arguments.
states | list of switch states passed by ISNewSwitch() |
names | list of switch names passed by ISNewSwitch() |
n | number of switches passed by ISNewSwitch() |
Definition at line 137 of file indidevapi.c.
ISwitch* IUFindSwitch | ( | const ISwitchVectorProperty * | svp, |
const char * | name | ||
) |
Find an ISwitch member in a vector switch property.
svp | a pointer to a switch vector property. |
name | the name of the member to search for. |
Definition at line 76 of file indidevapi.c.
IText* IUFindText | ( | const ITextVectorProperty * | tvp, |
const char * | name | ||
) |
void IUResetSwitch | ( | ISwitchVectorProperty * | svp | ) |
Reset all switches in a switch vector property to OFF.
Definition at line 148 of file indidevapi.c.
int IUSaveBLOB | ( | IBLOB * | bp, |
int | size, | ||
int | blobsize, | ||
char * | blob, | ||
char * | format | ||
) |
Function to save blob metadata in the corresponding blob.
bp | pointer to an IBLOB member. |
size | size of the blob buffer encoded in base64 |
blobsize | actual size of the buffer after base64 decoding. This is the actual byte count used in drivers. |
blob | pointer to the blob buffer |
format | format of the blob buffer |
Definition at line 44 of file indidevapi.c.
void IUSaveConfigBLOB | ( | FILE * | fp, |
const IBLOBVectorProperty * | bvp | ||
) |
Add a BLOB vector property value to the configuration file.
fp | file pointer to a configuration file. |
bvp | pointer to a BLOB vector property. |
Definition at line 30 of file indidevapi.c.
void IUSaveConfigNumber | ( | FILE * | fp, |
const INumberVectorProperty * | nvp | ||
) |
Add a number vector property value to the configuration file.
Definition at line 15 of file indidevapi.c.
void IUSaveConfigSwitch | ( | FILE * | fp, |
const ISwitchVectorProperty * | svp | ||
) |
Add a switch vector property value to the configuration file.
fp | file pointer to a configuration file. |
svp | pointer to a switch vector property. |
Definition at line 25 of file indidevapi.c.
void IUSaveConfigText | ( | FILE * | fp, |
const ITextVectorProperty * | tvp | ||
) |
Add a text vector property value to the configuration file.
fp | file pointer to a configuration file. |
tvp | pointer to a text vector property. |
Definition at line 20 of file indidevapi.c.
void IUSaveText | ( | IText * | tp, |
const char * | newtext | ||
) |
Function to reliably save new text in a IText.
tp | pointer to an IText member. |
newtext | the new text to be saved |
Definition at line 36 of file indidevapi.c.
int IUSnoopBLOB | ( | XMLEle * | root, |
IBLOBVectorProperty * | bvp | ||
) |
Update a snooped BLOB vector property from the given XML root element.
root | XML root elememnt containing the snopped property content |
bvp | a pointer to the BLOB vector property to be updated. |
Definition at line 502 of file indidevapi.c.
int IUSnoopLight | ( | XMLEle * | root, |
ILightVectorProperty * | lvp | ||
) |
Update a snooped light vector property from the given XML root element.
root | XML root elememnt containing the snopped property content |
lvp | a pointer to the light vector property to be updated. |
Definition at line 418 of file indidevapi.c.
int IUSnoopNumber | ( | XMLEle * | root, |
INumberVectorProperty * | nvp | ||
) |
Update a snooped number vector property from the given XML root element.
Definition at line 337 of file indidevapi.c.
int IUSnoopSwitch | ( | XMLEle * | root, |
ISwitchVectorProperty * | svp | ||
) |
Update a snooped switch vector property from the given XML root element.
root | XML root elememnt containing the snopped property content |
svp | a pointer to the switch vector property to be updated. |
Definition at line 460 of file indidevapi.c.
int IUSnoopText | ( | XMLEle * | root, |
ITextVectorProperty * | tvp | ||
) |
Update a snooped text vector property from the given XML root element.
root | XML root elememnt containing the snopped property content |
tvp | a pointer to the text vector property to be updated. |
Definition at line 382 of file indidevapi.c.
const char* permStr | ( | IPerm | p | ) |
Definition at line 676 of file indidevapi.c.
const char* pstateStr | ( | IPState | s | ) |
Definition at line 628 of file indidevapi.c.
const char* ruleStr | ( | ISRule | r | ) |
Definition at line 660 of file indidevapi.c.
const char* sstateStr | ( | ISState | s | ) |
Definition at line 646 of file indidevapi.c.
void xmlv1 | ( | ) |
print the boilerplate comment introducing xml
Definition at line 692 of file indidevapi.c.