mirror of
https://github.com/eddyem/SBIG_340.git
synced 2025-12-06 02:35:12 +03:00
forget to commit -a
This commit is contained in:
parent
80a52be7e1
commit
f6f0bd6f0f
60
Makefile
60
Makefile
@ -1,41 +1,51 @@
|
||||
# run `make DEF=...` to add extra defines
|
||||
PROGRAM := sbig340
|
||||
LDFLAGS := -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--discard-all
|
||||
LDFLAGS += -ltiff -lm $(shell pkg-config --libs cfitsio)
|
||||
LDFLAGS += -lm -pthread
|
||||
SRCS := $(wildcard *.c)
|
||||
DEFINES := $(DEF) -D_XOPEN_SOURCE=1111 -DEBUG
|
||||
OBJDIR := mk
|
||||
DEFINES := $(DEF) -D_XOPEN_SOURCE=1111
|
||||
DEFINES += -DEBUG
|
||||
#OBJDIR := mk
|
||||
CFLAGS += -O2 -Wall -Werror -Wextra -Wno-trampolines -std=gnu99
|
||||
OBJS := $(addprefix $(OBJDIR)/, $(SRCS:%.c=%.o))
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
#OBJS := $(addprefix $(OBJDIR)/, $(SRCS:%.c=%.o))
|
||||
#DEPS := $(OBJS:.o=.d)
|
||||
CC = gcc
|
||||
|
||||
all : $(OBJDIR) $(PROGRAM)
|
||||
all : sbig340 daemon client
|
||||
# $(OBJDIR)
|
||||
|
||||
$(PROGRAM) : $(OBJS)
|
||||
@echo -e "\t\tLD $(PROGRAM)"
|
||||
$(CC) $(LDFLAGS) $(OBJS) -o $(PROGRAM)
|
||||
sbig340 : $(SRCS)
|
||||
@echo -e "\t\tLD sbig340"
|
||||
$(CC) $(CFLAGS) $(DEFINES) $(LDFLAGS) $(shell pkg-config --libs cfitsio) -ltiff $(SRCS) -o sbig340
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir $(OBJDIR)
|
||||
daemon : $(SRCS)
|
||||
@echo -e "\t\tLD daemon"
|
||||
$(CC) -DDAEMON $(CFLAGS) $(DEFINES) $(LDFLAGS) $(SRCS) -o daemon
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(DEPS)
|
||||
endif
|
||||
client : $(SRCS)
|
||||
@echo -e "\t\tLD client"
|
||||
$(CC) -DCLIENT $(CFLAGS) $(DEFINES) $(LDFLAGS) $(shell pkg-config --libs cfitsio) -ltiff $(SRCS) -o client
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
@echo -e "\t\tCC $<"
|
||||
$(CC) -MD -c $(LDFLAGS) $(CFLAGS) $(DEFINES) -o $@ $<
|
||||
#$(OBJDIR):
|
||||
# mkdir $(OBJDIR)
|
||||
|
||||
clean:
|
||||
@echo -e "\t\tCLEAN"
|
||||
@rm -f $(OBJS) $(DEPS)
|
||||
@rmdir $(OBJDIR) 2>/dev/null || true
|
||||
#ifneq ($(MAKECMDGOALS),clean)
|
||||
#-include $(DEPS)
|
||||
#endif
|
||||
|
||||
xclean: clean
|
||||
@rm -f $(PROGRAM)
|
||||
#$(OBJDIR)/%.o: %.c
|
||||
# @echo -e "\t\tCC $<"
|
||||
# $(CC) -MD -c $(LDFLAGS) $(CFLAGS) $(DEFINES) -o $@ $<
|
||||
|
||||
#clean:
|
||||
# @echo -e "\t\tCLEAN"
|
||||
# @rm -f $(OBJS) $(DEPS)
|
||||
# @rmdir $(OBJDIR) 2>/dev/null || true
|
||||
|
||||
#xclean: clean
|
||||
# @rm -f $(PROGRAM)
|
||||
|
||||
gentags:
|
||||
CFLAGS="$(CFLAGS) $(DEFINES)" geany -g $(PROGRAM).c.tags *[hc] 2>/dev/null
|
||||
|
||||
.PHONY: gentags clean xclean
|
||||
.PHONY: gentags
|
||||
#clean xclean
|
||||
|
||||
35
cmdlnopts.c
35
cmdlnopts.c
@ -32,13 +32,10 @@
|
||||
int help;
|
||||
glob_pars G;
|
||||
|
||||
int rewrite_ifexists = 0, // rewrite existing files == 0 or 1
|
||||
verbose = 0; // each -v increments this value, e.g. -vvv sets it to 3
|
||||
#define DEFAULT_COMDEV "/dev/ttyUSB0"
|
||||
// DEFAULTS
|
||||
// default global parameters
|
||||
glob_pars const Gdefault = {
|
||||
.daemon = 0,
|
||||
.terminal = 0,
|
||||
.heater = HEATER_LEAVE,
|
||||
.device = DEFAULT_COMDEV,
|
||||
@ -56,6 +53,8 @@ glob_pars const Gdefault = {
|
||||
.imformat = NULL,
|
||||
.imstoretype = NULL,
|
||||
.outpfname = "output.tiff",
|
||||
.hostname = "localhost",
|
||||
.port = "4444"
|
||||
};
|
||||
|
||||
/*
|
||||
@ -63,10 +62,22 @@ glob_pars const Gdefault = {
|
||||
* name has_arg flag val type argptr help
|
||||
*/
|
||||
myoption cmdlnopts[] = {
|
||||
// set 1 to param despite of its repeating number:
|
||||
// common options
|
||||
{"help", NO_ARGS, NULL, 'h', arg_int, APTR(&help), _("show this help")},
|
||||
{"daemon", NO_ARGS, NULL, 'd', arg_int, APTR(&G.daemon), _("run as daemon")},
|
||||
// only standalone options
|
||||
#if !defined DAEMON && !defined CLIENT
|
||||
{"imtype", NEED_ARG, NULL, 'T', arg_string, APTR(&G.imtype), _("image type: light (l, L), autodark (a, A), dark (d, D); default: light")},
|
||||
{"terminal",NO_ARGS, NULL, 't', arg_int, APTR(&G.terminal), _("run as terminal")},
|
||||
{"start-exp",NO_ARGS, NULL, 'X', arg_int, APTR(&G.takeimg), _("start exposition")},
|
||||
#endif
|
||||
// not daemon options
|
||||
#ifndef DAEMON
|
||||
{"storetype",NEED_ARG, NULL, 'S', arg_string, APTR(&G.imstoretype),_("'overwrite'/'rewrite' to rewrite existing image, 'enumerate'/'numerate' to use given filename as base for series")},
|
||||
{"output", NEED_ARG, NULL, 'o', arg_string, APTR(&G.outpfname), _("output file name (default: output.tiff)")},
|
||||
{"imformat",NEED_ARG, NULL, 'f', arg_string, APTR(&G.imformat), _("image format: FITS (f), TIFF (t), raw dump with histogram storage (r,d), may be OR'ed; default: FITS or based on output image name")},
|
||||
#endif
|
||||
// not client options
|
||||
#ifndef CLIENT
|
||||
{"device", NEED_ARG, NULL, 'i', arg_string, APTR(&G.device), _("serial device name (default: " DEFAULT_COMDEV ")")},
|
||||
{"heater-on",NO_ARGS, APTR(&G.heater),HEATER_ON, arg_none, NULL, _("turn heater on")},
|
||||
{"heater-off",NO_ARGS, APTR(&G.heater),HEATER_OFF, arg_none, NULL, _("turn heater off")},
|
||||
@ -77,12 +88,14 @@ myoption cmdlnopts[] = {
|
||||
{"subframe",NEED_ARG, NULL, 0, arg_string, APTR(&G.subframe), _("select subframe: x,y,size")},
|
||||
{"exptime", NEED_ARG, NULL, 'x', arg_double, APTR(&G.exptime), _("exposition time in seconds (default: 1s)")},
|
||||
{"binning", NEED_ARG, NULL, 'B', arg_int, APTR(&G.binning), _("binning (default 0: full size)")},
|
||||
{"start-exp",NO_ARGS, NULL, 'X', arg_int, APTR(&G.takeimg), _("start exposition")},
|
||||
{"imtype", NEED_ARG, NULL, 'T', arg_string, APTR(&G.imtype), _("image type: light (l, L), autodark (a, A), dark (d, D); default: light")},
|
||||
{"storetype",NEED_ARG, NULL, 'S', arg_string, APTR(&G.imstoretype),_("'overwrite'/'rewrite' to rewrite existing image, 'enumerate'/'numerate' to use given filename as base for series")},
|
||||
{"output", NEED_ARG, NULL, 'o', arg_string, APTR(&G.outpfname), _("output file name (default: output.tiff)")},
|
||||
{"imformat",NEED_ARG, NULL, 'f', arg_string, APTR(&G.imformat), _("image format: FITS (f), TIFF (t), raw dump with histogram storage (r,d), may be OR'ed; default: FITS or based on output image name")},
|
||||
// simple integer parameter with obligatory arg:
|
||||
#endif
|
||||
// not standalone options
|
||||
#if defined DAEMON || defined CLIENT
|
||||
#ifndef DAEMON
|
||||
{"hostname",NEED_ARG, NULL, 'H', arg_string, APTR(&G.hostname), _("hostname to connect (default: localhost)")},
|
||||
#endif
|
||||
{"port", NEED_ARG, NULL, 'p', arg_string, APTR(&G.port), _("port to connect (default: 4444)")},
|
||||
#endif
|
||||
end_option
|
||||
};
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
* here are some typedef's for global data
|
||||
*/
|
||||
typedef struct{
|
||||
int daemon; // to daemonize
|
||||
int terminal; // run as terminal (send/receive)
|
||||
char *device; // serial device name
|
||||
int rest_pars_num; // number of rest parameters
|
||||
@ -47,12 +46,11 @@ typedef struct{
|
||||
char *imstoretype; // "overwrite" (or "rewrite"), "normal" (or NULL), "enumerate" (or "numerate")
|
||||
char *outpfname; // output filename for image storing
|
||||
char *imformat; // output file format
|
||||
char *hostname; // hostname to connect
|
||||
char *port; // port to connect
|
||||
char** rest_pars; // the rest parameters: array of char*
|
||||
} glob_pars;
|
||||
|
||||
|
||||
// default & global parameters
|
||||
extern int rewrite_ifexists, verbose;
|
||||
|
||||
glob_pars *parse_args(int argc, char **argv);
|
||||
#endif // __CMDLNOPTS_H__
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
#include <libgen.h> // basename
|
||||
#include <sys/stat.h> // utimensat
|
||||
#include <fcntl.h> // AT_...
|
||||
|
||||
double exp_calculated = -1.; // optimal exposition, calculated in histogram saver
|
||||
/**
|
||||
* All image-storing functions modify ctime of saved files to be the time of
|
||||
* exposition start!
|
||||
@ -144,7 +146,7 @@ imstorage *chk_storeimg(char *filename, char* store, char *format){
|
||||
for(size_t i = 0; i < FMTSZ; ++i){
|
||||
if(!(formats[i] & fmt)) continue;
|
||||
if(!make_filename(nm, suffixes[i], st)){
|
||||
WARNX(_("Can't create output file"));
|
||||
WARNX(_("Can't create output file (is it exists?)"));
|
||||
free(nm);
|
||||
return NULL;
|
||||
}
|
||||
@ -334,7 +336,7 @@ int writefits(imstorage *img){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef CLIENT
|
||||
/**
|
||||
* Receive image data & fill img->imdata
|
||||
* @return imdata or NULL if failed
|
||||
@ -350,13 +352,14 @@ uint16_t *get_imdata(imstorage *img){
|
||||
img->imdata = imdata;
|
||||
return imdata;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* save truncated to 256 levels histogram of `img` into file `f`
|
||||
* @return 0 if all OK
|
||||
*/
|
||||
int save_histo(FILE *f, imstorage *img){
|
||||
if(!img->imdata) return 1000;
|
||||
if(!img || !img->imdata) return 1000;
|
||||
size_t histogram[256];
|
||||
size_t l, S = img->W*img->H;
|
||||
uint16_t *ptr = img->imdata;
|
||||
@ -364,10 +367,12 @@ int save_histo(FILE *f, imstorage *img){
|
||||
for(l = 0; l < S; ++l, ++ptr){
|
||||
++histogram[((*ptr)>>8)&0xff];
|
||||
}
|
||||
for(l = 0; l < 256; ++l){
|
||||
int status = fprintf(f, "%zd\t%zd\n", l, histogram[l]);
|
||||
if(status < 0){
|
||||
return status;
|
||||
if(f){
|
||||
for(l = 0; l < 256; ++l){
|
||||
int status = fprintf(f, "%zd\t%zd\n", l, histogram[l]);
|
||||
if(status < 0){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
size_t low2 = S/50, med = S/2, up2 = (S*49)/50, acc = 0;
|
||||
@ -375,21 +380,29 @@ int save_histo(FILE *f, imstorage *img){
|
||||
for(l = 0; l < 256; ++l){ // get stat parameters
|
||||
acc += histogram[l];
|
||||
if(lval < 0 && acc >= low2) lval = l;
|
||||
else if(mval < 0 && acc >= med) mval = l;
|
||||
else if(tval < 0 && acc >= up2) tval = l;
|
||||
if(mval < 0 && acc >= med) mval = l;
|
||||
if(tval < 0 && acc >= up2) tval = l;
|
||||
}
|
||||
DBG("acc = %zd, S = %zd", acc, S);
|
||||
printf("low 2%% (%zd pixels) = %d, median (%zd pixels) = %d, up 2%% (%zd pixels) = %d\n",
|
||||
low2, lval, med, mval, up2, tval);
|
||||
double mul = 1., mulmax = 255. / tval;
|
||||
if(mval < 120 || mval > 134){
|
||||
if(lval > 32) mul = 96. / mval;
|
||||
else if(mval < 127) mul = 120. / mval;
|
||||
else if(mval < 196) mul = 120. / (mval - lval);
|
||||
else if(mval < 245) mul = 96. / (tval - lval);
|
||||
else mval = 0.03;
|
||||
if(tval <= 252){ // no overexposed pixels
|
||||
if(lval < 32){ // narrow histogram with overexposed black level
|
||||
mul = 252. / tval;
|
||||
}else mul = 32. / lval;
|
||||
}else{
|
||||
if(mval > 134){
|
||||
if(mval < 245) mul = 64. / mval;
|
||||
else mul = 0.1;
|
||||
}
|
||||
}
|
||||
if(mul > mulmax) mul = mulmax;
|
||||
green("Recommended exposition time: %.2f seconds\n", img->exptime * mul);
|
||||
double E = img->exptime * mul;
|
||||
if(E < 5e-5) E = 5e-5; // too short exposition
|
||||
else if(E > 120.) E = 120.; // no need to do expositions larger than 2 minutes
|
||||
green("Recommended exposition time: %g seconds\n", E);
|
||||
exp_calculated = E;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -436,7 +449,11 @@ int writedump(imstorage *img){
|
||||
*/
|
||||
int store_image(imstorage *img){
|
||||
int status = 0;
|
||||
if(!img->imdata && !get_imdata(img)) return 1;
|
||||
if((!img->imdata
|
||||
#ifndef CLIENT
|
||||
&& !get_imdata(img)
|
||||
#endif
|
||||
) || !img->W || !img->H) return 1;
|
||||
print_stat(img);
|
||||
if(img->imformat & FORMAT_TIFF){ // save tiff file
|
||||
if(writetiff(img)) status |= 1;
|
||||
|
||||
@ -68,9 +68,14 @@ typedef struct{
|
||||
time_t exposetime; // time of exposition start
|
||||
} imstorage;
|
||||
|
||||
extern double exp_calculated;
|
||||
|
||||
imstorage *chk_storeimg(char *filename, char* store, char *format);
|
||||
int store_image(imstorage *filename);
|
||||
void print_stat(imstorage *img);
|
||||
#ifndef CLIENT
|
||||
uint16_t *get_imdata(imstorage *img);
|
||||
#endif
|
||||
int save_histo(FILE *f, imstorage *img);
|
||||
|
||||
#endif // __IMFUNCTIONS_H__
|
||||
|
||||
72
main.c
72
main.c
@ -19,31 +19,44 @@
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
#include "usefull_macros.h"
|
||||
#include <sys/wait.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <signal.h>
|
||||
#include "term.h"
|
||||
#ifndef EBUG
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#ifndef CLIENT
|
||||
#include "term.h"
|
||||
#endif
|
||||
#include "cmdlnopts.h"
|
||||
#include "imfunctions.h"
|
||||
#if defined CLIENT || defined DAEMON
|
||||
#include "socket.h"
|
||||
#endif
|
||||
|
||||
void signals(int signo){
|
||||
#ifndef CLIENT
|
||||
abort_image();
|
||||
restore_console();
|
||||
restore_tty();
|
||||
#endif
|
||||
exit(signo);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
initial_setup();
|
||||
for(int i = 0; i < 255; ++i) signal(i, signals);
|
||||
signal(SIGTSTP, SIG_IGN); // ctrl+Z - ignore
|
||||
signal(SIGQUIT, SIG_IGN); // ctrl+\ - ignore
|
||||
|
||||
signal(SIGTERM, signals); // kill (-15) - quit
|
||||
signal(SIGHUP, SIG_IGN); // hup - ignore
|
||||
signal(SIGINT, signals); // ctrl+C - quit
|
||||
signal(SIGQUIT, signals); // ctrl+\ - quit
|
||||
signal(SIGTSTP, SIG_IGN); // ignore ctrl+Z
|
||||
glob_pars *G = parse_args(argc, argv);
|
||||
printf("sp: %d\n", G->splist);
|
||||
|
||||
imstorage *img = NULL;
|
||||
imsubframe *F = NULL;
|
||||
|
||||
#ifndef CLIENT
|
||||
if(G->splist) list_speeds();
|
||||
if(G->daemon && G->terminal){
|
||||
WARNX(_("Options --daemon and --terminal can't be together!"));
|
||||
return 1;
|
||||
}
|
||||
if(!try_connect(G->device, G->speed)){
|
||||
WARNX(_("Check power and connection: device not answer!"));
|
||||
return 1;
|
||||
@ -56,41 +69,60 @@ int main(int argc, char **argv){
|
||||
WARNX(_("Can't send shutter command: %s"), G->shutter_cmd);
|
||||
if(G->heater != HEATER_LEAVE)
|
||||
heater(G->heater); // turn on/off heater
|
||||
#if !defined DAEMON && !defined CLIENT
|
||||
if(G->takeimg){
|
||||
imsubframe *F = NULL;
|
||||
#endif
|
||||
if(G->subframe){
|
||||
if(!(F = define_subframe(G->subframe)))
|
||||
ERRX(_("Error defining subframe"));
|
||||
G->binning = 0xff; // take subframe
|
||||
}
|
||||
imstorage *img = chk_storeimg(G->outpfname, G->imstoretype, G->imformat);
|
||||
#endif // !CLIENT
|
||||
#ifndef DAEMON
|
||||
img = chk_storeimg(G->outpfname, G->imstoretype, G->imformat);
|
||||
#else
|
||||
img = MALLOC(imstorage, 1); // just allocate empty: all we need in daemon is exposition & binning
|
||||
#endif
|
||||
#ifndef CLIENT
|
||||
if(img){
|
||||
DBG("OK");
|
||||
img->subframe = F;
|
||||
img->exptime = G->exptime;
|
||||
img->binning = G->binning;
|
||||
if(start_exposition(img, G->imtype)){
|
||||
|
||||
if(start_exposition(img, G->imtype)){ // start test exposition even in daemon
|
||||
WARNX(_("Error starting exposition"));
|
||||
}else{
|
||||
if(!get_imdata(img)){
|
||||
WARNX(_("Error image transfer"));
|
||||
}else{
|
||||
#ifndef DAEMON
|
||||
if(store_image(img))
|
||||
WARNX(_("Error storing image"));
|
||||
#endif // !DAEMON
|
||||
}
|
||||
}
|
||||
FREE(img->imname);
|
||||
FREE(img->imdata);
|
||||
FREE(img);
|
||||
}
|
||||
FREE(F);
|
||||
#endif // !CLIENT
|
||||
#if !defined DAEMON && !defined CLIENT
|
||||
}
|
||||
if(G->daemon || G->terminal){
|
||||
if(G->terminal){
|
||||
red(_("All other commandline options rejected!\n"));
|
||||
if(G->terminal) run_terminal(); // non-echo terminal mode
|
||||
if(G->daemon) daemonize();
|
||||
run_terminal(); // non-echo terminal mode
|
||||
}
|
||||
#endif // !defined DAEMON && !defined CLIENT
|
||||
#if defined CLIENT || defined DAEMON
|
||||
daemonize(img, G->hostname, G->port);
|
||||
#endif
|
||||
if(img){
|
||||
FREE(img->imname);
|
||||
FREE(img->imdata);
|
||||
FREE(img);
|
||||
}
|
||||
FREE(F);
|
||||
#if !defined DAEMON && !defined CLIENT
|
||||
if(!G->shutter_cmd){ // close shutter if there wasn't direct command to do something else
|
||||
shutter_command("ck");
|
||||
}
|
||||
#endif // !defined DAEMON && !defined CLIENT
|
||||
}
|
||||
|
||||
@ -26,15 +26,20 @@ long_line_behaviour=1
|
||||
long_line_column=100
|
||||
|
||||
[files]
|
||||
current_page=0
|
||||
FILE_NAME_0=240;Make;0;EUTF-8;1;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2FMakefile;0;4
|
||||
FILE_NAME_1=1333;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fmain.c;0;4
|
||||
FILE_NAME_2=5126;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fterm.c;0;4
|
||||
FILE_NAME_3=0;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fterm.h;0;4
|
||||
FILE_NAME_4=0;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fcmdlnopts.c;0;4
|
||||
FILE_NAME_5=0;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fcmdlnopts.h;0;4
|
||||
FILE_NAME_6=1494;Make;0;EUTF-8;1;1;0;%2Fhome%2Feddy%2FDropbox%2FProjects%2Fstm32samples%2FF0-nolib%2Fblink%2FMakefile;0;4
|
||||
FILE_NAME_7=4569;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fusefull_macros.c;0;4
|
||||
current_page=12
|
||||
FILE_NAME_0=684;Make;0;EUTF-8;1;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2FMakefile;0;4
|
||||
FILE_NAME_1=1058;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fmain.c;0;4
|
||||
FILE_NAME_2=3665;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fcmdlnopts.c;0;4
|
||||
FILE_NAME_3=2158;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fcmdlnopts.h;0;4
|
||||
FILE_NAME_4=2541;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fterm.c;0;4
|
||||
FILE_NAME_5=3090;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fterm.h;0;4
|
||||
FILE_NAME_6=2204;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fimfunctions.h;0;4
|
||||
FILE_NAME_7=14598;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fimfunctions.c;0;4
|
||||
FILE_NAME_8=736;C++;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2Fdemosaic%2Fsrc%2Fio_tiff.cpp;0;4
|
||||
FILE_NAME_9=959;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2Fdemosaic%2Fsrc%2Fio_tiff.h;0;4
|
||||
FILE_NAME_10=4748;C++;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2Fdemosaic%2Fsrc%2FdemosaickingIpol.cpp;0;4
|
||||
FILE_NAME_11=1322;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Ftestimages%2Finotify.c;0;4
|
||||
FILE_NAME_12=67;Markdown;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2FReadme.md;0;4
|
||||
|
||||
[VTE]
|
||||
last_dir=/home/eddy/Docs/SAO/Cameras/FLI_camera/my/Mytakepic
|
||||
|
||||
58
term.c
58
term.c
@ -18,6 +18,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef CLIENT
|
||||
|
||||
#include "usefull_macros.h"
|
||||
#include "term.h"
|
||||
#include <strings.h> // strncasecmp
|
||||
@ -96,7 +98,7 @@ trans_status wait_checksum(){
|
||||
int r;
|
||||
double d0 = dtime();
|
||||
do{
|
||||
if((r = read_tty(&chr, 1))) break;
|
||||
if((r = read_tty(&chr, 1)) && chr == last_chksum) break;
|
||||
DBG("wait..");
|
||||
}while(dtime() - d0 < WAIT_TMOUT);
|
||||
if(dtime() - d0 >= WAIT_TMOUT) return TRANS_TIMEOUT;
|
||||
@ -208,6 +210,7 @@ int try_connect(char *device, int speed){
|
||||
green(_("Connecting to %s... "), device);
|
||||
for(curspd = spdstart; curspd < spdmax; ++curspd){
|
||||
tty_init(device, Bspeeds[curspd]);
|
||||
read_tty(tmpbuf, 4096); // clear rbuf
|
||||
DBG("Try speed %d", speeds[curspd]);
|
||||
int ctr;
|
||||
for(ctr = 0; ctr < 10; ++ctr){ // 10 tries to send data
|
||||
@ -326,12 +329,6 @@ void run_terminal(){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run as daemon
|
||||
*/
|
||||
void daemonize(){
|
||||
}
|
||||
|
||||
void heater(heater_cmd cmd){
|
||||
if(cmd == HEATER_LEAVE) return;
|
||||
uint8_t buf[2] = {CMD_HEATER, 0};
|
||||
@ -477,11 +474,12 @@ int start_exposition(imstorage *im, char *imtype){
|
||||
FNAME();
|
||||
double exptime = im->exptime;
|
||||
uint64_t exp100us = exptime * 10000.;
|
||||
uint8_t cmd[6] = {CMD_TAKE_IMAGE};
|
||||
static uint8_t cmd[6] = {CMD_TAKE_IMAGE}; // `static` to save all data after first call
|
||||
int binning = im->binning;
|
||||
image_type it = IMTYPE_AUTODARK;
|
||||
const char *m = "autodark";
|
||||
if(exptime < 5e-5){// 50us
|
||||
WARNX(_("Exposition time should be not less than 1us"));
|
||||
WARNX(_("Exposition time should be not less than 50us"));
|
||||
return 1;
|
||||
}
|
||||
DBG("exp: %lu", exp100us);
|
||||
@ -503,21 +501,25 @@ int start_exposition(imstorage *im, char *imtype){
|
||||
}else b = "subframe";
|
||||
cmd[4] = binning;
|
||||
// and now check image type
|
||||
if(!imtype) return 4;
|
||||
int L = strlen(imtype);
|
||||
if(!L){ WARNX(_("Empty image type")); return 4;}
|
||||
const char *m = "autodark";
|
||||
if(0 == strncasecmp(imtype, "autodark", L)){
|
||||
if(binning == 0){
|
||||
WARNX(_("Auto dark mode don't support full image"));
|
||||
return 5;
|
||||
if(imtype){
|
||||
int L = strlen(imtype);
|
||||
if(!L){ WARNX(_("Empty image type")); return 4;}
|
||||
if(0 == strncasecmp(imtype, "autodark", L)){
|
||||
if(binning == 0){
|
||||
WARNX(_("Auto dark mode don't support full image"));
|
||||
return 5;
|
||||
}
|
||||
cmd[5] = 2;}
|
||||
else if(0 == strncasecmp(imtype, "dark", L)) { cmd[5] = 0; m = "dark"; it = IMTYPE_DARK; }
|
||||
else if(0 == strncasecmp(imtype, "light", L)){ cmd[5] = 1; m = "light"; it = IMTYPE_LIGHT;}
|
||||
else{
|
||||
WARNX(_("Wrong image type: %s, should be \"autodark\", \"light\" or \"dark\""), imtype);
|
||||
return 6;
|
||||
}
|
||||
cmd[5] = 2;}
|
||||
else if(0 == strncasecmp(imtype, "dark", L)) { cmd[5] = 0; m = "dark"; it = IMTYPE_DARK; }
|
||||
else if(0 == strncasecmp(imtype, "light", L)){ cmd[5] = 1; m = "light"; it = IMTYPE_LIGHT;}
|
||||
else{
|
||||
WARNX(_("Wrong image type: %s, should be \"autodark\", \"light\" or \"dark\""), imtype);
|
||||
return 6;
|
||||
}else{
|
||||
it = im->imtype;
|
||||
if(it == IMTYPE_DARK) m = "dark";
|
||||
else if(it == IMTYPE_LIGHT) m = "light";
|
||||
}
|
||||
if(it != IMTYPE_DARK){
|
||||
if(shutter_command("ok")){ // open shutter
|
||||
@ -548,6 +550,7 @@ int start_exposition(imstorage *im, char *imtype){
|
||||
break;
|
||||
case 0xff: // subframe
|
||||
W = H = im->subframe->size;
|
||||
DBG("subfrsz: %d", im->subframe->size);
|
||||
break;
|
||||
case 0: // full image
|
||||
default:
|
||||
@ -555,6 +558,7 @@ int start_exposition(imstorage *im, char *imtype){
|
||||
H = IMHEIGHT;
|
||||
}
|
||||
im->W = W; im->H = H;
|
||||
DBG("W=%zd, H=%zd\n", im->W, im->H);
|
||||
im->exposetime = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
@ -608,7 +612,8 @@ int wait4image(){
|
||||
*/
|
||||
uint16_t *get_image(imstorage *img){
|
||||
char *iptr = indi;
|
||||
size_t L = img->W * img->H, rest = L * 2; // rest is datasize in bytes
|
||||
size_t L = img->W * img->H, rest = L * sizeof(uint16_t); // rest is datasize in bytes
|
||||
DBG("L = %zd, W=%zd, H=%zd", L, img->W, img->H);
|
||||
uint16_t *buff = MALLOC(uint16_t, L);
|
||||
if(TRANS_SUCCEED != send_cmd_cs(CMD_XFER_IMAGE)){
|
||||
WARNX(_("Error sending transfer command"));
|
||||
@ -681,8 +686,8 @@ uint16_t *get_image(imstorage *img){
|
||||
download_in_progress = 0;
|
||||
return NULL;
|
||||
}
|
||||
//DBG("portion %d", ++i);
|
||||
rest -= need - 1;
|
||||
//DBG("need: %zd", need);
|
||||
bptr = ptr;
|
||||
}while(rest);
|
||||
printf("\b Done!\n");
|
||||
@ -690,3 +695,6 @@ uint16_t *get_image(imstorage *img){
|
||||
download_in_progress = 0;
|
||||
return buff;
|
||||
}
|
||||
|
||||
|
||||
#endif // CLIENT
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user