fix bug after mount turnoff

This commit is contained in:
Edward Emelianov 2020-02-22 21:23:50 +03:00
parent 62f41e9baf
commit 9225e28d2e
2 changed files with 18 additions and 4 deletions

View File

@ -3,7 +3,7 @@ LDFLAGS = -lsofa_c -pthread
SRCS = $(wildcard *.c)
CC = gcc
DEFINES = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=1111
DEFINES += -DEBUG
#DEFINES += -DEBUG
CXX = gcc
CFLAGS = -Wall -Werror -Wextra -Wno-trampolines $(DEFINES)
OBJS = $(SRCS:.c=.o)

View File

@ -113,7 +113,7 @@ int chkconn(){
*/
int connect_telescope(char *dev, char *hdrname){
if(!dev) return 0;
tcflag_t spds[] = {B115200, B57600, B38400, B19200, B9600, B4800, B2400, B1200, 0}, *speeds = spds;
tcflag_t spds[] = {B9600, B115200, B57600, B38400, B19200, B4800, B2400, B1200, 0}, *speeds = spds;
DBG("Connection to device %s...", dev);
putlog("Try to connect to device %s...", dev);
while(*speeds){
@ -320,12 +320,26 @@ static void getplace(){
* @brief wrhdr - try to write into header file
*/
void wrhdr(){
static int failcounter = 0;
char *ans = NULL, *jd = NULL, *lst = NULL, *date = NULL;
// get coordinates for writing to file & sending to stellarium client
ans = write_cmd(":GR#");
if(!str2coord(ans, &r)) return;
if(!str2coord(ans, &r)){
if(++failcounter == 10){
DBG("Can't ger RA 10 times!");
signals(9);
}
return;
}
ans = write_cmd(":GD#");
if(!str2coord(ans, &d)) return;
if(!str2coord(ans, &d)){
if(++failcounter == 10){
DBG("Can't ger DEC 10 times!");
signals(9);
}
return;
}
failcounter = 0;
tlast = time(NULL);
if(!hdname) return;
if(!elevation || !longitude || !latitude) getplace();