|
Instrument Neutral Distributed Interface INDI 2.2.5
|
Implementations for common driver routines. More...
#include "indimacros.h"Go to the source code of this file.
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 | |
| 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 | |
| int | tty_read_section (int fd, char *buf, char stop_char, int timeout, int *nbytes_read) |
| read buffer from terminal with a delimiter | |
| 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 | |
| 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 | |
| int | tty_nread_section_expanded (int fd, char *buf, int nsize, char stop_char, long timeout_seconds, long timeout_microseconds, int *nbytes_read) |
| read buffer from terminal with a delimiter | |
| int | tty_write (int fd, const char *buffer, int nbytes, int *nbytes_written) |
| Writes a buffer to fd. | |
| int | tty_write_string (int fd, const char *buffer, int *nbytes_written) |
| Writes a null terminated string to fd. | |
| 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. | |
| int | tty_disconnect (int fd) |
| Closes a tty connection and flushes the bus. | |
| void | tty_error_msg (int err_code, char *err_msg, int err_msg_len) |
| Retrieve the tty error message. | |
| void | tty_set_debug (int debug) |
| tty_set_debug Enable or disable debug which prints verbose information. | |
| 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) |
| void | tty_reset_udp_session (int fd, int only_if_timeout_happened) |
| create new UDP session to prevent packet conflict | |
| void | tty_set_auto_reset_udp_session (int flag) |
| automatically reset UDP session on write | |
| 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[]. | |
| 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. | |
| int | extractISOTime (const char *timestr, struct ln_date *iso_date) |
| Extract ISO 8601 time and store it in a tm struct. | |
| 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. | |
| double | time_ns () |
| Get a unix timestamp with nanosecond precision. | |
| const char * | indi_timestamp () |
| Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS. | |
| double | rangeHA (double r) |
| rangeHA Limits the hour angle value to be between -12 —> 12 | |
| double | range24 (double r) |
| range24 Limits a number to be between 0-24 range. | |
| double | range360 (double r) |
| range360 Limits an angle to be between 0-360 degrees. | |
| double | range180 (double r) |
| range180 Limits an angle to be between -180 to +180 degrees | |
| double | rangeDec (double r) |
| rangeDec Limits declination value to be in -90 to 90 range. | |
| double | get_local_sidereal_time (double longitude) |
| get_local_sidereal_time Returns local sidereal time given longitude and system clock. | |
| double | get_local_hour_angle (double local_sidereal_time, double ra) |
| get_local_hour_angle Returns local hour angle of an object | |
| 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. | |
| 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 | |
| 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 | |
| double | estimate_geocentric_elevation (double latitude, double sea_level_elevation) |
| estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation | |
| 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 | |
| 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 | |
| double | as2rad (double as) |
| as2rad Convert arcseconds into radians | |
| double | rad2as (double rad) |
| rad2as Convert radians into arcseconds | |
| double | estimate_distance (double parsecs, double parallax_radius) |
| estimate_distance Convert parallax arcseconds into meters | |
| double | m2au (double m) |
| m2au Convert meters into astronomical units | |
| 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 | |
| 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 wavelength using a passband filter through a steradian expressed cone | |
| 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 wavelength using a passband filter over an incident surface | |
| 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 | |
| double | estimate_star_mass (double delta_mag, double ref_mass) |
| estimate the star mass in ref_size units e.g. sun masses or kgs | |
| 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. | |
| 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. | |
| double | estimate_secondary_size (double star_size, double dropoff_ratio) |
| estimate the size of an object occulting a star in star_size units. | |
| 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 | |
| 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 | |
Variables | |
| const char * | Direction [] |
| const char * | SolarSystem [] |
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:
Definition in file indicom.h.
| enum TTY_ERROR |
| double as2rad | ( | double | as | ) |
| 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
| alt | current altitude of the target. |
| az | azimuth position of the target. |
| baseline | the baseline in meters. Three-dimensional xyz north is z axis y is UTC0 x is UTC0+90°. |
| wavelength | The observing electromagnetic wavelength, the lower the size increases. |
| uvresult | result plane coordinates of the current projection given the baseline and target vector. |
| 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
| alt | current altitude of the target. |
| az | azimuth position of the target. |
| baseline | the baseline in meters. Three-dimensional xyz north is z axis y is UTC0 x is UTC0+90°. |
| wavelength | The observing electromagnetic wavelength, the lower the size increases. |
| 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
| mag_ratio | Reference magnitude |
| spectrum | The spectrum of the star under exam |
| ref_spectrum | The spectrum of the reference star |
| spectrum_size | The size of the spectrum array in elements |
| 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 wavelength using a passband filter through a steradian expressed cone
| rel_magnitude | Relative magnitude of the object observed |
| filter_bandwidth | Filter bandwidth in meters |
| wavelength | Wavelength in meters |
| steradian | The light cone in steradians |
| 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 wavelength using a passband filter over an incident surface
| photon_flux | The photon flux in Lumen |
| filter_bandwidth | Filter bandwidth in meters |
| wavelength | Wavelength in meters |
| incident_surface | The incident surface in square meters |
| 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
| dist | The distance in parallax radiuses |
| delta_mag | The difference of magnitudes |
| double estimate_distance | ( | double | parsecs, |
| double | parallax_radius | ||
| ) |
| double estimate_field_rotation | ( | double | hour_angle, |
| double | 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
| Alt | altitude coordinate of the object |
| Az | azimuth coordinate of the object |
| latitude | latitude in INDI format (-90 to +90) |
| double estimate_geocentric_elevation | ( | double | latitude, |
| double | sea_level_elevation | ||
| ) |
| 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.
| obs_lambda | The observed wavelength of a spectral line observed on the star affected by redshift or blueshift. |
| ref_lambda | The reference wavelength of the spectral line observed on earth or the nullshift spectral line position. |
| period | The orbital period. |
| 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.
| star_mass | The mass of the star hosting an orbiting object. |
| star_drift | The star lagrange point L1 (observed drift of the star). |
| orbit_radius | The estimated orbit radius of the companion object (star, planet, cloud). |
| double estimate_secondary_size | ( | double | star_size, |
| double | dropoff_ratio | ||
| ) |
| double estimate_star_mass | ( | double | delta_mag, |
| double | ref_mass | ||
| ) |
estimate the star mass in ref_size units e.g. sun masses or kgs
| delta_mag | The absolute magnitude ratio between the reference object used as unit in ref_size. |
| ref_mass | The mass of the reference object used to calculate the magnitude difference. |
| int extractISOTime | ( | const char * | timestr, |
| struct ln_date * | iso_date | ||
| ) |
Extract ISO 8601 time and store it in a tm struct.
| timestr | a string containing date and time in ISO 8601 format. |
| iso_date | a pointer to a ln_date structure to store the extracted time and date (libnova). |
| 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.
| str0 | string containing sexagesimal number. |
| dp | pointer to a double to store the sexagesimal number. |
| 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[].
| out | a pointer to store the sexagesimal number. |
| a | the sexagesimal number to convert. |
| w | the number of spaces in the whole part. |
| fracbase | is the number of pieces a whole is to broken into; valid options:
|
| 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
| hour_angle | Hour angle in hours (-12 to 12) |
| dec | DEC of object |
| latitude | latitude in INDI format (-90 to +90) |
| alt | ALT of object will be returned here |
| az | AZ of object will be returned here |
| 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
| object | Horizontal Object Coordinates |
| observer | Observer Location |
| JD | Julian Date |
| position | Calculated Equatorial Coordinates. |
| 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.
| object | Equatorial Object Coordinates |
| observer | Observer Location |
| JD | Julian Date |
| position | Calculated Horizontal Coordinates. |
| double get_local_hour_angle | ( | double | local_sidereal_time, |
| double | ra | ||
| ) |
| double get_local_sidereal_time | ( | double | longitude | ) |
get_local_sidereal_time Returns local sidereal time given longitude and system clock.
| longitude | Longitude in INDI format (0 to 360) increasing eastward. |
| void getSexComponents | ( | double | value, |
| int * | d, | ||
| int * | m, | ||
| int * | s | ||
| ) |
| void getSexComponentsIID | ( | double | value, |
| int * | d, | ||
| int * | m, | ||
| double * | s | ||
| ) |
| const char * indi_timestamp | ( | ) |
| double m2au | ( | double | m | ) |
| int numberFormat | ( | char * | buf, |
| const char * | format, | ||
| double | value | ||
| ) |
| double rad2as | ( | double | rad | ) |
| double range180 | ( | double | r | ) |
| double range24 | ( | double | r | ) |
| double range360 | ( | double | r | ) |
| double rangeDec | ( | double | r | ) |
| double rangeHA | ( | double | r | ) |
| double time_ns | ( | ) |
| 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.
| device | the device node. e.g. /dev/ttyS0 |
| bit_rate | bit rate |
| word_size | number of data bits, 7 or 8, USE 8 DATA BITS with modbus |
| parity | 0=no parity, 1=parity EVEN, 2=parity ODD |
| stop_bits | number of stop bits : 1 or 2 |
| fd | fd is set to the file descriptor value on success. |
| int tty_disconnect | ( | int | fd | ) |
| void tty_error_msg | ( | int | err_code, |
| char * | err_msg, | ||
| int | err_msg_len | ||
| ) |
| 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
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
| nsize | size of buf. If stop character is not encountered before nsize, the function aborts. |
| timeout | number of seconds to wait for terminal before a timeout error is issued. |
| nbytes_read | the number of bytes read. |
| int tty_nread_section_expanded | ( | int | fd, |
| char * | buf, | ||
| int | nsize, | ||
| char | stop_char, | ||
| long | timeout_seconds, | ||
| long | timeout_microseconds, | ||
| int * | nbytes_read | ||
| ) |
read buffer from terminal with a delimiter
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
| nsize | size of buf. If stop character is not encountered before nsize, the function aborts. |
| timeout | number of seconds to wait for terminal before a timeout error is issued. |
(Total Timeout is timeout_seconds + timeout_microseconds)
| timeout_microseconds | number of microseconds to wait for terminal before a timeout error is issued. |
| nbytes_read | the number of bytes read. |
| int tty_read | ( | int | fd, |
| char * | buf, | ||
| int | nbytes, | ||
| int | timeout, | ||
| int * | nbytes_read | ||
| ) |
read buffer from terminal
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| nbytes | number of bytes to read. |
| timeout | number of seconds to wait for terminal before a timeout error is issued. |
| nbytes_read | the number of bytes read. |
| 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
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
| timeout_seconds | number of seconds to wait for terminal before a timeout error is issued. |
(Total time = timeout_seconds + timeout_microseconds)
| timeout_microseconds | number of microseconds to wait for terminal before a timeout error is issued. |
(Total time = timeout_seconds + timeout_microseconds)
| nbytes_read | the number of bytes read. |
| int tty_read_section | ( | int | fd, |
| char * | buf, | ||
| char | stop_char, | ||
| int | timeout, | ||
| int * | nbytes_read | ||
| ) |
read buffer from terminal with a delimiter
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
| timeout | number of seconds to wait for terminal before a timeout error is issued. |
| nbytes_read | the number of bytes read. |
| 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
| fd | file descriptor |
| buf | pointer to store data. Must be initialized and big enough to hold data. |
| stop_char | if the function encounters stop_char then it stops reading and returns the buffer. |
| nsize | size of buf. If stop character is not encountered before nsize, the function aborts. |
| timeout_seconds | number of seconds to wait for terminal before a timeout error is issued. |
(Total Timeout is timeout_seconds + timeout_microseconds)
| timeout_microseconds | number of microseconds to wait for terminal before a timeout error is issued. |
(Total Timeout is timeout_seconds + timeout_microseconds)
| nbytes_read | the number of bytes read. |
| void tty_reset_udp_session | ( | int | fd, |
| int | only_if_timeout_happened | ||
| ) |
create new UDP session to prevent packet conflict
Create a new UDP connection socket (and thus new session) and replace existing descriptor with it (using dup2)
Note: it is effective if and only if tty_set_generic_udp_format is enabled
| fd | file descriptor of UDP socket |
| only_if_timeout_happened | of 0 create always, if 1 do it if there was IO timout on the socket in past, resets this flag |
| void tty_set_auto_reset_udp_session | ( | int | flag | ) |
automatically reset UDP session on write
Allows reset UDP session automatically if error/timeout or on every IO to prevent packet misshandling in protocols that do not mark request/response relation by design
| flag | 0 - disable, 1 - reset only if read timeout happened, 2 - every write regardless of timeout |
| void tty_set_debug | ( | int | debug | ) |
| int tty_timeout_microseconds | ( | int | fd, |
| long | timeout_seconds, | ||
| long | timeout_microseconds | ||
| ) |
| int tty_write | ( | int | fd, |
| const char * | buffer, | ||
| int | nbytes, | ||
| int * | nbytes_written | ||
| ) |
| int tty_write_string | ( | int | fd, |
| const char * | buffer, | ||
| int * | nbytes_written | ||
| ) |
|
extern |
|
extern |