TwiceAsNice  2019-02-18
Macros | Functions | Variables
indicom.c File Reference
#include "indicom.h"
#include "indidevapi.h"
#include "locale_compat.h"
#include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <termios.h>
#include <sys/param.h>
Include dependency graph for indicom.c:

Macros

#define _GNU_SOURCE   1
 
#define PARITY_NONE   0
 
#define PARITY_EVEN   1
 
#define PARITY_ODD   2
 
#define MAXRBUF   2048
 

Functions

int fs_sexa (char *out, double a, int w, int fracbase)
 Converts a sexagesimal number to a string. More...
 
int f_scansexa (const char *str0, double *dp)
 convert sexagesimal string str AxBxC to double. More...
 
void getSexComponents (double value, int *d, int *m, int *s)
 
void getSexComponentsIID (double value, int *d, int *m, double *s)
 
int numberFormat (char *buf, const char *format, double value)
 Fill buffer with properly formatted INumber string. More...
 
void IDLog (const char *fmt,...)
 Function Drivers call to log a message locally. More...
 
const char * timestamp ()
 Create an ISO 8601 formatted time stamp. More...
 
void tty_set_debug (int debug)
 tty_set_debug Enable or disable debug which prints verbose information. More...
 
void tty_set_gemini_udp_format (int enabled)
 
void tty_clr_trailing_read_lf (int enabled)
 
int tty_timeout (int fd, int timeout)
 
int tty_write (int fd, const char *buf, int nbytes, int *nbytes_written)
 Writes a buffer to fd. More...
 
int tty_write_string (int fd, const char *buf, int *nbytes_written)
 Writes a null terminated string to fd. More...
 
int tty_read (int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
 read buffer from terminal More...
 
int tty_read_section (int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
 read buffer from terminal with a delimiter More...
 
int tty_nread_section (int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
 read buffer from terminal with a delimiter More...
 
int tty_connect (const char *device, int bit_rate, int word_size, int parity, int stop_bits, int *fd)
 Establishes a tty connection to a terminal device. More...
 
int tty_disconnect (int fd)
 Closes a tty connection and flushes the bus. More...
 
void tty_error_msg (int err_code, char *err_msg, int err_msg_len)
 Retrieve the tty error message. More...
 
const char * pstateStr (IPState s)
 
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 * sstateStr (ISState s)
 
const char * ruleStr (ISRule r)
 
const char * permStr (IPerm p)
 
void xmlv1 ()
 
int crackDN (XMLEle *root, char **dev, char **name, char msg[])
 Extract dev and name attributes from an XML element. More...
 
ITextIUFindText (const ITextVectorProperty *tvp, const char *name)
 Find an IText member in a vector text property. More...
 
INumberIUFindNumber (const INumberVectorProperty *nvp, const char *name)
 Find an INumber member in a number text property. More...
 
ISwitchIUFindSwitch (const ISwitchVectorProperty *svp, const char *name)
 Find an ISwitch member in a vector switch property. More...
 
ILightIUFindLight (const ILightVectorProperty *lvp, const char *name)
 Find an ILight member in a vector Light property. More...
 
IBLOBIUFindBLOB (const IBLOBVectorProperty *bvp, const char *name)
 Find an IBLOB member in a vector BLOB property. More...
 
ISwitchIUFindOnSwitch (const ISwitchVectorProperty *svp)
 Returns the first ON switch it finds in the vector switch property. 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 IUSaveText (IText *tp, const char *newtext)
 Function to reliably save new text in a IText. More...
 
double rangeHA (double r)
 rangeHA Limits the hour angle value to be between -12 —> 12 More...
 
double range24 (double r)
 range24 Limits a number to be between 0-24 range. More...
 
double range360 (double r)
 range360 Limits an angle to be between 0-360 degrees. More...
 
double rangeDec (double decdegrees)
 rangeDec Limits declination value to be in -90 to 90 range. More...
 
double get_local_hour_angle (double sideral_time, double ra)
 get_local_hour_angle Returns local hour angle of an object More...
 

Variables

int tty_debug = 0
 
int ttyGeminiUdpFormat = 0
 
int sequenceNumber = 1
 
int ttyClrTrailingLF = 0
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   1

◆ MAXRBUF

#define MAXRBUF   2048

◆ PARITY_EVEN

#define PARITY_EVEN   1

◆ PARITY_NONE

#define PARITY_NONE   0

◆ PARITY_ODD

#define PARITY_ODD   2

Function Documentation

◆ crackDN()

int crackDN ( XMLEle root,
char **  dev,
char **  name,
char  msg[] 
)

Extract dev and name attributes from an XML element.

Parameters
rootThe XML element to be parsed.
devpointer to an allocated buffer to save the extracted element device name attribute. The buffer size must be at least MAXINDIDEVICE bytes.
namepointer to an allocated buffer to save the extracted elemented name attribute. The buffer size must be at least MAXINDINAME bytes.
msgpointer to an allocated char buffer to store error messages. The minimum buffer size is MAXRBUF.
Returns
0 if successful, -1 if error is encountered and msg is set.

◆ crackIPerm()

int crackIPerm ( const char *  str,
IPerm ip 
)

Extract property permission state (RW, RO, WO) from the supplied string.

Parameters
strA string representation of the permission state.
ipPointer to IPerm structure to store the extracted permission state.
Returns
0 if successful, -1 if error is encountered.

◆ crackIPState()

int crackIPState ( const char *  str,
IPState ip 
)

Extract property state (Idle, OK, Busy, Alert) from the supplied string.

Parameters
strA string representation of the state.
ipPointer to IPState structure to store the extracted property state.
Returns
0 if successful, -1 if error is encountered.

◆ crackISRule()

int crackISRule ( const char *  str,
ISRule ip 
)

Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.

Parameters
strA string representation of the switch rule.
ipPointer to ISRule structure to store the extracted switch rule.
Returns
0 if successful, -1 if error is encountered.

◆ crackISState()

int crackISState ( const char *  str,
ISState ip 
)

Extract switch state (On or Off) from the supplied string.

Parameters
strA string representation of the switch state.
ipPointer to ISState structure to store the extracted switch state.
Returns
0 if successful, -1 if error is encountered.

◆ permStr()

const char* permStr ( IPerm  p)
Returns
Returns a string representation of the supplied permission value.

◆ pstateStr()

const char* pstateStr ( IPState  s)
Returns
Returns a string representation of the supplied property state.

◆ ruleStr()

const char* ruleStr ( ISRule  r)
Returns
Returns a string representation of the supplied switch rule.

◆ sstateStr()

const char* sstateStr ( ISState  s)
Returns
Returns a string representation of the supplied switch status.

◆ xmlv1()

void xmlv1 ( )

Variable Documentation

◆ sequenceNumber

int sequenceNumber = 1

◆ tty_debug

int tty_debug = 0

◆ ttyClrTrailingLF

int ttyClrTrailingLF = 0

◆ ttyGeminiUdpFormat

int ttyGeminiUdpFormat = 0