36 #if defined(HAVE_LIBNOVA)
37 #include <libnova/julian_day.h>
38 #include <libnova/sidereal_time.h>
39 #include <libnova/ln_types.h>
40 #include <libnova/transform.h>
54 #include <sys/ioctl.h>
58 #include <sys/param.h>
59 #include <mach/clock.h>
60 #include <mach/mach.h>
64 #include <sys/param.h>
67 #if defined(BSD) && !defined(__GNU__)
69 #include <IOKit/serial/ioss.h>
71 #include <sys/ioctl.h>
75 #include <sys/ioctl.h>
86 #include <sys/param.h>
96 #define snprintf _snprintf
99 #pragma warning(disable : 4996)
104 static int tty_debug = 0;
105 static int tty_gemini_udp_format = 0;
106 static int tty_generic_udp_format = 0;
107 static int tty_sequence_number = 1;
108 static int tty_clear_trailing_lf = 0;
110 #if defined(HAVE_LIBNOVA)
115 if (strptime(timestr,
"%Y/%m/%dT%H:%M:%S", &utm))
117 ln_get_date_from_tm(&utm, iso_date);
121 if (strptime(timestr,
"%Y-%m-%dT%H:%M:%S", &utm))
123 ln_get_date_from_tm(&utm, iso_date);
141 int fs_sexa(
char *out,
double a,
int w,
int fracbase)
157 n = (
unsigned long)(a * fracbase + 0.5);
165 out += snprintf(out,
MAXINDIFORMAT,
"%*d", w, isneg ? -d : d);
171 m = f / (fracbase / 60);
175 out += snprintf(out,
MAXINDIFORMAT,
":%02d.%1d", f / 10, f % 10);
178 m = f / (fracbase / 60);
179 s = f % (fracbase / 60);
183 m = f / (fracbase / 60);
184 s = f % (fracbase / 60);
185 out += snprintf(out,
MAXINDIFORMAT,
":%02d:%02d.%1d", m, s / 10, s % 10);
188 m = f / (fracbase / 60);
189 s = f % (fracbase / 60);
190 out += snprintf(out,
MAXINDIFORMAT,
":%02d:%02d.%02d", m, s / 100, s % 100);
193 printf(
"fs_sexa: unknown fracbase: %d\n", fracbase);
197 return (
int)(out - out0);
210 double a = 0, b = 0, c = 0;
213 uint8_t isNegative=0;
217 strncpy(str, str0,
sizeof(str) - 1);
218 str[
sizeof(str) - 1] =
'\0';
242 r = sscanf(str,
"%lf%*[^0-9]%lf%*[^0-9]%lf", &a, &b, &c);
244 indi_locale_C_numeric_pop(orig);
248 *dp = a + b / 60 + c / 3600;
256 *d = (int32_t)fabs(value);
257 *m = (int32_t)((fabs(value) - *d) * 60.0);
258 *s = (int32_t)rint(((fabs(value) - *d) * 60.0 - *m) * 60.0);
279 *d = (int32_t)fabs(value);
280 *m = (int32_t)((fabs(value) - *d) * 60.0);
281 *s = (double)(((fabs(value) - *d) * 60.0 - *m) * 60.0);
293 if (sscanf(format,
"%%%d.%d%c", &w, &f, &m) == 3 && m ==
'm')
298 case 9: s = 360000;
break;
299 case 8: s = 36000;
break;
300 case 6: s = 3600;
break;
301 case 5: s = 600;
break;
302 default: s = 60;
break;
304 return (
fs_sexa(buf, value, w - f, s));
322 vfprintf(stderr, fmt, ap);
329 #if defined(HAVE_TIMESPEC_GET)
330 timespec_get(&ts, TIME_UTC);
331 #elif defined(HAVE_CLOCK_GETTIME)
332 clock_gettime(CLOCK_REALTIME, &ts);
333 #elif defined(__APPLE__)
336 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
337 clock_get_time(cclock, &mts);
338 mach_port_deallocate(mach_task_self(), cclock);
339 ts.tv_sec = mts.tv_sec;
340 ts.tv_nsec = mts.tv_nsec;
342 #error "Unsupported platform"
344 return (
double)ts.tv_sec+(double)(ts.tv_nsec%1000000000)/1000000000.0;
356 strftime(ts,
sizeof(ts),
"%Y-%m-%dT%H:%M:%S", tp);
367 tty_gemini_udp_format = enabled;
372 tty_generic_udp_format = enabled;
377 tty_clear_trailing_lf = enabled;
387 #if defined(_WIN32) || defined(ANDROID)
402 FD_SET(
fd, &readout);
405 tv.tv_sec = timeout_seconds;
406 tv.tv_usec = timeout_microseconds;
409 retval = select(
fd + 1, &readout, NULL, NULL, &tv);
415 else if (retval == -1)
424 int tty_write(
int fd,
const char *buf,
int nbytes,
int *nbytes_written)
429 int geminiBuffer[66]={0};
430 char *
buffer = (
char *)buf;
432 if (tty_gemini_udp_format)
434 buffer = (
char*)geminiBuffer;
435 geminiBuffer[0] = ++tty_sequence_number;
437 memcpy((
char *)&geminiBuffer[2], buf, nbytes);
451 for (i = 0; i < nbytes; i++)
452 IDLog(
"%s: buffer[%d]=%#X (%c)\n", __FUNCTION__, i, (
unsigned char)buf[i], buf[i]);
457 bytes_w = write(
fd,
buffer + (*nbytes_written), nbytes);
462 *nbytes_written += bytes_w;
466 if (tty_gemini_udp_format)
467 *nbytes_written -= 9;
477 nbytes = (int)strlen(buf);
482 int tty_read(
int fd,
char *buf,
int nbytes,
int timeout,
int *nbytes_read)
487 int tty_read_expanded(
int fd,
char *buf,
int nbytes,
long timeout_seconds,
long timeout_microseconds,
int *nbytes_read)
496 int numBytesToRead = nbytes;
505 IDLog(
"%s: Request to read %d bytes with %ld s, %ld us timeout for fd %d\n", __FUNCTION__, nbytes, timeout_seconds, timeout_microseconds,
fd);
507 char geminiBuffer[257]={0};
510 if (tty_gemini_udp_format)
512 numBytesToRead = nbytes + 8;
516 while (numBytesToRead > 0)
521 bytesRead = read(
fd,
buffer + (*nbytes_read), ((uint32_t)numBytesToRead));
528 IDLog(
"%d bytes read and %d bytes remaining...\n", bytesRead, numBytesToRead - bytesRead);
530 for (i = *nbytes_read; i < (*nbytes_read + bytesRead); i++)
531 IDLog(
"%s: buffer[%d]=%#X (%c)\n", __FUNCTION__, i, (
unsigned char)buf[i], buf[i]);
534 if (*nbytes_read == 0 && tty_clear_trailing_lf && *
buffer == 0x0A)
537 IDLog(
"%s: Cleared LF char left in buf\n", __FUNCTION__);
543 *nbytes_read += bytesRead;
544 numBytesToRead -= bytesRead;
548 if (tty_gemini_udp_format)
550 int *intSizedBuffer = (
int *)geminiBuffer;
551 if (intSizedBuffer[0] != tty_sequence_number)
554 return tty_read_expanded(
fd, buf, nbytes, timeout_seconds, timeout_microseconds, nbytes_read);
558 memcpy(buf, geminiBuffer+8, *nbytes_read);
577 char readBuffer[257]={0};
586 uint8_t *read_char = 0;
589 IDLog(
"%s: Request to read until stop char '%#02X' with %ld s %ld us timeout for fd %d\n", __FUNCTION__, stop_char, timeout_seconds, timeout_microseconds,
fd);
591 if (tty_gemini_udp_format)
593 bytesRead = read(
fd, readBuffer, 255);
598 int *intSizedBuffer = (
int *)readBuffer;
599 if (intSizedBuffer[0] != tty_sequence_number)
605 for (
int index = 8; index < bytesRead; index++)
609 if (*(readBuffer+index) == stop_char)
611 strncpy(buf, readBuffer+8, *nbytes_read);
616 else if (tty_generic_udp_format)
618 bytesRead = read(
fd, readBuffer, 255);
621 for (
int index = 0; index < bytesRead; index++)
625 if (*(readBuffer+index) == stop_char)
627 strncpy(buf, readBuffer, *nbytes_read);
639 read_char = (uint8_t*)(buf + *nbytes_read);
640 bytesRead = read(
fd, read_char, 1);
646 IDLog(
"%s: buffer[%d]=%#X (%c)\n", __FUNCTION__, (*nbytes_read), *read_char, *read_char);
648 if (!(tty_clear_trailing_lf && *read_char == 0X0A && *nbytes_read == 0))
652 IDLog(
"%s: Cleared LF char left in buf\n", __FUNCTION__);
655 if (*read_char == stop_char) {
676 if (tty_gemini_udp_format || tty_generic_udp_format)
682 uint8_t *read_char = 0;
683 memset(buf, 0, nsize);
686 IDLog(
"%s: Request to read until stop char '%#02X' with %d timeout for fd %d\n", __FUNCTION__, stop_char, timeout,
fd);
693 read_char = (uint8_t*)(buf + *nbytes_read);
694 bytesRead = read(
fd, read_char, 1);
700 IDLog(
"%s: buffer[%d]=%#X (%c)\n", __FUNCTION__, (*nbytes_read), *read_char, *read_char);
702 if (!(tty_clear_trailing_lf && *read_char == 0X0A && *nbytes_read == 0))
706 IDLog(
"%s: Cleared LF char left in buf\n", __FUNCTION__);
709 if (*read_char == stop_char)
711 else if (*nbytes_read >= nsize)
718 #if defined(BSD) && !defined(__GNU__)
720 int tty_connect(
const char *
device,
int bit_rate,
int word_size,
int parity,
int stop_bits,
int *
fd)
732 t_fd = open(
device, O_RDWR | O_NOCTTY | O_NONBLOCK);
744 if (ioctl(t_fd, TIOCEXCL) == -1)
753 if (fcntl(t_fd, F_SETFL, 0) == -1)
777 case 0: bps = B0;
break;
778 case 50: bps = B50;
break;
779 case 75: bps = B75;
break;
780 case 110: bps = B110;
break;
781 case 134: bps = B134;
break;
782 case 150: bps = B150;
break;
783 case 200: bps = B200;
break;
784 case 300: bps = B300;
break;
785 case 600: bps = B600;
break;
786 case 1200: bps = B1200;
break;
787 case 1800: bps = B1800;
break;
788 case 2400: bps = B2400;
break;
789 case 4800: bps = B4800;
break;
790 case 9600: bps = B9600;
break;
791 case 19200: bps = B19200;
break;
792 case 38400: bps = B38400;
break;
793 case 57600: bps = B57600;
break;
794 case 115200: bps = B115200;
break;
795 case 230400: bps = B230400;
break;
796 #if !defined(__APPLE__) && !defined(__FreeBSD__)
797 case 460800: bps = B460800;
break;
798 case 576000: bps = B576000;
break;
799 case 921600: bps = B921600;
break;
802 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid bit rate.", bit_rate) < 0)
818 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid data bit count.", word_size) < 0)
838 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid parity selection value.", parity) < 0)
855 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid stop bit count.", stop_bits) < 0)
863 #if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
869 speed_t speed = 14400;
870 if (ioctl(t_fd, IOSSIOSPEED, &speed) == -1)
872 IDLog(
"Error calling ioctl(..., IOSSIOSPEED, ...) - %s(%d).\n", strerror(
errno),
errno);
886 if (ioctl(t_fd, TIOCSDTR) == -1)
891 if (ioctl(t_fd, TIOCCDTR) == -1)
896 handshake = TIOCM_DTR | TIOCM_RTS | TIOCM_CTS | TIOCM_DSR;
897 if (ioctl(t_fd, TIOCMSET, &handshake) == -1)
906 if (ioctl(t_fd, TIOCMGET, &handshake) == -1)
912 IDLog(
"Handshake lines currently set to %d\n", handshake);
914 #if defined(MAC_OS_X_VERSION_10_3) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3)
915 unsigned long mics = 1UL;
923 if (ioctl(t_fd, IOSSDATALAT, &mics) == -1)
958 int ignore_exclusive_close = strstr(
device,
"rfcomm") || strstr(
device,
"Bluetooth") || strstr(
device,
"virtualcom");
962 for (i = 0 ; i < 3 ; i++)
965 t_fd = open(
device, O_RDWR | O_NOCTTY | (ignore_exclusive_close ? 0 : O_CLOEXEC));
984 #if !defined(__CYGWIN__)
987 if (ignore_exclusive_close == 0 && ioctl(t_fd, TIOCEXCL) == -1)
989 perror(
"tty_connect: Error setting TIOCEXC.");
998 perror(
"tty_connect: failed getting tty attributes.");
1007 case 0: bps = B0;
break;
1008 case 50: bps = B50;
break;
1009 case 75: bps = B75;
break;
1010 case 110: bps = B110;
break;
1011 case 134: bps = B134;
break;
1012 case 150: bps = B150;
break;
1013 case 200: bps = B200;
break;
1014 case 300: bps = B300;
break;
1015 case 600: bps = B600;
break;
1016 case 1200: bps = B1200;
break;
1017 case 1800: bps = B1800;
break;
1018 case 2400: bps = B2400;
break;
1019 case 4800: bps = B4800;
break;
1020 case 9600: bps = B9600;
break;
1021 case 19200: bps = B19200;
break;
1022 case 38400: bps = B38400;
break;
1023 case 57600: bps = B57600;
break;
1024 case 115200: bps = B115200;
break;
1025 case 230400: bps = B230400;
break;
1026 case 460800: bps = B460800;
break;
1027 case 576000: bps = B576000;
break;
1028 case 921600: bps = B921600;
break;
1030 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid bit rate.", bit_rate) < 0)
1039 perror(
"tty_connect: failed setting bit rate.");
1048 tty_setting.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | HUPCL | CRTSCTS);
1060 fprintf(stderr,
"Default\n");
1061 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid data bit count.", word_size) < 0)
1083 fprintf(stderr,
"Default1\n");
1084 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid parity selection value.", parity) < 0)
1102 fprintf(stderr,
"Default2\n");
1103 if (snprintf(msg,
sizeof(msg),
"tty_connect: %d is not a valid stop bit count.", stop_bits) < 0)
1114 tty_setting.c_iflag &= ~(PARMRK | ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON | IXANY);
1123 tty_setting.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG | IEXTEN | NOFLSH | TOSTOP);
1131 tcflush(t_fd, TCIOFLUSH);
1134 perror(
"tty_connect: failed setting attributes on serial port.");
1157 tcflush(
fd, TCIOFLUSH);
1172 snprintf(err_msg, err_msg_len,
"No Error");
1176 snprintf(err_msg, err_msg_len,
"Read Error: %s", strerror(
errno));
1180 snprintf(err_msg, err_msg_len,
"Write Error: %s", strerror(
errno));
1184 snprintf(err_msg, err_msg_len,
"Select Error: %s", strerror(
errno));
1188 snprintf(err_msg, err_msg_len,
"Timeout error");
1192 if (
errno == EACCES)
1193 snprintf(err_msg, err_msg_len,
1194 "Port failure Error: %s. Try adding your user to the dialout group and restart (sudo adduser "
1198 snprintf(err_msg, err_msg_len,
"Port failure Error: %s. Check if device is connected to this port.",
1204 snprintf(err_msg, err_msg_len,
"Parameter error");
1208 snprintf(err_msg, err_msg_len,
"%s", strerror(
errno));
1212 snprintf(err_msg, err_msg_len,
"Read overflow");
1216 snprintf(err_msg, err_msg_len,
"Port is busy");
1220 snprintf(err_msg, err_msg_len,
"Error: unrecognized error code");
1257 if ((decdegrees >= 270.0) && (decdegrees <= 360.0))
1258 return (decdegrees - 360.0);
1259 if ((decdegrees >= 180.0) && (decdegrees < 270.0))
1260 return (180.0 - decdegrees);
1261 if ((decdegrees >= 90.0) && (decdegrees < 180.0))
1262 return (180.0 - decdegrees);
1266 #if defined(HAVE_LIBNOVA)
1269 return range24(ln_get_apparent_sidereal_time(ln_get_julian_from_sys()) + longitude / 15.0);
1272 void get_hrz_from_equ(
struct ln_equ_posn *
object,
struct ln_lnlat_posn *observer,
double JD,
struct ln_hrz_posn *position)
1274 ln_get_hrz_from_equ(
object, observer, JD, position);
1275 position->az -= 180;
1276 if (position->az < 0)
1277 position->az += 360;
1280 void get_equ_from_hrz(
struct ln_hrz_posn *
object,
struct ln_lnlat_posn *observer,
double JD,
struct ln_equ_posn *position)
1282 struct ln_hrz_posn libnova_object;
1283 libnova_object.az =
object->az + 180;
1284 if (libnova_object.az > 360)
1285 libnova_object.az -= 360;
1286 libnova_object.alt =
object->alt;
1288 ln_get_equ_from_hrz(&libnova_object, observer, JD, position);
1295 double HA = sideral_time -
ra;
1303 Dec *= M_PI / 180.0;
1304 Lat *= M_PI / 180.0;
1305 alt = asin(sin(Dec) * sin(Lat) + cos(Dec) * cos(Lat) * cos(Ha));
1306 az = acos((sin(Dec) - sin(alt)*sin(Lat)) / (cos(alt) * cos(Lat)));
1307 alt *= 180.0 / M_PI;
1317 Lat *= M_PI / 180.0;
1325 Alt *= M_PI / 180.0;
1327 Lat *= M_PI / 180.0;
1328 double ret = cos(Lat) * cos(Az) / cos(Alt);
1329 ret *= 180.0 / M_PI;
1345 return as * M_PI / (60.0*60.0*12.0);
1350 return rad * (60.0*60.0*12.0) / M_PI;
1355 return parallax_radius / sin(
as2rad(parsecs));
1365 double delta_mag = 0;
1366 for(
int l = 0; l < spectrum_size; l++) {
1367 delta_mag += spectrum[l] * mag_ratio * ref_spectrum[l] / spectrum[l];
1369 delta_mag /= spectrum_size;
1375 return delta_mag * ref_size;
1385 return orbit_radius*pow(star_drift*orbit_radius, 3)*3*star_mass;
1390 return pow(dropoff_ratio*pow(star_size, 2), 0.5);
1393 double calc_photon_flux(
double rel_magnitude,
double filter_bandwidth,
double wavelength,
double steradian)
1395 return pow(10, rel_magnitude*-0.4)*(
LUMEN(wavelength)*steradian*filter_bandwidth);
1398 double calc_rel_magnitude(
double photon_flux,
double filter_bandwidth,
double wavelength,
double steradian)
1400 return pow(10, 1.0/(photon_flux/(
LUMEN(wavelength)*steradian*filter_bandwidth)))/-0.4;
1405 return sqrt(delta_dist) * delta_mag;
1411 alt *= M_PI / 180.0;
1412 uvresult[0] = (baseline[0] * sin(az) + baseline[1] * cos(az));
1413 uvresult[1] = (baseline[1] * sin(alt) * sin(az) - baseline[0] * sin(alt) * cos(az) + baseline[2] * cos(alt));
1414 uvresult[0] *=
AIRY / wavelength;
1415 uvresult[1] *=
AIRY / wavelength;
1421 alt *= M_PI / 180.0;
1422 return cos(az) * baseline[1] * cos(alt) - baseline[0] * sin(az) * cos(alt) + sin(alt) * baseline[2];
1425 #if defined(_MSC_VER)
1427 #pragma warning(pop)
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
double estimate_secondary_size(double star_size, double dropoff_ratio)
estimate the size of an object occulting a star in star_size units.
void tty_set_generic_udp_format(int enabled)
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 a...
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.
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 o...
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
void getSexComponentsIID(double value, int *d, int *m, double *s)
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
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.
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 determi...
void tty_set_debug(int debug)
tty_set_debug Enable or disable debug which prints verbose information.
double estimate_distance(double parsecs, double parallax_radius)
estimate_distance Convert parallax arcseconds into meters
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 di...
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
double estimate_field_rotation(double HA, double rate)
estimate_field_rotation Returns an estimation of the field rotation rate of the object
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.
int tty_disconnect(int fd)
Closes a tty connection and flushes the bus.
void IDLog(const char *fmt,...)
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
int tty_timeout_microseconds(int fd, long timeout_seconds, long timeout_microseconds)
double rangeHA(double r)
rangeHA Limits the hour angle value to be between -12 —> 12
void getSexComponents(double value, int *d, int *m, int *s)
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
double calc_star_mass(double delta_mag, double ref_size)
double m2au(double m)
m2au Convert meters into astronomical units
const char * indi_timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
double range24(double r)
range24 Limits a number to be between 0-24 range.
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_timeout(int fd, int timeout)
double as2rad(double as)
as2rad Convert arcseconds into radians
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
double rangeDec(double decdegrees)
rangeDec Limits declination value to be in -90 to 90 range.
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
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
double time_ns()
Get a unix timestamp with nanosecond precision.
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
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 numberFormat(char *buf, const char *format, double value)
Fill buffer with properly formatted INumber string.
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_read_expanded(int fd, char *buf, int nbytes, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
void tty_clr_trailing_read_lf(int enabled)
void tty_set_gemini_udp_format(int enabled)
double get_local_hour_angle(double sideral_time, double ra)
get_local_hour_angle Returns local hour angle of an object
double estimate_geocentric_elevation(double Lat, double El)
estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation
double rad2as(double rad)
rad2as Convert radians into arcseconds
Implementations for common driver routines.
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sideral time given longitude and system clock.
#define LUMEN(wavelength)
#define DOPPLER(shift, speed)
#define EARTHRADIUSEQUATORIAL
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.
#define REDSHIFT(wavelength, reference)
int extractISOTime(const char *timestr, struct ln_date *iso_date)
Extract ISO 8601 time and store it in a tm struct.
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
Interface to the reference INDI C API device implementation on the Device Driver side.
std::vector< uint8_t > buffer
@ error
throw a parse_error exception in case of a tag
struct termios tty_setting