diff --git a/Daemons/10micron_stellarium/Readme.md b/Daemons/10micron_stellarium/Readme.md
index 011f166..f09c01e 100644
--- a/Daemons/10micron_stellarium/Readme.md
+++ b/Daemons/10micron_stellarium/Readme.md
@@ -325,6 +325,12 @@ Place data can only be set at start-up (via CLI/config).
| `parkaz` | get/set| Parking azimuth, degrees. |
| `parkzd` | get/set| Parking zenith distance, degrees. |
+### Sending custom command
+
+The `raw` command allows to send any unsupported command string directly to mount.
+E.g. to set lunar tracking rate send `raw = :TL#`. If mount gives no answer for command, you will
+get message "No answer", otherwise you'll get this answer.
+
### Shutdown
The `shutdown` command implements a simple confirmation handshake:
diff --git a/Daemons/10micron_stellarium/fitshdr.h b/Daemons/10micron_stellarium/fitshdr.h
index 31f4258..3ba3dc6 100644
--- a/Daemons/10micron_stellarium/fitshdr.h
+++ b/Daemons/10micron_stellarium/fitshdr.h
@@ -16,6 +16,8 @@
* along with this program. If not, see .
*/
+#pragma once
+
#include
#include "angles.h"
diff --git a/Daemons/10micron_stellarium/main.c b/Daemons/10micron_stellarium/main.c
index 45132bf..f6957e3 100644
--- a/Daemons/10micron_stellarium/main.c
+++ b/Daemons/10micron_stellarium/main.c
@@ -25,7 +25,6 @@
#include
#include "args.h"
-#include "fitshdr.h"
#include "server.h"
#include "mount.h"
#include "stellarium.h"
diff --git a/Daemons/10micron_stellarium/mount.c b/Daemons/10micron_stellarium/mount.c
index ddae71d..1028b54 100644
--- a/Daemons/10micron_stellarium/mount.c
+++ b/Daemons/10micron_stellarium/mount.c
@@ -689,3 +689,14 @@ bool mount_corrdata(weather_data_t *w){
bool mount_shutdown(){
return write_cmd(CMD_SHUTDOWN, true);
}
+
+/**
+ * @brief mount_rawcmd - send raw command `cmd` to mount
+ * @param cmd - raw command
+ * @param ans (o) - answer text
+ * @param anslen - length of `ans` buffer
+ * @return false if failed
+ */
+bool mount_rawcmd(const char *cmd, char *ans, size_t anslen){
+ return send_cmd_resp(cmd, ans, anslen);
+}
diff --git a/Daemons/10micron_stellarium/mount.conf b/Daemons/10micron_stellarium/mount.conf
new file mode 100644
index 0000000..0f3bafb
--- /dev/null
+++ b/Daemons/10micron_stellarium/mount.conf
@@ -0,0 +1,7 @@
+device = /dev/ttyS1
+serspeed = 9600 # starting speed after powering on
+logfile = loghere.log
+hdrfile = fitshdr.fits
+dut1 = -0.021
+polarx = 0.1774
+polary = 0.3264
diff --git a/Daemons/10micron_stellarium/mount.h b/Daemons/10micron_stellarium/mount.h
index 4d9a422..a6bd55c 100644
--- a/Daemons/10micron_stellarium/mount.h
+++ b/Daemons/10micron_stellarium/mount.h
@@ -90,3 +90,5 @@ bool mount_setParkZD(double zd);
void mount_getPark(horizCrds_t *c);
bool mount_shutdown();
+
+bool mount_rawcmd(const char *cmd, char *ans, size_t anslen);
diff --git a/Daemons/10micron_stellarium/mountdaemon_10micron.creator.user b/Daemons/10micron_stellarium/mountdaemon_10micron.creator.user
index fba2ccf..dd00427 100644
--- a/Daemons/10micron_stellarium/mountdaemon_10micron.creator.user
+++ b/Daemons/10micron_stellarium/mountdaemon_10micron.creator.user
@@ -1,6 +1,6 @@
-
+
EnvironmentId
diff --git a/Daemons/10micron_stellarium/server.c b/Daemons/10micron_stellarium/server.c
index 3e9ae5b..9f160a7 100644
--- a/Daemons/10micron_stellarium/server.c
+++ b/Daemons/10micron_stellarium/server.c
@@ -27,7 +27,6 @@
#include
#include
-#include "fitshdr.h"
#include "mount.h"
#include "server.h"
#include "stellarium.h"
@@ -47,6 +46,7 @@
#define CMD_PLACE "place"
#define CMD_POLARX "polarx"
#define CMD_POLARY "polary"
+#define CMD_RAW "raw"
#define CMD_SHUTDOWN "shutdown"
#define CMD_STATUS "status"
#define CMD_STOP "stop"
@@ -79,6 +79,7 @@ static bool weatherlost = false;
// data for FITS-header (also to send user)
static fitsheader_t HDR = {0};
+static pthread_mutex_t headermutex = PTHREAD_MUTEX_INITIALIZER;
unsigned int server_getsleept(){ return sleept; }
bool server_setsleept(unsigned int t){
@@ -448,6 +449,17 @@ static sl_sock_hresult_e cmd_place(sl_sock_t *c, sl_sock_hitem_t _U_ *item, cons
return RESULT_SILENCE;
}
+static sl_sock_hresult_e cmd_raw(sl_sock_t *c, sl_sock_hitem_t _U_ *item, const char *req){
+ char buf[128];
+ if(!req || !*req) return RESULT_BADVAL;
+ if(!mount_rawcmd(req, buf, 126)) strcpy(buf, "No answer");
+ size_t L = strlen(buf);
+ buf[L] = '\n';
+ buf[L + 1] = 0;
+ sl_sock_sendstrmessage(c, buf);
+ return RESULT_SILENCE;
+}
+
static sl_sock_hresult_e cmd_shutdown(sl_sock_t *c, sl_sock_hitem_t *item, const char *req){
double val;
static int shtdwnkey = -1;
@@ -491,6 +503,7 @@ static sl_sock_hitem_t handlers[] = {
{cmd_place, CMD_PLACE, "get place data", NULL},
{cmd_polarx, CMD_POLARX, "set polar X value (m)", NULL},
{cmd_polary, CMD_POLARY, "set polar Y value (m)", NULL},
+ {cmd_raw, CMD_RAW, "send raw command to mount", NULL},
{cmd_shutdown, CMD_SHUTDOWN, "shut down mount power", NULL},
{status, CMD_STATUS, "get mount status", NULL},
{cmd_stop, CMD_STOP, "stop telescope", NULL},
@@ -613,9 +626,11 @@ void server_run(){
WARNX("Can't get weather data");
}
// collect data for other fields
+ pthread_mutex_lock(&headermutex);
HDR.status = mount_status();
if(HDR.status != MNT_S_OFF){
double deg1, deg2;
+ DBG("Take coordinates");
if(mount_getcoords(°1, °2)){
get_MJDt(NULL, &HDR.MJD);
get_LST(&HDR.MJD, &HDR.sidtime);
@@ -639,6 +654,7 @@ void server_run(){
}
getDUT(&HDR.dut);
if(HDR.status == MNT_S_OFF || !mount_getpierside(HDR.pierside, MAX_HDR_STRLEN)) *HDR.pierside = 0;
+ pthread_mutex_unlock(&headermutex);
// and write FITS-header
wrhdr(&HDR);
// check need of reconnection
@@ -673,3 +689,10 @@ void server_run(){
void server_stop(){
isrunning = false;
}
+
+void server_getheader(fitsheader_t *fh){
+ if(!fh) return;
+ pthread_mutex_lock(&headermutex);
+ *fh = HDR;
+ pthread_mutex_unlock(&headermutex);
+}
diff --git a/Daemons/10micron_stellarium/server.h b/Daemons/10micron_stellarium/server.h
index 0bf2638..754c156 100644
--- a/Daemons/10micron_stellarium/server.h
+++ b/Daemons/10micron_stellarium/server.h
@@ -20,6 +20,8 @@
#include
+#include "fitshdr.h"
+
// default and max available time for "usleep"
#define DEFAULT_SLEEP_T 100
#define MAX_SLEEP_T 10000
@@ -49,3 +51,4 @@ void server_run();
void server_stop();
unsigned int server_getsleept();
bool server_setsleept(unsigned int t);
+void server_getheader(fitsheader_t *fh);
diff --git a/Daemons/10micron_stellarium/stellarium.c b/Daemons/10micron_stellarium/stellarium.c
index 8f50e67..a0b677c 100644
--- a/Daemons/10micron_stellarium/stellarium.c
+++ b/Daemons/10micron_stellarium/stellarium.c
@@ -27,6 +27,7 @@
#include "angles.h"
#include "mount.h"
+#include "server.h"
#include "stellarium.h"
#define BUFLEN 256
@@ -161,13 +162,8 @@ static void *handle_socket(void *sockd){
dout.len = htole16(sizeof(outdata));
dout.type = 0;
while(isrunning){
- // get coordinates
- double Rhrs = 0., Ddeg = 0.;
- if((dout.status = mount_getcoords(&Rhrs, &Ddeg)) == false){
- WARNX("Error: can't get coordinates");
- sleep(1);
- continue;
- }
+ fitsheader_t HDR;
+ server_getheader(&HDR);
/*
// convert from Jnow to J2000
polarCrds_t Jn = {0}, J2000 = {0};
@@ -178,10 +174,10 @@ static void *handle_socket(void *sockd){
dout.ra = htole32(RAD2RA(J2000.ra));
dout.dec = (int32_t)htole32(RAD2DEC(J2000.dec));
*/
- dout.ra = htole32(RAD2RA(HRS2RAD(Rhrs)));
- dout.dec = (int32_t)htole32(RAD2DEC(DEG2RAD(Ddeg)));
+ dout.ra = htole32(RAD2RA(HRS2RAD(HDR.polar.ra)));
+ dout.dec = (int32_t)htole32(RAD2DEC(DEG2RAD(HDR.polar.dec)));
/**/
- if(!send_data((uint8_t*)&dout, sizeof(outdata), sock)) break;
+ if(!send_data((uint8_t*)&dout, sizeof(outdata), sock)) break; // send data even in `off` state
if(!sl_canread(sock)){
sleep(1);
continue;