mirror of
https://github.com/eddyem/small_tel.git
synced 2026-09-30 22:00:37 +03:00
add "raw" commands
This commit is contained in:
@@ -325,6 +325,12 @@ Place data can only be set at start-up (via CLI/config).
|
|||||||
| `parkaz` | get/set| Parking azimuth, degrees. |
|
| `parkaz` | get/set| Parking azimuth, degrees. |
|
||||||
| `parkzd` | get/set| Parking zenith distance, 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
|
### Shutdown
|
||||||
|
|
||||||
The `shutdown` command implements a simple confirmation handshake:
|
The `shutdown` command implements a simple confirmation handshake:
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <weather_data.h>
|
#include <weather_data.h>
|
||||||
|
|
||||||
#include "angles.h"
|
#include "angles.h"
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include <usefull_macros.h>
|
#include <usefull_macros.h>
|
||||||
|
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "fitshdr.h"
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "mount.h"
|
#include "mount.h"
|
||||||
#include "stellarium.h"
|
#include "stellarium.h"
|
||||||
|
|||||||
@@ -689,3 +689,14 @@ bool mount_corrdata(weather_data_t *w){
|
|||||||
bool mount_shutdown(){
|
bool mount_shutdown(){
|
||||||
return write_cmd(CMD_SHUTDOWN, true);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
7
Daemons/10micron_stellarium/mount.conf
Normal file
7
Daemons/10micron_stellarium/mount.conf
Normal file
@@ -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
|
||||||
@@ -90,3 +90,5 @@ bool mount_setParkZD(double zd);
|
|||||||
void mount_getPark(horizCrds_t *c);
|
void mount_getPark(horizCrds_t *c);
|
||||||
|
|
||||||
bool mount_shutdown();
|
bool mount_shutdown();
|
||||||
|
|
||||||
|
bool mount_rawcmd(const char *cmd, char *ans, size_t anslen);
|
||||||
|
|||||||
@@ -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-09-28T09:01:11. -->
|
<!-- Written by QtCreator 20.0.1, 2026-09-29T09:41:26. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <usefull_macros.h>
|
#include <usefull_macros.h>
|
||||||
#include <weather_data.h>
|
#include <weather_data.h>
|
||||||
|
|
||||||
#include "fitshdr.h"
|
|
||||||
#include "mount.h"
|
#include "mount.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "stellarium.h"
|
#include "stellarium.h"
|
||||||
@@ -47,6 +46,7 @@
|
|||||||
#define CMD_PLACE "place"
|
#define CMD_PLACE "place"
|
||||||
#define CMD_POLARX "polarx"
|
#define CMD_POLARX "polarx"
|
||||||
#define CMD_POLARY "polary"
|
#define CMD_POLARY "polary"
|
||||||
|
#define CMD_RAW "raw"
|
||||||
#define CMD_SHUTDOWN "shutdown"
|
#define CMD_SHUTDOWN "shutdown"
|
||||||
#define CMD_STATUS "status"
|
#define CMD_STATUS "status"
|
||||||
#define CMD_STOP "stop"
|
#define CMD_STOP "stop"
|
||||||
@@ -79,6 +79,7 @@ static bool weatherlost = false;
|
|||||||
|
|
||||||
// data for FITS-header (also to send user)
|
// data for FITS-header (also to send user)
|
||||||
static fitsheader_t HDR = {0};
|
static fitsheader_t HDR = {0};
|
||||||
|
static pthread_mutex_t headermutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
unsigned int server_getsleept(){ return sleept; }
|
unsigned int server_getsleept(){ return sleept; }
|
||||||
bool server_setsleept(unsigned int t){
|
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;
|
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){
|
static sl_sock_hresult_e cmd_shutdown(sl_sock_t *c, sl_sock_hitem_t *item, const char *req){
|
||||||
double val;
|
double val;
|
||||||
static int shtdwnkey = -1;
|
static int shtdwnkey = -1;
|
||||||
@@ -491,6 +503,7 @@ static sl_sock_hitem_t handlers[] = {
|
|||||||
{cmd_place, CMD_PLACE, "get place data", NULL},
|
{cmd_place, CMD_PLACE, "get place data", NULL},
|
||||||
{cmd_polarx, CMD_POLARX, "set polar X value (m)", NULL},
|
{cmd_polarx, CMD_POLARX, "set polar X value (m)", NULL},
|
||||||
{cmd_polary, CMD_POLARY, "set polar Y 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},
|
{cmd_shutdown, CMD_SHUTDOWN, "shut down mount power", NULL},
|
||||||
{status, CMD_STATUS, "get mount status", NULL},
|
{status, CMD_STATUS, "get mount status", NULL},
|
||||||
{cmd_stop, CMD_STOP, "stop telescope", NULL},
|
{cmd_stop, CMD_STOP, "stop telescope", NULL},
|
||||||
@@ -613,9 +626,11 @@ void server_run(){
|
|||||||
WARNX("Can't get weather data");
|
WARNX("Can't get weather data");
|
||||||
}
|
}
|
||||||
// collect data for other fields
|
// collect data for other fields
|
||||||
|
pthread_mutex_lock(&headermutex);
|
||||||
HDR.status = mount_status();
|
HDR.status = mount_status();
|
||||||
if(HDR.status != MNT_S_OFF){
|
if(HDR.status != MNT_S_OFF){
|
||||||
double deg1, deg2;
|
double deg1, deg2;
|
||||||
|
DBG("Take coordinates");
|
||||||
if(mount_getcoords(°1, °2)){
|
if(mount_getcoords(°1, °2)){
|
||||||
get_MJDt(NULL, &HDR.MJD);
|
get_MJDt(NULL, &HDR.MJD);
|
||||||
get_LST(&HDR.MJD, &HDR.sidtime);
|
get_LST(&HDR.MJD, &HDR.sidtime);
|
||||||
@@ -639,6 +654,7 @@ void server_run(){
|
|||||||
}
|
}
|
||||||
getDUT(&HDR.dut);
|
getDUT(&HDR.dut);
|
||||||
if(HDR.status == MNT_S_OFF || !mount_getpierside(HDR.pierside, MAX_HDR_STRLEN)) *HDR.pierside = 0;
|
if(HDR.status == MNT_S_OFF || !mount_getpierside(HDR.pierside, MAX_HDR_STRLEN)) *HDR.pierside = 0;
|
||||||
|
pthread_mutex_unlock(&headermutex);
|
||||||
// and write FITS-header
|
// and write FITS-header
|
||||||
wrhdr(&HDR);
|
wrhdr(&HDR);
|
||||||
// check need of reconnection
|
// check need of reconnection
|
||||||
@@ -673,3 +689,10 @@ void server_run(){
|
|||||||
void server_stop(){
|
void server_stop(){
|
||||||
isrunning = false;
|
isrunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void server_getheader(fitsheader_t *fh){
|
||||||
|
if(!fh) return;
|
||||||
|
pthread_mutex_lock(&headermutex);
|
||||||
|
*fh = HDR;
|
||||||
|
pthread_mutex_unlock(&headermutex);
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <usefull_macros.h>
|
#include <usefull_macros.h>
|
||||||
|
|
||||||
|
#include "fitshdr.h"
|
||||||
|
|
||||||
// default and max available time for "usleep"
|
// default and max available time for "usleep"
|
||||||
#define DEFAULT_SLEEP_T 100
|
#define DEFAULT_SLEEP_T 100
|
||||||
#define MAX_SLEEP_T 10000
|
#define MAX_SLEEP_T 10000
|
||||||
@@ -49,3 +51,4 @@ void server_run();
|
|||||||
void server_stop();
|
void server_stop();
|
||||||
unsigned int server_getsleept();
|
unsigned int server_getsleept();
|
||||||
bool server_setsleept(unsigned int t);
|
bool server_setsleept(unsigned int t);
|
||||||
|
void server_getheader(fitsheader_t *fh);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "angles.h"
|
#include "angles.h"
|
||||||
#include "mount.h"
|
#include "mount.h"
|
||||||
|
#include "server.h"
|
||||||
#include "stellarium.h"
|
#include "stellarium.h"
|
||||||
|
|
||||||
#define BUFLEN 256
|
#define BUFLEN 256
|
||||||
@@ -161,13 +162,8 @@ static void *handle_socket(void *sockd){
|
|||||||
dout.len = htole16(sizeof(outdata));
|
dout.len = htole16(sizeof(outdata));
|
||||||
dout.type = 0;
|
dout.type = 0;
|
||||||
while(isrunning){
|
while(isrunning){
|
||||||
// get coordinates
|
fitsheader_t HDR;
|
||||||
double Rhrs = 0., Ddeg = 0.;
|
server_getheader(&HDR);
|
||||||
if((dout.status = mount_getcoords(&Rhrs, &Ddeg)) == false){
|
|
||||||
WARNX("Error: can't get coordinates");
|
|
||||||
sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
// convert from Jnow to J2000
|
// convert from Jnow to J2000
|
||||||
polarCrds_t Jn = {0}, J2000 = {0};
|
polarCrds_t Jn = {0}, J2000 = {0};
|
||||||
@@ -178,10 +174,10 @@ static void *handle_socket(void *sockd){
|
|||||||
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(HRS2RAD(Rhrs)));
|
dout.ra = htole32(RAD2RA(HRS2RAD(HDR.polar.ra)));
|
||||||
dout.dec = (int32_t)htole32(RAD2DEC(DEG2RAD(Ddeg)));
|
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)){
|
if(!sl_canread(sock)){
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user