Instrument Neutral Distributed Interface INDI  2.0.2
Macros | Enumerations | Functions | Variables
indicom.h File Reference

Implementations for common driver routines. More...

#include <math.h>

Go to the source code of this file.

Macros

#define J2000   2451545.0
 
#define ERRMSG_SIZE   1024
 
#define STELLAR_DAY   86164.098903691
 
#define TRACKRATE_SIDEREAL   ((360.0 * 3600.0) / STELLAR_DAY)
 
#define SOLAR_DAY   86400
 
#define TRACKRATE_SOLAR   ((360.0 * 3600.0) / SOLAR_DAY)
 
#define TRACKRATE_LUNAR   14.511415
 
#define EARTHRADIUSEQUATORIAL   6378137.0
 
#define EARTHRADIUSPOLAR   6356752.0
 
#define EARTHRADIUSMEAN   6372797.0
 
#define SUNMASS   1.98847E+30
 
#define PLANK_H   6.62607015E-34
 
#define DIRAC_H   (PLANK_H/(2*M_PI))
 
#define EINSTEIN_G   6.67408E-11
 
#define EULER   2.71828182845904523536028747135266249775724709369995
 
#define ROOT2   1.41421356237309504880168872420969807856967187537694
 
#define AIRY   1.21966
 
#define CIRCLE_DEG   360
 
#define CIRCLE_AM   (CIRCLE_DEG * 60)
 
#define CIRCLE_AS   (CIRCLE_AM * 60)
 
#define RAD_AS   (CIRCLE_AS/(M_PI*2))
 
#define ASTRONOMICALUNIT   1.495978707E+11
 
#define PARSEC   (ASTRONOMICALUNIT*RAD_AS)
 
#define LIGHTSPEED   299792458.0
 
#define JULIAN_LY   (LIGHTSPEED * SOLAR_DAY * 365)
 
#define STELLAR_LY   (LIGHTSPEED * STELLAR_DAY * 365)
 
#define FLUX(wavelength)   (wavelength/(PLANK_H*LIGHTSPEED))
 
#define CANDLE   ((1.0/683.0)*FLUX(555))
 
#define LUMEN(wavelength)   (CANDLE/(4*M_PI)*pow((FLUX(wavelength)/FLUX(555)), 0.25))
 
#define REDSHIFT(wavelength, reference)   (1.0-(reference/wavelength))
 
#define DOPPLER(shift, speed)   (speed*shift)
 

Enumerations

enum  TTY_ERROR {
  TTY_OK = 0 , TTY_READ_ERROR = -1 , TTY_WRITE_ERROR = -2 , TTY_SELECT_ERROR = -3 ,
  TTY_TIME_OUT = -4 , TTY_PORT_FAILURE = -5 , TTY_PARAM_ERROR = -6 , TTY_ERRNO = -7 ,
  TTY_OVERFLOW = -8 , TTY_PORT_BUSY = -9
}
 

Functions

int tty_read (int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
 read buffer from terminal More...
 
int tty_read_expanded (int fd, char *buf, int nbytes, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
 read buffer from terminal with a delimiter 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_read_section_expanded (int fd, char *buf, char stop_char, long timeout_seconds, long timeout_microseconds, 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_write (int fd, const char *buffer, int nbytes, int *nbytes_written)
 Writes a buffer to fd. More...
 
int tty_write_string (int fd, const char *buffer, int *nbytes_written)
 Writes a null terminated string to fd. 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...
 
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_timeout_microseconds (int fd, long timeout_seconds, long timeout_microseconds)
 
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[]. More...
 
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. More...
 
int extractISOTime (const char *timestr, struct ln_date *iso_date)
 Extract ISO 8601 time and store it in a tm struct. 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...
 
double time_ns ()
 Get a unix timestamp with nanosecond precision. More...
 
const char * indi_timestamp ()
 Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS. 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 r)
 rangeDec Limits declination value to be in -90 to 90 range. More...
 
double get_local_sidereal_time (double longitude)
 get_local_sidereal_time Returns local sideral time given longitude and system clock. More...
 
double get_local_hour_angle (double local_sideral_time, double ra)
 get_local_hour_angle Returns local hour angle of an object More...
 
void get_hrz_from_equ (struct ln_equ_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_hrz_posn *position)
 get_hrz_from_equ Calculate horizontal coordinates from equatorial coordinates. More...
 
void get_equ_from_hrz (struct ln_hrz_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_equ_posn *position)
 ln_get_equ_from_hrz Calculate Equatorial EOD Coordinates from horizontal coordinates More...
 
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 More...
 
double estimate_geocentric_elevation (double latitude, double sea_level_elevation)
 estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation More...
 
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 More...
 
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 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_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 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...
 
double estimate_star_mass (double delta_mag, double ref_mass)
 estimate the star mass in ref_size units e.g. sun masses or kgs More...
 
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...
 
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...
 

Variables

const char * Direction []
 
const char * SolarSystem []
 

Detailed Description

Implementations for common driver routines.

INDI LIB Common routines used by all drivers Copyright (C) 2003 by Jason Harris (jharr.nosp@m.is@3.nosp@m.0dora.nosp@m.dus..nosp@m.org) Elwood C. Downey Jasem Mutlaq

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

The INDI Common Routine Library provides formatting and serial routines employed by many INDI drivers. Currently, the library is composed of the following sections:

Author
Jason Harris
Elwood C. Downey
Jasem Mutlaq

Definition in file indicom.h.

Macro Definition Documentation

◆ AIRY

#define AIRY   1.21966

Definition at line 94 of file indicom.h.

◆ ASTRONOMICALUNIT

#define ASTRONOMICALUNIT   1.495978707E+11

Definition at line 109 of file indicom.h.

◆ CANDLE

#define CANDLE   ((1.0/683.0)*FLUX(555))

Definition at line 127 of file indicom.h.

◆ CIRCLE_AM

#define CIRCLE_AM   (CIRCLE_DEG * 60)

Definition at line 100 of file indicom.h.

◆ CIRCLE_AS

#define CIRCLE_AS   (CIRCLE_AM * 60)

Definition at line 103 of file indicom.h.

◆ CIRCLE_DEG

#define CIRCLE_DEG   360

Definition at line 97 of file indicom.h.

◆ DIRAC_H

#define DIRAC_H   (PLANK_H/(2*M_PI))

Definition at line 82 of file indicom.h.

◆ DOPPLER

#define DOPPLER (   shift,
  speed 
)    (speed*shift)

Definition at line 136 of file indicom.h.

◆ EARTHRADIUSEQUATORIAL

#define EARTHRADIUSEQUATORIAL   6378137.0

Definition at line 67 of file indicom.h.

◆ EARTHRADIUSMEAN

#define EARTHRADIUSMEAN   6372797.0

Definition at line 73 of file indicom.h.

◆ EARTHRADIUSPOLAR

#define EARTHRADIUSPOLAR   6356752.0

Definition at line 70 of file indicom.h.

◆ EINSTEIN_G

#define EINSTEIN_G   6.67408E-11

Definition at line 85 of file indicom.h.

◆ ERRMSG_SIZE

#define ERRMSG_SIZE   1024

Definition at line 49 of file indicom.h.

◆ EULER

#define EULER   2.71828182845904523536028747135266249775724709369995

Definition at line 88 of file indicom.h.

◆ FLUX

#define FLUX (   wavelength)    (wavelength/(PLANK_H*LIGHTSPEED))

Definition at line 124 of file indicom.h.

◆ J2000

#define J2000   2451545.0

Definition at line 47 of file indicom.h.

◆ JULIAN_LY

#define JULIAN_LY   (LIGHTSPEED * SOLAR_DAY * 365)

Definition at line 118 of file indicom.h.

◆ LIGHTSPEED

#define LIGHTSPEED   299792458.0

Definition at line 115 of file indicom.h.

◆ LUMEN

#define LUMEN (   wavelength)    (CANDLE/(4*M_PI)*pow((FLUX(wavelength)/FLUX(555)), 0.25))

Definition at line 130 of file indicom.h.

◆ PARSEC

#define PARSEC   (ASTRONOMICALUNIT*RAD_AS)

Definition at line 112 of file indicom.h.

◆ PLANK_H

#define PLANK_H   6.62607015E-34

Definition at line 79 of file indicom.h.

◆ RAD_AS

#define RAD_AS   (CIRCLE_AS/(M_PI*2))

Definition at line 106 of file indicom.h.

◆ REDSHIFT

#define REDSHIFT (   wavelength,
  reference 
)    (1.0-(reference/wavelength))

Definition at line 133 of file indicom.h.

◆ ROOT2

#define ROOT2   1.41421356237309504880168872420969807856967187537694

Definition at line 91 of file indicom.h.

◆ SOLAR_DAY

#define SOLAR_DAY   86400

Definition at line 58 of file indicom.h.

◆ STELLAR_DAY

#define STELLAR_DAY   86164.098903691

Definition at line 52 of file indicom.h.

◆ STELLAR_LY

#define STELLAR_LY   (LIGHTSPEED * STELLAR_DAY * 365)

Definition at line 121 of file indicom.h.

◆ SUNMASS

#define SUNMASS   1.98847E+30

Definition at line 76 of file indicom.h.

◆ TRACKRATE_LUNAR

#define TRACKRATE_LUNAR   14.511415

Definition at line 64 of file indicom.h.

◆ TRACKRATE_SIDEREAL

#define TRACKRATE_SIDEREAL   ((360.0 * 3600.0) / STELLAR_DAY)

Definition at line 55 of file indicom.h.

◆ TRACKRATE_SOLAR

#define TRACKRATE_SOLAR   ((360.0 * 3600.0) / SOLAR_DAY)

Definition at line 61 of file indicom.h.

Enumeration Type Documentation

◆ TTY_ERROR

enum TTY_ERROR
Enumerator
TTY_OK 
TTY_READ_ERROR 
TTY_WRITE_ERROR 
TTY_SELECT_ERROR 
TTY_TIME_OUT 
TTY_PORT_FAILURE 
TTY_PARAM_ERROR 
TTY_ERRNO 
TTY_OVERFLOW 
TTY_PORT_BUSY 

Definition at line 148 of file indicom.h.

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 1343 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 1408 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 1418 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 1363 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 1393 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 1398 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 1403 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 1353 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 1333 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 1323 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 1315 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 1378 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 1383 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 1388 of file indicom.c.

◆ estimate_star_mass()

double estimate_star_mass ( double  delta_mag,
double  ref_mass 
)

estimate the star mass in ref_size units e.g. sun masses or kgs

Parameters
delta_magThe absolute magnitude ratio between the reference object used as unit in ref_size.
ref_massThe mass of the reference object used to calculate the magnitude difference.

◆ extractISOTime()

int extractISOTime ( const char *  timestr,
struct ln_date *  iso_date 
)

Extract ISO 8601 time and store it in a tm struct.

Parameters
timestra string containing date and time in ISO 8601 format.
iso_datea pointer to a ln_date structure to store the extracted time and date (libnova).
Returns
0 on success, -1 on failure.

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

Definition at line 141 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 1299 of file indicom.c.

◆ get_equ_from_hrz()

void get_equ_from_hrz ( struct ln_hrz_posn *  object,
struct ln_lnlat_posn *  observer,
double  JD,
struct ln_equ_posn *  position 
)

ln_get_equ_from_hrz Calculate Equatorial EOD Coordinates from horizontal coordinates

Parameters
objectHorizontal Object Coordinates
observerObserver Location
JDJulian Date
positionCalculated Equatorial Coordinates.
Note
Use this instead of libnova ln_get_equ_from_hrz since it corrects libnova Azimuth (0 = North and not South).

◆ get_hrz_from_equ()

void get_hrz_from_equ ( struct ln_equ_posn *  object,
struct ln_lnlat_posn *  observer,
double  JD,
struct ln_hrz_posn *  position 
)

get_hrz_from_equ Calculate horizontal coordinates from equatorial coordinates.

Parameters
objectEquatorial Object Coordinates
observerObserver Location
JDJulian Date
positionCalculated Horizontal Coordinates.
Note
Use this instead of libnova ln_get_hrz_from_equ since it corrects libnova Azimuth (0 = North and not South).

◆ 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 1293 of file indicom.c.

◆ get_local_sidereal_time()

double get_local_sidereal_time ( double  longitude)

get_local_sidereal_time Returns local sideral time given longitude and system clock.

Parameters
longitudeLongitude in INDI format (0 to 360) increasing eastward.
Returns
Local Sidereal Time.

◆ getSexComponents()

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

Definition at line 254 of file indicom.c.

◆ getSexComponentsIID()

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

Definition at line 277 of file indicom.c.

◆ indi_timestamp()

const char* indi_timestamp ( )

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

Returns
The formatted time stamp.

Definition at line 348 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 1358 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 288 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 1348 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 1235 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 1245 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 1255 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 1225 of file indicom.c.

◆ time_ns()

double time_ns ( )

Get a unix timestamp with nanosecond precision.

Returns
Seconds since UNIX Epoch.

Definition at line 326 of file indicom.c.

◆ tty_clr_trailing_read_lf()

void tty_clr_trailing_read_lf ( int  enabled)

Definition at line 375 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 946 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 1148 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 1167 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 initialized 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 666 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 initialized 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 482 of file indicom.c.

◆ tty_read_expanded()

int tty_read_expanded ( int  fd,
char *  buf,
int  nbytes,
long  timeout_seconds,
long  timeout_microseconds,
int *  nbytes_read 
)

read buffer from terminal with a delimiter

Parameters
fdfile descriptor
bufpointer to store data. Must be initialized and big enough to hold data.
stop_charif the function encounters stop_char then it stops reading and returns the buffer.
timeout_secondsnumber of seconds to wait for terminal before a timeout error is issued.

(Total time = timeout_seconds + timeout_microseconds)

Parameters
timeout_microsecondsnumber of microseconds to wait for terminal before a timeout error is issued.

(Total time = timeout_seconds + timeout_microseconds)

Parameters
nbytes_readthe number of bytes read.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 487 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 initialized 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 566 of file indicom.c.

◆ tty_read_section_expanded()

int tty_read_section_expanded ( int  fd,
char *  buf,
char  stop_char,
long  timeout_seconds,
long  timeout_microseconds,
int *  nbytes_read 
)

read buffer from terminal with a delimiter

Parameters
fdfile descriptor
bufpointer to store data. Must be initialized 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.
timeout_secondsnumber of seconds to wait for terminal before a timeout error is issued.

(Total Timeout is timeout_seconds + timeout_microseconds)

Parameters
timeout_microsecondsnumber of microseconds to wait for terminal before a timeout error is issued.

(Total Timeout is timeout_seconds + timeout_microseconds)

Parameters
nbytes_readthe number of bytes read.
Returns
On success, it returns TTY_OK, otherwise, a TTY_ERROR code.

Definition at line 571 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 360 of file indicom.c.

◆ tty_set_gemini_udp_format()

void tty_set_gemini_udp_format ( int  enabled)

Definition at line 365 of file indicom.c.

◆ tty_set_generic_udp_format()

void tty_set_generic_udp_format ( int  enabled)

Definition at line 370 of file indicom.c.

◆ tty_timeout()

int tty_timeout ( int  fd,
int  timeout 
)

Definition at line 380 of file indicom.c.

◆ tty_timeout_microseconds()

int tty_timeout_microseconds ( int  fd,
long  timeout_seconds,
long  timeout_microseconds 
)

Definition at line 385 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 424 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 474 of file indicom.c.

Variable Documentation

◆ Direction

const char* Direction[]
extern

◆ SolarSystem

const char* SolarSystem[]
extern