Instrument Neutral Distributed Interface INDI  1.9.2
Macros | Functions
indicom.c File Reference
#include "indicom.h"
#include "indidevapi.h"
#include "locale_compat.h"
#include "base64.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 "userio.h"
#include "indiuserio.h"

Go to the source code of this file.

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,...)
 
double time_ns ()
 Get a unix timestamp with nanosecond precision. More...
 
const char * timestamp ()
 Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS. 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_set_generic_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...
 
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...
 
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...
 
void get_alt_az_coordinates (double Ha, double Dec, double Lat, double *Alt, double *Az)
 get_alt_az_coordinates Returns alt-azimuth coordinates of an object More...
 
double estimate_geocentric_elevation (double Lat, double El)
 estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation More...
 
double estimate_field_rotation_rate (double Alt, double Az, double Lat)
 estimate_field_rotation_rate Returns an estimation of the field rotation rate of the object More...
 
double estimate_field_rotation (double HA, double rate)
 estimate_field_rotation Returns an estimation of the field rotation rate of the object More...
 
double as2rad (double as)
 as2rad Convert arcseconds into radians More...
 
double rad2as (double rad)
 rad2as Convert radians into arcseconds More...
 
double estimate_distance (double parsecs, double parallax_radius)
 estimate_distance Convert parallax arcseconds into meters More...
 
double m2au (double m)
 m2au Convert meters into astronomical units More...
 
double calc_delta_magnitude (double mag_ratio, double *spectrum, double *ref_spectrum, int spectrum_size)
 calc_delta_magnitude Returns the difference of magnitudes given two spectra More...
 
double calc_star_mass (double delta_mag, double ref_size)
 
double estimate_orbit_radius (double obs_lambda, double ref_lambda, double period)
 estimate the orbit radius of an object with known mass orbiting around a star. More...
 
double estimate_secondary_mass (double star_mass, double star_drift, double orbit_radius)
 estimate the mass of an object with known mass orbiting around a star. More...
 
double estimate_secondary_size (double star_size, double dropoff_ratio)
 estimate the size of an object occulting a star in star_size units. More...
 
double calc_photon_flux (double rel_magnitude, double filter_bandwidth, double wavelength, double steradian)
 calc_photon_flux Returns the photon flux of the object with the given magnitude observed at a determined wavelenght using a passband filter through a steradian expressed cone More...
 
double calc_rel_magnitude (double photon_flux, double filter_bandwidth, double wavelength, double steradian)
 calc_rel_magnitude Returns the relative magnitude of the object with the given photon flux measured at a determined wavelenght using a passband filter over an incident surface More...
 
double estimate_absolute_magnitude (double delta_dist, double delta_mag)
 estimate_absolute_magnitude Returns an estimation of the absolute magnitude of an object given its distance and the difference of its magnitude with a reference object More...
 
void baseline_2d_projection (double alt, double az, double baseline[3], double wavelength, double uvresult[2])
 baseline_2d_projection Returns the coordinates of the projection of a single baseline targeting the object by coordinates More...
 
double baseline_delay (double alt, double az, double baseline[3])
 baseline_delay Returns the delay in meters of a single baseline targeting the object by coordinates More...
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   1

Definition at line 26 of file indicom.c.

◆ MAXRBUF

#define MAXRBUF   2048

Definition at line 92 of file indicom.c.

◆ PARITY_EVEN

#define PARITY_EVEN   1

Definition at line 78 of file indicom.c.

◆ PARITY_NONE

#define PARITY_NONE   0

Definition at line 77 of file indicom.c.

◆ PARITY_ODD

#define PARITY_ODD   2

Definition at line 79 of file indicom.c.

Function Documentation

◆ as2rad()

double as2rad ( double  as)

as2rad Convert arcseconds into radians

Parameters
asthe arcseconds to convert
Returns
radians corresponding as angle value

Definition at line 1572 of file indicom.c.

◆ baseline_2d_projection()

void baseline_2d_projection ( double  alt,
double  az,
double  baseline[3],
double  wavelength,
double  uvresult[2] 
)

baseline_2d_projection Returns the coordinates of the projection of a single baseline targeting the object by coordinates

Parameters
altcurrent altitude of the target.
azazimuth position of the target.
baselinethe baseline in meters. Three-dimensional xyz north is z axis y is UTC0 x is UTC0+90°.
wavelengthThe observing electromagnetic wavelength, the lower the size increases.
uvresultresult plane coordinates of the current projection given the baseline and target vector.

Definition at line 1637 of file indicom.c.

◆ baseline_delay()

double baseline_delay ( double  alt,
double  az,
double  baseline[3] 
)

baseline_delay Returns the delay in meters of a single baseline targeting the object by coordinates

Parameters
altcurrent altitude of the target.
azazimuth position of the target.
baselinethe baseline in meters. Three-dimensional xyz north is z axis y is UTC0 x is UTC0+90°.
wavelengthThe observing electromagnetic wavelength, the lower the size increases.
Returns
double[2] UV plane coordinates of the current projection given the baseline and target vector.

Definition at line 1647 of file indicom.c.

◆ calc_delta_magnitude()

double calc_delta_magnitude ( double  mag_ratio,
double *  spectrum,
double *  ref_spectrum,
int  spectrum_size 
)

calc_delta_magnitude Returns the difference of magnitudes given two spectra

Parameters
mag_ratioReference magnitude
spectrumThe spectrum of the star under exam
ref_spectrumThe spectrum of the reference star
spectrum_sizeThe size of the spectrum array in elements
Returns
the magnitude difference

Definition at line 1592 of file indicom.c.

◆ calc_photon_flux()

double calc_photon_flux ( double  rel_magnitude,
double  filter_bandwidth,
double  wavelength,
double  steradian 
)

calc_photon_flux Returns the photon flux of the object with the given magnitude observed at a determined wavelenght using a passband filter through a steradian expressed cone

Parameters
rel_magnitudeRelative magnitude of the object observed
filter_bandwidthFilter bandwidth in meters
wavelengthWavelength in meters
steradianThe light cone in steradians
Returns
the photon flux in Lumen

Definition at line 1622 of file indicom.c.

◆ calc_rel_magnitude()

double calc_rel_magnitude ( double  photon_flux,
double  filter_bandwidth,
double  wavelength,
double  steradian 
)

calc_rel_magnitude Returns the relative magnitude of the object with the given photon flux measured at a determined wavelenght using a passband filter over an incident surface

Parameters
photon_fluxThe photon flux in Lumen
filter_bandwidthFilter bandwidth in meters
wavelengthWavelength in meters
incident_surfaceThe incident surface in square meters
Returns
the relative magnitude of the object observed

Definition at line 1627 of file indicom.c.

◆ calc_star_mass()

double calc_star_mass ( double  delta_mag,
double  ref_size 
)

Definition at line 1602 of file indicom.c.

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

Definition at line 1317 of file indicom.c.

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

Definition at line 1240 of file indicom.c.

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

Definition at line 1211 of file indicom.c.

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

Definition at line 1253 of file indicom.c.

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

Definition at line 1229 of file indicom.c.

◆ estimate_absolute_magnitude()

double estimate_absolute_magnitude ( double  dist,
double  delta_mag 
)

estimate_absolute_magnitude Returns an estimation of the absolute magnitude of an object given its distance and the difference of its magnitude with a reference object

Parameters
distThe distance in parallax radiuses
delta_magThe difference of magnitudes
Returns
Aproximation of the absolute magnitude in Δmag

Definition at line 1632 of file indicom.c.

◆ estimate_distance()

double estimate_distance ( double  parsecs,
double  parallax_radius 
)

estimate_distance Convert parallax arcseconds into meters

Parameters
parsecthe parallax arcseconds to convert
Returns
Estimation of the distance in measure units used in parallax_radius

Definition at line 1582 of file indicom.c.

◆ estimate_field_rotation()

double estimate_field_rotation ( double  hour_angle,
double  field_rotation_rate 
)

estimate_field_rotation Returns an estimation of the field rotation rate of the object

Parameters
hour_angleHour angle in hours (-12 to 12)
field_rotation_ratethe field rotation rate
Returns
Aproximation of the absolute field rotation

Definition at line 1562 of file indicom.c.

◆ estimate_field_rotation_rate()

double estimate_field_rotation_rate ( double  Alt,
double  Az,
double  latitude 
)

estimate_field_rotation_rate Returns an estimation of the field rotation rate of the object

Parameters
Altaltitude coordinate of the object
Azazimuth coordinate of the object
latitudelatitude in INDI format (-90 to +90)
Returns
Aproximation of the field rotation rate

Definition at line 1552 of file indicom.c.

◆ estimate_geocentric_elevation()

double estimate_geocentric_elevation ( double  latitude,
double  sea_level_elevation 
)

estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation

Parameters
latitudelatitude in INDI format (-90 to +90)
sea_level_elevationsea level elevation
Returns
Aproximated geocentric elevation

Definition at line 1544 of file indicom.c.

◆ estimate_orbit_radius()

double estimate_orbit_radius ( double  obs_lambda,
double  ref_lambda,
double  period 
)

estimate the orbit radius of an object with known mass orbiting around a star.

Parameters
obs_lambdaThe observed wavelength of a spectral line observed on the star affected by redshift or blueshift.
ref_lambdaThe reference wavelength of the spectral line observed on earth or the nullshift spectral line position.
periodThe orbital period.

Definition at line 1607 of file indicom.c.

◆ estimate_secondary_mass()

double estimate_secondary_mass ( double  star_mass,
double  star_drift,
double  orbit_radius 
)

estimate the mass of an object with known mass orbiting around a star.

Parameters
star_massThe mass of the star hosting an orbiting object.
star_driftThe star lagrange point L1 (observed drift of the star).
orbit_radiusThe estimated orbit radius of the companion object (star, planet, cloud).

Definition at line 1612 of file indicom.c.

◆ estimate_secondary_size()

double estimate_secondary_size ( double  star_size,
double  dropoff_ratio 
)

estimate the size of an object occulting a star in star_size units.

Parameters
star_sizeThe size of the occulted star.
dropoff_ratioThe light curve dropoff during the transit. Linear scale. 0.0=no dropoff 1.0=totally occulted.

Definition at line 1617 of file indicom.c.

◆ f_scansexa()

int f_scansexa ( const char *  str0,
double *  dp 
)

convert sexagesimal string str AxBxC to double.

x can be anything non-numeric. Any missing A, B or C will be assumed 0. Optional - and + can be anywhere.

Parameters
str0string containing sexagesimal number.
dppointer to a double to store the sexagesimal number.
Returns
return 0 if ok, -1 if can't find a thing.

Definition at line 195 of file indicom.c.

◆ fs_sexa()

int fs_sexa ( char *  out,
double  a,
int  w,
int  fracbase 
)

Converts a sexagesimal number to a string.

sprint the variable a in sexagesimal format into out[].

Parameters
outa pointer to store the sexagesimal number.
athe sexagesimal number to convert.
wthe number of spaces in the whole part.
fracbaseis the number of pieces a whole is to broken into; valid options:
  • 360000: <w>:mm:ss.ss
  • 36000: <w>:mm:ss.s
  • 3600: <w>:mm:ss
  • 600: <w>:mm.m
  • 60: <w>:mm
Returns
number of characters written to out, not counting final null terminator.
Examples
simplescope.cpp.

Definition at line 131 of file indicom.c.

◆ get_alt_az_coordinates()

void get_alt_az_coordinates ( double  hour_angle,
double  dec,
double  latitude,
double *  alt,
double *  az 
)

get_alt_az_coordinates Returns alt-azimuth coordinates of an object

Parameters
hour_angleHour angle in hours (-12 to 12)
decDEC of object
latitudelatitude in INDI format (-90 to +90)
altALT of object will be returned here
azAZ of object will be returned here

Definition at line 1528 of file indicom.c.

◆ get_local_hour_angle()

double get_local_hour_angle ( double  local_sideral_time,
double  ra 
)

get_local_hour_angle Returns local hour angle of an object

Parameters
local_sideral_timeLocal Sideral Time
raRA of object
Returns
Hour angle in hours (-12 to 12)

Definition at line 1522 of file indicom.c.

◆ getSexComponents()

void getSexComponents ( double  value,
int *  d,
int *  m,
int *  s 
)

Definition at line 244 of file indicom.c.

◆ getSexComponentsIID()

void getSexComponentsIID ( double  value,
int *  d,
int *  m,
double *  s 
)

Definition at line 267 of file indicom.c.

◆ IDLog()

void IDLog ( const char *  fmt,
  ... 
)

Definition at line 306 of file indicom.c.

◆ IUFindBLOB()

IBLOB* IUFindBLOB ( const IBLOBVectorProperty bvp,
const char *  name 
)

Find an IBLOB member in a vector BLOB property.

Parameters
bvpa pointer to a BLOB vector property.
namethe name of the member to search for.
Returns
a pointer to an IBLOB member on match, or NULL if nothing is found.

Definition at line 1381 of file indicom.c.

◆ IUFindLight()

ILight* IUFindLight ( const ILightVectorProperty lvp,
const char *  name 
)

Find an ILight member in a vector Light property.

Parameters
lvpa pointer to a Light vector property.
namethe name of the member to search for.
Returns
a pointer to an ILight member on match, or NULL if nothing is found.

Definition at line 1371 of file indicom.c.

◆ IUFindNumber()

INumber* IUFindNumber ( const INumberVectorProperty nvp,
const char *  name 
)

Find an INumber member in a number text property.

Parameters
nvpa pointer to a number vector property.
namethe name of the member to search for.
Returns
a pointer to an INumber member on match, or NULL if nothing is found.

Definition at line 1351 of file indicom.c.

◆ IUFindOnSwitch()

ISwitch* IUFindOnSwitch ( const ISwitchVectorProperty sp)

Returns the first ON switch it finds in the vector switch property.

Note
This is only valid for ISR_1OFMANY mode. That is, when only one switch out of many is allowed to be ON. Do not use this function if you can have multiple ON switches in the same vector property.
Parameters
spa pointer to a switch vector property.
Returns
a pointer to the first ON ISwitch member if found. If all switches are off, NULL is returned.

Definition at line 1393 of file indicom.c.

◆ IUFindOnSwitchIndex()

int IUFindOnSwitchIndex ( const ISwitchVectorProperty sp)

Returns the index of first ON switch it finds in the vector switch property.

Note
This is only valid for ISR_1OFMANY mode. That is, when only one switch out of many is allowed to be ON. Do not use this function if you can have multiple ON switches in the same vector property.
Parameters
spa pointer to a switch vector property.
Returns
index to the first ON ISwitch member if found. If all switches are off, -1 is returned.

Definition at line 1403 of file indicom.c.

◆ IUFindOnSwitchName()

const char* IUFindOnSwitchName ( ISState states,
char *  names[],
int  n 
)

Returns the name of the first ON switch it finds in the supplied arguments.

Note
This is only valid for ISR_1OFMANY mode. That is, when only one switch out of many is allowed to be ON. Do not use this function if you can have multiple ON switches in the same vector property.
This is a convience function intended to be used in ISNewSwitch(...) function to find out ON switch name without having to change actual switch state via IUUpdateSwitch(..)
Parameters
stateslist of switch states passed by ISNewSwitch()
nameslist of switch names passed by ISNewSwitch()
nnumber of switches passed by ISNewSwitch()
Returns
name of the first ON ISwitch member if found. If all switches are off, NULL is returned.

Definition at line 1412 of file indicom.c.

◆ IUFindSwitch()

ISwitch* IUFindSwitch ( const ISwitchVectorProperty svp,
const char *  name 
)

Find an ISwitch member in a vector switch property.

Parameters
svpa pointer to a switch vector property.
namethe name of the member to search for.
Returns
a pointer to an ISwitch member on match, or NULL if nothing is found.

Definition at line 1361 of file indicom.c.

◆ IUFindText()

IText* IUFindText ( const ITextVectorProperty tvp,
const char *  name 
)

Find an IText member in a vector text property.

Parameters
tvpa pointer to a text vector property.
namethe name of the member to search for.
Returns
a pointer to an IText member on match, or NULL if nothing is found.

Definition at line 1341 of file indicom.c.

◆ IUResetSwitch()

void IUResetSwitch ( ISwitchVectorProperty svp)

Reset all switches in a switch vector property to OFF.

Parameters
svpa pointer to a switch vector property.

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

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

◆ IUSaveText()

void IUSaveText ( IText tp,
const char *  newtext 
)

Function to reliably save new text in a IText.

Parameters
tppointer to an IText member.
newtextthe new text to be saved

Definition at line 1428 of file indicom.c.

◆ m2au()

double m2au ( double  m)

m2au Convert meters into astronomical units

Parameters
mthe distance in meters to convert
Returns
Estimation of the distance in astronomical units

Definition at line 1587 of file indicom.c.

◆ numberFormat()

int numberFormat ( char *  buf,
const char *  format,
double  value 
)

Fill buffer with properly formatted INumber string.

Parameters
bufto store the formatted string.
formatformat in sprintf style.
valuethe number to format.
Returns
length of string.
Note
buf must be of length MAXINDIFORMAT at minimum

Definition at line 278 of file indicom.c.

◆ permStr()

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

Definition at line 1294 of file indicom.c.

◆ pstateStr()

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

Definition at line 1194 of file indicom.c.

◆ rad2as()

double rad2as ( double  rad)

rad2as Convert radians into arcseconds

Parameters
asthe radians to convert
Returns
arcseconds corresponding as angle value

Definition at line 1577 of file indicom.c.

◆ range24()

double range24 ( double  r)

range24 Limits a number to be between 0-24 range.

Parameters
rnumber to be limited
Returns
Limited number

Definition at line 1464 of file indicom.c.

◆ range360()

double range360 ( double  r)

range360 Limits an angle to be between 0-360 degrees.

Parameters
rangle
Returns
Limited angle

Definition at line 1474 of file indicom.c.

◆ rangeDec()

double rangeDec ( double  r)

rangeDec Limits declination value to be in -90 to 90 range.

Parameters
rdeclination angle
Returns
limited declination

Definition at line 1484 of file indicom.c.

◆ rangeHA()

double rangeHA ( double  r)

rangeHA Limits the hour angle value to be between -12 —> 12

Parameters
rcurrent hour angle value
Returns
Limited value (-12,12)

Definition at line 1454 of file indicom.c.

◆ ruleStr()

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

Definition at line 1280 of file indicom.c.

◆ sstateStr()

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

Definition at line 1267 of file indicom.c.

◆ time_ns()

double time_ns ( )

Get a unix timestamp with nanosecond precision.

Returns
Seconds since UNIX Epoch.

Definition at line 316 of file indicom.c.

◆ timestamp()

const char* timestamp ( )

Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.

Returns
The formatted time stamp.

Definition at line 334 of file indicom.c.

◆ tty_clr_trailing_read_lf()

void tty_clr_trailing_read_lf ( int  enabled)

Definition at line 361 of file indicom.c.

◆ tty_connect()

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.

Parameters
devicethe device node. e.g. /dev/ttyS0
bit_ratebit rate
word_sizenumber of data bits, 7 or 8, USE 8 DATA BITS with modbus
parity0=no parity, 1=parity EVEN, 2=parity ODD
stop_bitsnumber of stop bits : 1 or 2
fdfd is set to the file descriptor value on success.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.
Author
Wildi Markus

Definition at line 916 of file indicom.c.

◆ tty_disconnect()

int tty_disconnect ( int  fd)

Closes a tty connection and flushes the bus.

Parameters
fdthe file descriptor to close.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 1116 of file indicom.c.

◆ tty_error_msg()

void tty_error_msg ( int  err_code,
char *  err_msg,
int  err_msg_len 
)

Retrieve the tty error message.

Parameters
err_codethe error code return by any TTY function.
err_msgan initialized buffer to hold the error message.
err_msg_lenlength in bytes of err_msg

Definition at line 1135 of file indicom.c.

◆ tty_nread_section()

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

Parameters
fdfile descriptor
bufpointer to store data. Must be initilized and big enough to hold data.
stop_charif the function encounters stop_char then it stops reading and returns the buffer.
nsizesize of buf. If stop character is not encountered before nsize, the function aborts.
timeoutnumber of seconds to wait for terminal before a timeout error is issued.
nbytes_readthe number of bytes read.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 636 of file indicom.c.

◆ tty_read()

int tty_read ( int  fd,
char *  buf,
int  nbytes,
int  timeout,
int *  nbytes_read 
)

read buffer from terminal

Parameters
fdfile descriptor
bufpointer to store data. Must be initilized and big enough to hold data.
nbytesnumber of bytes to read.
timeoutnumber of seconds to wait for terminal before a timeout error is issued.
nbytes_readthe number of bytes read.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 462 of file indicom.c.

◆ tty_read_section()

int tty_read_section ( int  fd,
char *  buf,
char  stop_char,
int  timeout,
int *  nbytes_read 
)

read buffer from terminal with a delimiter

Parameters
fdfile descriptor
bufpointer to store data. Must be initilized and big enough to hold data.
stop_charif the function encounters stop_char then it stops reading and returns the buffer.
timeoutnumber of seconds to wait for terminal before a timeout error is issued.
nbytes_readthe number of bytes read.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 541 of file indicom.c.

◆ tty_set_debug()

void tty_set_debug ( int  debug)

tty_set_debug Enable or disable debug which prints verbose information.

Parameters
debug1 to enable, 0 to disable

Definition at line 346 of file indicom.c.

◆ tty_set_gemini_udp_format()

void tty_set_gemini_udp_format ( int  enabled)

Definition at line 351 of file indicom.c.

◆ tty_set_generic_udp_format()

void tty_set_generic_udp_format ( int  enabled)

Definition at line 356 of file indicom.c.

◆ tty_timeout()

int tty_timeout ( int  fd,
int  timeout 
)

Definition at line 366 of file indicom.c.

◆ tty_write()

int tty_write ( int  fd,
const char *  buffer,
int  nbytes,
int *  nbytes_written 
)

Writes a buffer to fd.

Parameters
fdfile descriptor
buffera null-terminated buffer to write to fd.
nbytesnumber of bytes to write from buffer
nbytes_writtenthe number of bytes written
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 404 of file indicom.c.

◆ tty_write_string()

int tty_write_string ( int  fd,
const char *  buffer,
int *  nbytes_written 
)

Writes a null terminated string to fd.

Parameters
fdfile descriptor
bufferthe buffer to write to fd.
nbytes_writtenthe number of bytes written
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 454 of file indicom.c.

◆ xmlv1()

void xmlv1 ( )

Definition at line 1308 of file indicom.c.