shit happens

This commit is contained in:
2025-02-25 23:32:51 +03:00
parent f83f95c9cc
commit 5b89a968eb
17 changed files with 214 additions and 102 deletions

View File

@@ -23,6 +23,7 @@
#include <time.h>
#include <usefull_macros.h>
#include "conf.h"
#include "dump.h"
#include "sidservo.h"
#include "simpleconv.h"
@@ -33,6 +34,7 @@ typedef struct{
int wait;
int relative;
char *coordsoutput;
char *conffile;
double X;
double Y;
} parameters;
@@ -51,18 +53,10 @@ static sl_option_t cmdlnopts[] = {
{"output", NEED_ARG, NULL, 'o', arg_string, APTR(&G.coordsoutput),"file to log coordinates"},
{"wait", NO_ARGS, NULL, 'w', arg_int, APTR(&G.wait), "wait until mowing stopped"},
{"relative", NO_ARGS, NULL, 'r', arg_int, APTR(&G.relative), "relative move"},
{"conffile", NEED_ARG, NULL, 'C', arg_int, APTR(&G.conffile), "configuration file name"},
end_option
};
static conf_t Config = {
.MountDevPath = "/dev/ttyUSB0",
.MountDevSpeed = 19200,
//.EncoderDevPath = "/dev/ttyUSB1",
//.EncoderDevSpeed = 153000,
.MountReqInterval = 0.1,
.SepEncoder = 0
};
static FILE* fcoords = NULL;
static pthread_t dthr;
@@ -86,8 +80,14 @@ static void *dumping(void _U_ *u){
int main(int _U_ argc, char _U_ **argv){
sl_init();
sl_parseargs(&argc, &argv, cmdlnopts);
if(G.help) sl_showhelp(-1, cmdlnopts);
if(MCC_E_OK != Mount.init(&Config)) ERRX("Can't init mount");
if(G.help)
sl_showhelp(-1, cmdlnopts);
conf_t *Config = readServoConf(G.conffile);
if(!Config){
dumpConf();
return 1;
}
if(MCC_E_OK != Mount.init(Config)) ERRX("Can't init mount");
coords_t M;
if(!getPos(&M, NULL)) ERRX("Can't get current position");
if(G.coordsoutput){
@@ -126,6 +126,9 @@ int main(int _U_ argc, char _U_ **argv){
}
out:
if(G.coordsoutput) pthread_join(dthr, NULL);
if(G.wait) Mount.quit();
if(G.wait){
if(getPos(&M, NULL)) printf("Mount position: X=%g, Y=%g\n", RAD2DEG(M.X), RAD2DEG(M.Y));
Mount.quit();
}
return 0;
}