more fixes, not all yet

This commit is contained in:
Edward Emelianov
2026-10-15 00:56:33 +03:00
parent 6916e0bcd4
commit 98a84fb7df
8 changed files with 129 additions and 85 deletions

View File

@@ -24,7 +24,8 @@
#include "angles.h" #include "angles.h"
static placeData_t place = {.slong = -0.7232763200, .slat = 0.7618977414, .salt = 2070.}; // in ERFA library east longitudes are POSITIVE (but in 10micron they are negative)
static placeData_t place = {.slong = 0.7232763200, .slat = 0.7618977414, .salt = 2070.};
static almDut_t AlmDut = {0}; static almDut_t AlmDut = {0};
// set/get polar/DUT1 data // set/get polar/DUT1 data
@@ -82,6 +83,7 @@ void getPlaceData(placeData_t *pd){
*pd = place; *pd = place;
} }
#if 0
/** /**
* @brief ra2str - convert RA to string form "HH:MM:SS.SS" * @brief ra2str - convert RA to string form "HH:MM:SS.SS"
* @param ra - RA (hours) * @param ra - RA (hours)
@@ -117,6 +119,7 @@ char *dec2str(double dec, char buf[RADEC_STR_MAXLEN]){
buf[RADEC_STR_MAXLEN-1] = 0; buf[RADEC_STR_MAXLEN-1] = 0;
return buf; return buf;
} }
#endif
// normalize azimuth to [0, 360.) and z.d. to [0, 90] // normalize azimuth to [0, 360.) and z.d. to [0, 90]
// if z>90 || z<-90 return false; if z < 0 rotate azimuth to 180 // if z>90 || z<-90 return false; if z < 0 rotate azimuth to 180
@@ -239,34 +242,38 @@ void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime){
} }
/** /**
* @brief r2sHMS - convert angle in radians into string "'HH:MM:SS.SS'" * @brief r2sHMS - convert angle in radians into string "HH:MM:SS.SS"
* @param radians - angle * @param radians - angle
* @param hms (o) - string * @param buf (o) - string
* @param len - length of hms
*/ */
void r2sHMS(double radians, char *hms, int len){ void r2sHMS(double radians, char buf[RADEC_STR_MAXLEN]){
char pm; char pm;
int i[4]; int i[4];
eraA2tf(2, radians, &pm, i); eraA2tf(2, radians, &pm, i);
snprintf(hms, len, "'%c%02d:%02d:%02d.%02d'", pm, i[0],i[1],i[2],i[3]); size_t l = snprintf(buf, RADEC_STR_MAXLEN, "%c%02d:%02d:%02d.%02d", pm, i[0],i[1],i[2],i[3]);
if(l >= RADEC_STR_MAXLEN) buf[RADEC_STR_MAXLEN-1] = 0;
} }
/** /**
* @brief r2sDMS - convert angle in radians into string "'DD:MM:SS.S'" * @brief r2sDMS - convert angle in radians into string "DD:MM:SS.S"
* @param radians - angle * @param radians - angle
* @param dms (o) - string * @param buf (o) - string
* @param len - length of hms
*/ */
void r2sDMS(double radians, char *dms, int len){ void r2sDMS(double radians, char buf[RADEC_STR_MAXLEN]){
char pm; char pm;
int i[4]; int i[4];
eraA2af(1, radians, &pm, i); eraA2af(1, radians, &pm, i);
snprintf(dms, len, "%c%02d:%02d:%02d.%d", pm, i[0],i[1],i[2],i[3]); size_t l = snprintf(buf, RADEC_STR_MAXLEN, "%c%02d:%02d:%02d.%d", pm, i[0],i[1],i[2],i[3]);
if(l >= RADEC_STR_MAXLEN) buf[RADEC_STR_MAXLEN-1] = 0;
} }
// the same, but argument in degrees // the same, but argument in degrees
void d2sDMS(double degrees, char *dms, int len){ void d2sDMS(double degrees, char buf[RADEC_STR_MAXLEN]){
double radians = DEG2RAD(degrees); double radians = DEG2RAD(degrees);
return r2sDMS(radians, dms, len); r2sDMS(radians, buf);
}
void h2sHMS(double hours, char buf[RADEC_STR_MAXLEN]){
double radians = HRS2RAD(hours);
r2sHMS(radians, buf);
} }
/** /**

View File

@@ -64,8 +64,10 @@ typedef struct{
double py; double py;
} almDut_t; } almDut_t;
#if 0
char *ra2str(double ra, char buf[RADEC_STR_MAXLEN]); char *ra2str(double ra, char buf[RADEC_STR_MAXLEN]);
char *dec2str(double dec, char buf[RADEC_STR_MAXLEN]); char *dec2str(double dec, char buf[RADEC_STR_MAXLEN]);
#endif
bool str2coord(const char *str, double *val); bool str2coord(const char *str, double *val);
bool normAZ(double *a, double *z); bool normAZ(double *a, double *z);
void norm_RA(double *ra); void norm_RA(double *ra);
@@ -77,9 +79,10 @@ void hor2eq(horizCrds_t *h, polarCrds_t *pc, double sidTime);
void eq2horH(polarCrds_t *pc, horizCrds_t *h); void eq2horH(polarCrds_t *pc, horizCrds_t *h);
void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime); void eq2hor(polarCrds_t *pc, horizCrds_t *h, double sidTime);
void r2sHMS(double radians, char *hms, int len); void r2sHMS(double radians, char buf[RADEC_STR_MAXLEN]);
void r2sDMS(double radians, char *hms, int len); void r2sDMS(double radians, char buf[RADEC_STR_MAXLEN]);
void d2sDMS(double degrees, char *dms, int len); void d2sDMS(double degrees, char buf[RADEC_STR_MAXLEN]);
void h2sHMS(double hours, char buf[RADEC_STR_MAXLEN]);
bool get_MJDt(struct timeval *tval, sMJD_t *MJD); bool get_MJDt(struct timeval *tval, sMJD_t *MJD);
bool get_LST(sMJD_t *mjd, double *LST); bool get_LST(sMJD_t *mjd, double *LST);

View File

@@ -108,22 +108,25 @@ void wrhdr(fitsheader_t *HDR){
return; return;
} }
fchmod(fd, 0644); fchmod(fd, 0644);
char val[23]; #define VALLEN 22
val[22] = 0; #define CMNTLEN 51
char val[VALLEN+1];
char ang[RADEC_STR_MAXLEN], cmnt[CMNTLEN+1];
val[VALLEN] = 0, cmnt[CMNTLEN] = 0;
#define WRHDR(k, v, c) do{if(printhdr(fd, k, v, c)){goto returning;}}while(0) #define WRHDR(k, v, c) do{if(printhdr(fd, k, v, c)){goto returning;}}while(0)
WRHDR("TIMESYS", "'UTC'", "Time system"); WRHDR("TIMESYS", "'UTC'", "Time system");
WRHDR("ORIGIN", "'SAO RAS'", "Organization responsible for the data"); WRHDR("ORIGIN", "'SAO RAS'", "Organization responsible for the data");
WRHDR("MOUNTNAM", HDR->mountname, "Mount name"); WRHDR("MOUNTNAM", HDR->mountname, "Mount name");
if(fabs(HDR->dut.px) > FLT_EPSILON){ if(fabs(HDR->dut.px) > FLT_EPSILON){
snprintf(val, 22, "%.10f", HDR->dut.px); snprintf(val, VALLEN, "%.10f", HDR->dut.px);
WRHDR("POLARX", val, "IERS pole X coordinate, arcsec"); WRHDR("POLARX", val, "IERS pole X coordinate, arcsec");
} }
if(fabs(HDR->dut.py) > FLT_EPSILON){ if(fabs(HDR->dut.py) > FLT_EPSILON){
snprintf(val, 22, "%.10f", HDR->dut.py); snprintf(val, VALLEN, "%.10f", HDR->dut.py);
WRHDR("POLARY", val, "IERS pole Y coordinate, arcsec"); WRHDR("POLARY", val, "IERS pole Y coordinate, arcsec");
} }
if(fabs(HDR->dut.DUT1) > FLT_EPSILON){ if(fabs(HDR->dut.DUT1) > FLT_EPSILON){
snprintf(val, 22, "%.10f", HDR->dut.DUT1); snprintf(val, VALLEN, "%.10f", HDR->dut.DUT1);
WRHDR("DUT1", val, "IERS `UT1-UTC`, sec"); WRHDR("DUT1", val, "IERS `UT1-UTC`, sec");
} }
polarCrds_t polar; polarCrds_t polar;
@@ -131,75 +134,98 @@ void wrhdr(fitsheader_t *HDR){
double pt = mount_getInpCoords(&polar), ht = mount_getInpHor(&horiz); double pt = mount_getInpCoords(&polar), ht = mount_getInpHor(&horiz);
if(pt > ht){ // horcrds is older -> show polar if(pt > ht){ // horcrds is older -> show polar
if(curtime - pt < COORDS_OLD_T){ if(curtime - pt < COORDS_OLD_T){
snprintf(val, 22, "%.10f", RAD2DEG(polar.ra)); snprintf(val, VALLEN, "%.10f", RAD2DEG(polar.ra));
WRHDR("INPRA", val, "Input RA, degrees"); r2sHMS(polar.ra, ang);
snprintf(val, 22, "%.10f", RAD2DEG(polar.dec)); snprintf(cmnt, CMNTLEN, "Input RA, deg. (%s)", ang);
WRHDR("INPDEC", val, "Input DEC, degrees"); WRHDR("INPRA", val, cmnt);
snprintf(val, VALLEN, "%.10f", RAD2DEG(polar.dec));
r2sDMS(polar.dec, ang);
snprintf(cmnt, CMNTLEN, "Input DEC, deg. (%s)", ang);
WRHDR("INPDEC", val, cmnt);
} }
}else{ // show horiz }else{ // show horiz
if(curtime - ht < COORDS_OLD_T){ if(curtime - ht < COORDS_OLD_T){
snprintf(val, 22, "%.10f", RAD2DEG(horiz.az)); snprintf(val, VALLEN, "%.10f", RAD2DEG(horiz.az));
WRHDR("INPAZ", val, "Input Azimuth, degrees"); r2sDMS(horiz.az, ang);
snprintf(val, 22, "%.10f", RAD2DEG(horiz.zd)); snprintf(cmnt, CMNTLEN, "Input Azimuth, deg. (%s)", ang);
WRHDR("INPZD", val, "Input Zenith dist., degrees"); WRHDR("INPAZ", val, cmnt);
snprintf(val, VALLEN, "%.10f", RAD2DEG(horiz.zd));
r2sDMS(horiz.zd, ang);
snprintf(cmnt, CMNTLEN, "Input Zenith dist., deg. (%s)", ang);
WRHDR("INPZD", val, cmnt);
} }
} }
if(curtime - mount_getTagCoords(&polar) < COORDS_OLD_T){ if(curtime - mount_getTagCoords(&polar) < COORDS_OLD_T){
snprintf(val, 22, "%.10f", RAD2DEG(polar.ra)); snprintf(val, VALLEN, "%.10f", RAD2DEG(polar.ra));
WRHDR("TAGRA", val, "Target RA, degrees"); r2sHMS(polar.ra, ang);
snprintf(val, 22, "%.10f", RAD2DEG(polar.dec)); snprintf(cmnt, CMNTLEN, "Target RA, deg. (%s)", ang);
WRHDR("TAGDEC", val, "Target DEC, degrees"); WRHDR("TAGRA", val, cmnt);
snprintf(val, VALLEN, "%.10f", RAD2DEG(polar.dec));
r2sDMS(polar.dec, ang);
snprintf(cmnt, CMNTLEN, "Target DEC, deg. (%s)", ang);
WRHDR("TAGDEC", val, cmnt);
} }
if(poweredON){ if(poweredON){
snprintf(val, 22, "%.10f", RAD2HRS(HDR->polar.ra)); // convert RA to degrees snprintf(val, VALLEN, "%.10f", RAD2HRS(HDR->polar.ra)); // convert RA to degrees
WRHDR("RA", val, "Telescope right ascension, current epoch, deg"); r2sHMS(HDR->polar.ra, ang);
snprintf(val, 22, "%.10f", RAD2HRS(eraAnp(HDR->sidtime - HDR->polar.ra))); // hour angle snprintf(cmnt, CMNTLEN, "Telescope Right Ascension, deg. (%s)", ang);
WRHDR("HA", val, "Telescope hour angle, deg"); WRHDR("RA", val, cmnt);
snprintf(val, 22, "%.10f", RAD2DEG(HDR->polar.dec)); double ha = eraAnp(HDR->sidtime - HDR->polar.ra);
WRHDR("DEC", val, "Telescope declination, current epoch, deg"); snprintf(val, VALLEN, "%.10f", RAD2HRS(ha)); // hour angle
snprintf(val, 22, "%.10f", RAD2DEG(HDR->altaz.az)); r2sHMS(ha, ang);
WRHDR("AZ", val, "Telescope azimuth, deg"); snprintf(cmnt, CMNTLEN, "Telescope Hour Angle, deg. (%s)", ang);
snprintf(val, 22, "%.10f", RAD2DEG(HDR->altaz.zd)); WRHDR("HA", val, cmnt);
WRHDR("ZD", val, "Telescope zenith distance, deg"); snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->polar.dec));
r2sDMS(HDR->polar.dec, ang);
snprintf(cmnt, CMNTLEN, "Telescope Declination, deg. (%s)", ang);
WRHDR("DEC", val, cmnt);
snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->altaz.az));
r2sDMS(HDR->altaz.az, ang);
snprintf(cmnt, CMNTLEN, "Telescope Azimuth, deg. (%s)", ang);
WRHDR("AZ", val, cmnt);
snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->altaz.zd));
r2sDMS(HDR->altaz.zd, ang);
snprintf(cmnt, CMNTLEN, "Telescope Zenith Distance, deg. (%s)", ang);
WRHDR("ZD", val, cmnt);
} }
WRHDR("TELSTAT", mount_status_str(HDR->status), "Telescope mount status"); WRHDR("TELSTAT", mount_status_str(HDR->status), "Telescope mount status");
double mjd; double epoch;
mount_getInpEpoch(&mjd); mount_getInpEpoch(&epoch);
if(mjd > 0.) snprintf(val, 22, "%.10f", 2000.+(mjd - ERFA_DJM00)/365.25); // calculate EPOCH/EQUINOX if(epoch > 0.) snprintf(val, VALLEN, "%.8f", epoch); // calculate EPOCH/EQUINOX
else snprintf(val, 22, "%.10f", 2000.+(HDR->MJD.MJD - ERFA_DJM00)/365.25); else snprintf(val, VALLEN, "%.10f", 2000.+(HDR->MJD.MJD - ERFA_DJM00)/365.25);
WRHDR("INPEQUIN", val, "Equinox of input celestial coordinate system"); WRHDR("INPEQUIN", val, "Equinox of input celestial coordinate system");
if(poweredON){ if(poweredON){
snprintf(val, 22, "%.10f", 2000.+(HDR->MJD.MJD - ERFA_DJM00)/365.25); // telescope coordinates: JNOW snprintf(val, VALLEN, "%.10f", 2000.+(HDR->MJD.MJD - ERFA_DJM00)/365.25); // telescope coordinates: JNOW
WRHDR("EQUINOX", val, "Equinox of telescope celestial coordinate sys."); WRHDR("EQUINOX", val, "Equinox of telescope celestial coordinate sys.");
snprintf(val, 22, "%.10f", HDR->MJD.MJD); snprintf(val, VALLEN, "%.10f", HDR->MJD.MJD);
WRHDR("MJD", val, "Modified Julian date of file creation"); WRHDR("MJD", val, "Modified Julian date of file creation");
if(*HDR->pierside) WRHDR("PIERSIDE", HDR->pierside, "Pier side of telescope mount"); if(*HDR->pierside) WRHDR("PIERSIDE", HDR->pierside, "Pier side of telescope mount");
} }
snprintf(val, 22, "%.1f", HDR->place.salt); snprintf(val, VALLEN, "%.1f", HDR->place.salt);
WRHDR("ELEVAT", val, "Elevation of site over the sea level"); WRHDR("ELEVAT", val, "Elevation of site over the sea level");
snprintf(val, 22, "%.10f", RAD2DEG(HDR->place.slong)); snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->place.slong));
WRHDR("LONGITUD", val, "Geo longitude of site (east negative)"); WRHDR("LONGITUD", val, "Geo longitude of site (east negative)");
snprintf(val, 22, "%.10f", RAD2DEG(HDR->place.slat)); snprintf(val, VALLEN, "%.10f", RAD2DEG(HDR->place.slat));
WRHDR("LATITUDE", val, "Geo latitude of site (south negative)"); WRHDR("LATITUDE", val, "Geo latitude of site (south negative)");
snprintf(val, 22, "%.6f", RAD2HRS(HDR->sidtime)); snprintf(val, VALLEN, "%.6f", RAD2HRS(HDR->sidtime));
WRHDR("LSTEND", val, "Local sidereal time of file creation"); WRHDR("LSTEND", val, "Local sidereal time of file creation");
/* Weather data is written into separate header-file by weather daemon /* Weather data is written into separate header-file by weather daemon
if(haveweather){ if(haveweather){
snprintf(val, 22, "%.1f", HDR->weather.humidity); snprintf(val, VALLEN, "%.1f", HDR->weather.humidity);
WRHDR("HUMIDITY", val, "Relative humidity, %%"); WRHDR("HUMIDITY", val, "Relative humidity, %%");
snprintf(val, 22, "%.1f", HDR->weather.pressure); snprintf(val, VALLEN, "%.1f", HDR->weather.pressure);
WRHDR("PRESSURE", val, "Atmospheric pressure, mmHg"); WRHDR("PRESSURE", val, "Atmospheric pressure, mmHg");
snprintf(val, 22, "%.1f", HDR->weather.exttemp); snprintf(val, VALLEN, "%.1f", HDR->weather.exttemp);
WRHDR("EXTTEMP", val, "External temperature, degrC"); WRHDR("EXTTEMP", val, "External temperature, degrC");
snprintf(val, 22, "%d", HDR->weather.rain); snprintf(val, VALLEN, "%d", HDR->weather.rain);
WRHDR("RAIN", val, "Rain conditions"); WRHDR("RAIN", val, "Rain conditions");
snprintf(val, 22, "%.1f", HDR->weather.clouds); snprintf(val, VALLEN, "%.1f", HDR->weather.clouds);
WRHDR("SKYQUAL", val, "Sky quality (0 - wery bad, >2500 - good)"); WRHDR("SKYQUAL", val, "Sky quality (0 - wery bad, >2500 - good)");
snprintf(val, 22, "%.1f", HDR->weather.wind); snprintf(val, VALLEN, "%.1f", HDR->weather.wind);
WRHDR("WINDSPD", val, "Wind speed (m/s)"); WRHDR("WINDSPD", val, "Wind speed (m/s)");
snprintf(val, 22, "%.1f", HDR->weather.windmax); snprintf(val, VALLEN, "%.1f", HDR->weather.windmax);
WRHDR("WINDMAX", val, "Last hour maximal wind speed (m/s)"); WRHDR("WINDMAX", val, "Last hour maximal wind speed (m/s)");
snprintf(val, 22, "%lld", (long long)HDR->weather.last_update); snprintf(val, VALLEN, "%lld", (long long)HDR->weather.last_update);
WRHDR("WEATTIME", val, "Unix time of weather measurements"); WRHDR("WEATTIME", val, "Unix time of weather measurements");
}*/ }*/
// WRHDR("", , ""); // WRHDR("", , "");

View File

@@ -278,16 +278,16 @@ static bool write_cmd(const char *cmd, bool haveanswer){
if(!haveanswer){ if(!haveanswer){
DBG("Command '%s'", cmd); DBG("Command '%s'", cmd);
if(!mount_dev || !cmd){ if(!mount_dev || !cmd){
DBG("no mount device?"); WARNX("no mount device?");
return false; return false;
} }
if(sl_tty_write(mount_dev->comfd, cmd, strlen(cmd))){ if(sl_tty_write(mount_dev->comfd, cmd, strlen(cmd))){
DBG("Error writing request '%s'", cmd); WARNX("Error writing request '%s'", cmd);
return false; return false;
} }
while(sl_tty_read(mount_dev) > 0); while(sl_tty_read(mount_dev) > 0);
}else if(!send_cmd_resp(cmd, buf, 128)){ }else if(!send_cmd_resp(cmd, buf, 128)){
DBG("Error writing command '%s'", cmd); WARNX("Error writing command '%s'", cmd);
return false; return false;
} }
return true; return true;
@@ -376,7 +376,10 @@ static bool guess_speed(){
// connect to mount // connect to mount
bool mount_connect(){ bool mount_connect(){
if(isemulated) return true; if(isemulated) return true;
if(!mount_dev) return false; if(!mount_dev){
WARNX("Mount not initialized!");
return false;
}
pthread_mutex_lock(&mntdev_mutex); pthread_mutex_lock(&mntdev_mutex);
if(!chkconn() && !guess_speed()){ if(!chkconn() && !guess_speed()){
pthread_mutex_unlock(&mntdev_mutex); pthread_mutex_unlock(&mntdev_mutex);
@@ -419,12 +422,15 @@ void mount_disconnect(){
bool mount_point(double ra, double dec){ bool mount_point(double ra, double dec){
char rastr[RADEC_STR_MAXLEN], decstr[RADEC_STR_MAXLEN]; char rastr[RADEC_STR_MAXLEN], decstr[RADEC_STR_MAXLEN];
norm_RADEC(&ra, &dec); norm_RADEC(&ra, &dec);
ra2str(ra, rastr); h2sHMS(ra, rastr);
dec2str(dec, decstr); d2sDMS(dec, decstr);
LOGDBG("try to set RA/DEC to %s/%s", rastr, decstr);
DBG("Set RA/Decl to %s/%s", rastr, decstr); DBG("Set RA/Decl to %s/%s", rastr, decstr);
LOGMSG("Try to set RA/Decl to %s/%s", rastr, decstr);
if(isemulated) return point_emulation(ra, dec); if(isemulated) return point_emulation(ra, dec);
if(!mount_dev) return false; if(!mount_dev){
WARNX("No mount device!");
return false;
}
pthread_mutex_lock(&mntdev_mutex); pthread_mutex_lock(&mntdev_mutex);
char cmd[128]; char cmd[128];
bool ret = false; bool ret = false;
@@ -443,6 +449,7 @@ bool mount_point(double ra, double dec){
TagCoords.ra = HRS2RAD(ra); TagCoords.ra = HRS2RAD(ra);
TagCoords.dec = DEG2RAD(dec); TagCoords.dec = DEG2RAD(dec);
TagTime = sl_dtime(); TagTime = sl_dtime();
LOGMSG("Go to RA/Decl: %s/%s", rastr, decstr);
retn: retn:
pthread_mutex_unlock(&mntdev_mutex); pthread_mutex_unlock(&mntdev_mutex);
return ret; return ret;
@@ -460,8 +467,8 @@ bool mount_pointAZ(double A, double Z){
DBG("Wrong Z?"); DBG("Wrong Z?");
return false; return false;
} }
d2sDMS(A, azstr, RADEC_STR_MAXLEN); d2sDMS(A, azstr);
d2sDMS(90. - Z, altstr, RADEC_STR_MAXLEN); d2sDMS(90. - Z, altstr);
DBG("Point to stationary object, Az=%s, Alt=%s", azstr, altstr); DBG("Point to stationary object, Az=%s, Alt=%s", azstr, altstr);
if(isemulated){ if(isemulated){
return pointAZ_emulation(A, Z); return pointAZ_emulation(A, Z);

View File

@@ -1,7 +1,9 @@
device = /dev/ttyS1 device = /dev/ttyS1
serspeed = 9600 # starting speed after powering on serspeed = 9600 # starting speed after powering on
logfile = loghere.log logfile = /tmp/stlog.log
hdrfile = fitshdr.fits hdrfile = /tmp/fitshdr.fits
dut1 = -0.021 dut1 = -0.021
polarx = 0.1774 polarx = 0.1774
polary = 0.3264 polary = 0.3264
parka = 01:48:38
parkz = 88:46:31

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 20.0.1, 2026-10-13T23:29:46. --> <!-- Written by QtCreator 20.0.1, 2026-10-15T00:52:00. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@@ -267,11 +267,12 @@ static sl_sock_hresult_e cmd_gotord(_U_ sl_sock_t *c, _U_ sl_sock_hitem_t *item,
double Epoch; double Epoch;
mount_getInpEpoch(&Epoch); mount_getInpEpoch(&Epoch);
if(Epoch > 0.){ if(Epoch > 0.){
LOGDBG("Convert ra=%ghrs, dec=%gdeg from epoch=%g", RAD2HRS(px.ra), RAD2DEG(px.dec), Epoch);
if(!JXtoJnow(&px, &pnow, Epoch)) return RESULT_FAIL; if(!JXtoJnow(&px, &pnow, Epoch)) return RESULT_FAIL;
}else pnow = px; }else pnow = px;
double ra_h = RAD2HRS(pnow.ra); double ra_h = RAD2HRS(pnow.ra);
double dec_d = RAD2DEG(pnow.dec); double dec_d = RAD2DEG(pnow.dec);
LOGDBG("Client %d asks to point ra=%ghrs, dec=%gdeg", c->fd, ra_h, dec_d); LOGMSG("Client %d asks to point ra=%ghrs, dec=%gdeg", c->fd, ra_h, dec_d);
if(!mount_point(ra_h, dec_d)) return RESULT_FAIL; if(!mount_point(ra_h, dec_d)) return RESULT_FAIL;
return RESULT_OK; return RESULT_OK;
} }
@@ -599,7 +600,7 @@ void server_run(){
LOGWARN("Can't connect to mount, will try to reconnect later"); LOGWARN("Can't connect to mount, will try to reconnect later");
} }
DBG("While"); DBG("While");
double tcheck = 0., treconnect = sl_dtime(); double tcheck = sl_dtime(), treconnect = 0.;
time_t lastweathertime = 0; time_t lastweathertime = 0;
getPlaceData(&HDR.place); getPlaceData(&HDR.place);
mount_get_name(HDR.mountname, MAX_HDR_STRLEN); mount_get_name(HDR.mountname, MAX_HDR_STRLEN);
@@ -664,7 +665,7 @@ void server_run(){
if(mount_connect()){ if(mount_connect()){
notlogged = true; notlogged = true;
WARNX("Mount is ON"); WARNX("Mount is ON");
} }else WARNX("Still can't connect");
} }
} }
DBG("Current status: %s", mount_status_str(HDR.status)); DBG("Current status: %s", mount_status_str(HDR.status));

View File

@@ -131,7 +131,7 @@ static bool proc_data(uint8_t *data, ssize_t len){
double tagRA = RA2HRS(ra), tagDec = DEC2DEG(dec); double tagRA = RA2HRS(ra), tagDec = DEC2DEG(dec);
DBG("RA: %u (%g hrs), DEC: %d (%g degr)", ra, tagRA, dec, tagDec); DBG("RA: %u (%g hrs), DEC: %d (%g degr)", ra, tagRA, dec, tagDec);
LOGMSG("(stellarium) RA: %u (%g hrs), DEC: %d (%g degr)", ra, tagRA, dec, tagDec); LOGMSG("(stellarium) RA: %u (%g hrs), DEC: %d (%g degr)", ra, tagRA, dec, tagDec);
return (mount_setInpRA(tagRA) && mount_setInpDec(tagDec) && mount_setInpEpoch(ERFA_DJM00)); return (mount_setInpRA(tagRA) && mount_setInpDec(tagDec) && mount_setInpEpoch(2000.));
} }
/** /**
@@ -187,19 +187,17 @@ static void *handle_socket(void *sockd){
while(isrunning){ while(isrunning){
fitsheader_t HDR; fitsheader_t HDR;
server_getheader(&HDR); server_getheader(&HDR);
/* /**/
// convert from Jnow to J2000 // convert from Jnow to J2000
polarCrds_t Jn = {0}, J2000 = {0}; polarCrds_t J2000 = {0};
Jn.ra = HRS2RAD(Rhrs); if(!JnowtoJ2000(&HDR.polar, &J2000)) break;
Jn.dec = DEG2RAD(Ddeg);
if(!JnowtoJ2000(&Jn, &J2000)) break;
//DBG("got : %g/%g", RA, Decl); //DBG("got : %g/%g", RA, Decl);
dout.ra = htole32(RAD2RA(J2000.ra)); dout.ra = htole32(RAD2RA(J2000.ra));
dout.dec = (int32_t)htole32(RAD2DEC(J2000.dec)); dout.dec = (int32_t)htole32(RAD2DEC(J2000.dec));
*/ /*
dout.ra = htole32(RAD2RA(HDR.polar.ra)); dout.ra = htole32(RAD2RA(HDR.polar.ra));
dout.dec = (int32_t)htole32(RAD2DEC(HDR.polar.dec)); dout.dec = (int32_t)htole32(RAD2DEC(HDR.polar.dec));
/**/ */
if(!send_data((uint8_t*)&dout, sizeof(outdata), sock)) break; // send data even in `off` state if(!send_data((uint8_t*)&dout, sizeof(outdata), sock)) break; // send data even in `off` state
if(!sl_canread(sock)){ if(!sl_canread(sock)){
sleep(1); sleep(1);