mirror of
https://github.com/eddyem/SBIG_340.git
synced 2025-12-06 02:35:12 +03:00
small fixes & add output @ command heater=xx
This commit is contained in:
parent
8bd8fdc2c2
commit
88ba66fd60
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ LDFLAGS += -lm -pthread
|
|||||||
LDIMG :=
|
LDIMG :=
|
||||||
SRCS := $(wildcard *.c)
|
SRCS := $(wildcard *.c)
|
||||||
DEFINES := $(DEF) -D_GNU_SOURCE -D_XOPEN_SOURCE=1111
|
DEFINES := $(DEF) -D_GNU_SOURCE -D_XOPEN_SOURCE=1111
|
||||||
DEFINES += -DEBUG
|
#DEFINES += -DEBUG
|
||||||
CFLAGS += -Wall -Wextra -O2
|
CFLAGS += -Wall -Wextra -O2
|
||||||
OBJS := $(SRCS:%.c=%.o)
|
OBJS := $(SRCS:%.c=%.o)
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|||||||
9
SBIG.config
Normal file
9
SBIG.config
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Add predefined macros for your project here. For example:
|
||||||
|
// #define THE_ANSWER 42
|
||||||
|
#define DAEMON 1
|
||||||
|
//#define CLIENT 1
|
||||||
|
#define STANDALONE 1
|
||||||
|
#define LIBCFITSIO 1
|
||||||
|
#define LIBRAW 1
|
||||||
|
#define LIBTIFF 1
|
||||||
|
#define EBUG 1
|
||||||
1
SBIG.creator
Normal file
1
SBIG.creator
Normal file
@ -0,0 +1 @@
|
|||||||
|
[General]
|
||||||
170
SBIG.creator.user
Normal file
170
SBIG.creator.user
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 4.8.2, 2020-07-09T12:04:02. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{cf63021e-ef53-49b0-b03b-2f2570cdf3b6}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">KOI8-R</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||||
|
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{91347f2c-5221-46a7-80b1-0a054ca02f79}</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/tmp/znd/SBIG</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||||
|
<value type="QString">all</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
|
||||||
|
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
|
||||||
|
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||||
|
<value type="QString">clean</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
|
||||||
|
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
|
||||||
|
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">По умолчанию</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Установка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Конфигурация установки</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||||
|
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||||
|
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Особая программа</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||||
|
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||||
|
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="int">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">20</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>Version</variable>
|
||||||
|
<value type="int">20</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
||||||
15
SBIG.files
Normal file
15
SBIG.files
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
cmdlnopts.c
|
||||||
|
cmdlnopts.h
|
||||||
|
debayer.cpp
|
||||||
|
debayer.h
|
||||||
|
imfunctions.c
|
||||||
|
imfunctions.h
|
||||||
|
main.c
|
||||||
|
parseargs.c
|
||||||
|
parseargs.h
|
||||||
|
socket.c
|
||||||
|
socket.h
|
||||||
|
term.c
|
||||||
|
term.h
|
||||||
|
usefull_macros.c
|
||||||
|
usefull_macros.h
|
||||||
1
SBIG.includes
Normal file
1
SBIG.includes
Normal file
@ -0,0 +1 @@
|
|||||||
|
.
|
||||||
@ -46,7 +46,7 @@ glob_pars const Gdefault = {
|
|||||||
.shutter_cmd = NULL,
|
.shutter_cmd = NULL,
|
||||||
.subframe = NULL,
|
.subframe = NULL,
|
||||||
.speed = 0,
|
.speed = 0,
|
||||||
.exptime = 1.,
|
.exptime = 1e-4,
|
||||||
.binning = 0,
|
.binning = 0,
|
||||||
.takeimg = 0,
|
.takeimg = 0,
|
||||||
.imtype = "l",
|
.imtype = "l",
|
||||||
|
|||||||
@ -21,12 +21,16 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "usefull_macros.h"
|
|
||||||
#include "imfunctions.h"
|
#include "imfunctions.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
#include <strings.h> // strncasecmp
|
#include "usefull_macros.h"
|
||||||
|
|
||||||
|
#include <fcntl.h> // AT_...
|
||||||
|
#include <libgen.h> // basename
|
||||||
#include <math.h> // sqrt
|
#include <math.h> // sqrt
|
||||||
#include <time.h> // time, gmtime etc
|
#include <strings.h> // strncasecmp
|
||||||
|
#include <sys/stat.h> // utimensat
|
||||||
|
|
||||||
#ifndef DAEMON
|
#ifndef DAEMON
|
||||||
#ifdef LIBRAW
|
#ifdef LIBRAW
|
||||||
#include "debayer.h"
|
#include "debayer.h"
|
||||||
@ -38,9 +42,6 @@
|
|||||||
#include <tiffio.h> // save tiff
|
#include <tiffio.h> // save tiff
|
||||||
#endif // LIBTIFF
|
#endif // LIBTIFF
|
||||||
#endif // !DAEMON
|
#endif // !DAEMON
|
||||||
#include <libgen.h> // basename
|
|
||||||
#include <sys/stat.h> // utimensat
|
|
||||||
#include <fcntl.h> // AT_...
|
|
||||||
|
|
||||||
double exp_calculated = -1.; // optimal exposition, calculated in histogram saver
|
double exp_calculated = -1.; // optimal exposition, calculated in histogram saver
|
||||||
/**
|
/**
|
||||||
@ -245,8 +246,8 @@ void print_stat(imstorage *img){
|
|||||||
printf(_("Image stat:\n"));
|
printf(_("Image stat:\n"));
|
||||||
double avr = sum/sz, std = sqrt(fabs(sum2/sz - avr*avr));
|
double avr = sum/sz, std = sqrt(fabs(sum2/sz - avr*avr));
|
||||||
glob_avr = avr, glob_std = std, glob_max = max, glob_min = min;
|
glob_avr = avr, glob_std = std, glob_max = max, glob_min = min;
|
||||||
printf("avr = %.1f, std = %.1f, Noverload = %ld\n", avr, std, Noverld);
|
printf("avr = %.1f, std = %.1f, Noverload = %zd\n", avr, std, Noverld);
|
||||||
printf("max = %u, min = %u, W*H = %ld\n", max, min, size);
|
printf("max = %u, min = %u, W*H = %zd\n", max, min, size);
|
||||||
Noverld = 0L;
|
Noverld = 0L;
|
||||||
ptr = img->imdata; sum = 0.; sum2 = 0.;
|
ptr = img->imdata; sum = 0.; sum2 = 0.;
|
||||||
tres = avr + 3. * std; // max treshold == 3sigma
|
tres = avr + 3. * std; // max treshold == 3sigma
|
||||||
@ -267,7 +268,7 @@ void print_stat(imstorage *img){
|
|||||||
}
|
}
|
||||||
sz = (double)N;
|
sz = (double)N;
|
||||||
avr = sum/sz; std = sqrt(fabs(sum2/sz - avr*avr));
|
avr = sum/sz; std = sqrt(fabs(sum2/sz - avr*avr));
|
||||||
printf("At 3sigma: Noverload = %ld, avr = %.3f, std = %.3f\n", Noverld, avr, std);
|
printf("At 3sigma: Noverload = %zd, avr = %.3f, std = %.3f\n", Noverld, avr, std);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DAEMON
|
#ifndef DAEMON
|
||||||
@ -525,7 +526,7 @@ int store_image(imstorage *img){
|
|||||||
static double lastdtime = 0.;
|
static double lastdtime = 0.;
|
||||||
if(img->imtype != IMTYPE_DARK){ // store debayer only if image type isn't dark
|
if(img->imtype != IMTYPE_DARK){ // store debayer only if image type isn't dark
|
||||||
int lowval = glob_avr - 3*glob_std;
|
int lowval = glob_avr - 3*glob_std;
|
||||||
if(glob_min > lowval) lowval = glob_min + glob_std/2;
|
if(glob_min > lowval) lowval = glob_min + glob_std/3;
|
||||||
if(dark) do{
|
if(dark) do{
|
||||||
if(dtime() - lastdtime > 3600.){ // not more than 1 hour
|
if(dtime() - lastdtime > 3600.){ // not more than 1 hour
|
||||||
putlog("Dark too old");
|
putlog("Dark too old");
|
||||||
@ -550,7 +551,7 @@ int store_image(imstorage *img){
|
|||||||
else *iptr = 0;
|
else *iptr = 0;
|
||||||
}
|
}
|
||||||
putlog("Dark extracted");
|
putlog("Dark extracted");
|
||||||
lowval = 1+glob_std/2;
|
lowval = 1+glob_std/3;
|
||||||
}while(0);
|
}while(0);
|
||||||
if(write_debayer(img, (uint16_t)lowval)) status |= 8; // and save colour image
|
if(write_debayer(img, (uint16_t)lowval)) status |= 8; // and save colour image
|
||||||
}else{ // save last dark
|
}else{ // save last dark
|
||||||
|
|||||||
@ -23,7 +23,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __IMFUNCTIONS_H__
|
#ifndef __IMFUNCTIONS_H__
|
||||||
#define __IMFUNCTIONS_H__
|
#define __IMFUNCTIONS_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h> // time, gmtime etc
|
||||||
|
|
||||||
// how to save files: rewrite, check existance or add number
|
// how to save files: rewrite, check existance or add number
|
||||||
typedef enum{
|
typedef enum{
|
||||||
|
|||||||
13
main.c
13
main.c
@ -53,8 +53,10 @@ int main(int argc, char **argv){
|
|||||||
signal(SIGQUIT, signals); // ctrl+\ - quit
|
signal(SIGQUIT, signals); // ctrl+\ - quit
|
||||||
signal(SIGTSTP, SIG_IGN); // ignore ctrl+Z
|
signal(SIGTSTP, SIG_IGN); // ignore ctrl+Z
|
||||||
glob_pars *G = parse_args(argc, argv);
|
glob_pars *G = parse_args(argc, argv);
|
||||||
if(G->rest_pars_num)
|
#if defined DAEMON || defined CLIENT
|
||||||
openlogfile(G->rest_pars[0]);
|
char *logname = NULL;
|
||||||
|
if(G->rest_pars_num) logname = G->rest_pars[0];
|
||||||
|
#endif
|
||||||
imstorage *img = NULL;
|
imstorage *img = NULL;
|
||||||
imsubframe *F = NULL;
|
imsubframe *F = NULL;
|
||||||
#ifndef CLIENT
|
#ifndef CLIENT
|
||||||
@ -69,23 +71,18 @@ int main(int argc, char **argv){
|
|||||||
#if defined DAEMON || defined CLIENT
|
#if defined DAEMON || defined CLIENT
|
||||||
if(!G->once){
|
if(!G->once){
|
||||||
#ifndef EBUG
|
#ifndef EBUG
|
||||||
putlog("Daemonize");
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if(daemon(1, 0)){
|
if(daemon(1, 0)){
|
||||||
putlog("Can't daemonize");
|
|
||||||
ERR("daemon()");
|
ERR("daemon()");
|
||||||
}
|
}
|
||||||
#endif // EBUG
|
#endif // EBUG
|
||||||
while(1){ // guard for dead processes
|
while(1){ // guard for dead processes
|
||||||
pid_t childpid = fork();
|
pid_t childpid = fork();
|
||||||
if(childpid){
|
if(childpid){
|
||||||
putlog("Create child with PID %d\n", childpid);
|
|
||||||
DBG("Create child with PID %d\n", childpid);
|
|
||||||
wait(NULL);
|
wait(NULL);
|
||||||
putlog("Child %d died\n", childpid);
|
|
||||||
WARNX("Child %d died\n", childpid);
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}else{
|
}else{
|
||||||
|
if(logname) openlogfile(logname);
|
||||||
prctl(PR_SET_PDEATHSIG, SIGTERM); // send SIGTERM to child when parent dies
|
prctl(PR_SET_PDEATHSIG, SIGTERM); // send SIGTERM to child when parent dies
|
||||||
break; // go out to normal functional
|
break; // go out to normal functional
|
||||||
}
|
}
|
||||||
|
|||||||
6076
sbig340.c.tags
6076
sbig340.c.tags
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@
|
|||||||
[editor]
|
|
||||||
line_wrapping=false
|
|
||||||
line_break_column=100
|
|
||||||
auto_continue_multiline=true
|
|
||||||
|
|
||||||
[file_prefs]
|
|
||||||
final_new_line=true
|
|
||||||
ensure_convert_new_lines=true
|
|
||||||
strip_trailing_spaces=true
|
|
||||||
replace_tabs=true
|
|
||||||
|
|
||||||
[indentation]
|
|
||||||
indent_width=4
|
|
||||||
indent_type=0
|
|
||||||
indent_hard_tab_width=4
|
|
||||||
detect_indent=false
|
|
||||||
detect_indent_width=false
|
|
||||||
indent_mode=3
|
|
||||||
|
|
||||||
[project]
|
|
||||||
name=SBIG340
|
|
||||||
base_path=/home/eddy/Docs/SAO/Cameras/SBIG/allsky_340/SBIG_340/
|
|
||||||
description=
|
|
||||||
|
|
||||||
[long line marker]
|
|
||||||
long_line_behaviour=1
|
|
||||||
long_line_column=100
|
|
||||||
|
|
||||||
[files]
|
|
||||||
current_page=5
|
|
||||||
FILE_NAME_0=2657;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fmain.c;0;4
|
|
||||||
FILE_NAME_1=3442;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fimfunctions.c;0;4
|
|
||||||
FILE_NAME_2=1637;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fimfunctions.h;0;4
|
|
||||||
FILE_NAME_3=1077;C;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fdebayer.h;0;4
|
|
||||||
FILE_NAME_4=2547;C++;0;EUTF-8;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fdebayer.cpp;0;4
|
|
||||||
FILE_NAME_5=707;Make;0;EUTF-8;1;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2FMakefile;0;4
|
|
||||||
FILE_NAME_6=11756;C;0;EKOI8-R;0;1;0;%2Fhome%2Feddy%2FDocs%2FSAO%2FCameras%2FSBIG%2Fallsky_340%2FSBIG_340%2Fsocket.c;0;4
|
|
||||||
|
|
||||||
[VTE]
|
|
||||||
last_dir=/home/eddy/Docs/SAO/Cameras/FLI_camera/my/Mytakepic
|
|
||||||
48
socket.c
48
socket.c
@ -21,17 +21,19 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if defined CLIENT || defined DAEMON
|
#if defined CLIENT || defined DAEMON
|
||||||
#include "usefull_macros.h"
|
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
#include <netdb.h> // addrinfo
|
#include "usefull_macros.h"
|
||||||
|
|
||||||
#include <arpa/inet.h> // inet_ntop
|
#include <arpa/inet.h> // inet_ntop
|
||||||
#include <pthread.h>
|
|
||||||
#include <limits.h> // INT_xxx
|
#include <limits.h> // INT_xxx
|
||||||
|
#include <netdb.h> // addrinfo
|
||||||
|
#include <pthread.h>
|
||||||
#include <signal.h> // pthread_kill
|
#include <signal.h> // pthread_kill
|
||||||
#include <unistd.h> // daemon
|
|
||||||
#include <sys/wait.h> // wait
|
|
||||||
#include <sys/prctl.h> //prctl
|
#include <sys/prctl.h> //prctl
|
||||||
|
#include <sys/wait.h> // wait
|
||||||
|
#include <unistd.h> // daemon
|
||||||
|
|
||||||
#define BUFLEN (10240)
|
#define BUFLEN (10240)
|
||||||
#define BUFLEN10 (1048576)
|
#define BUFLEN10 (1048576)
|
||||||
@ -153,10 +155,18 @@ static imstorage *copyima(imstorage *im){
|
|||||||
return storedima;
|
return storedima;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int addwebhdr(char *buf, size_t buflen, char *conttype, size_t contlen){
|
||||||
|
return snprintf(buf, buflen,
|
||||||
|
"HTTP/2.0 200 OK\r\n"
|
||||||
|
"Access-Control-Allow-Origin: *\r\n"
|
||||||
|
"Access-Control-Allow-Methods: GET, POST\r\n"
|
||||||
|
"Access-Control-Allow-Credentials: true\r\n"
|
||||||
|
"Content-type: %s\r\nContent-Length: %zd\r\n\r\n", conttype, contlen);
|
||||||
|
}
|
||||||
|
|
||||||
int send_ima(int sock, int webquery){
|
int send_ima(int sock, int webquery){
|
||||||
uint8_t buf[BUFLEN10], *bptr = buf, obuff[BUFLEN];
|
uint8_t buf[BUFLEN10], *bptr = buf, obuff[BUFLEN];
|
||||||
ssize_t Len;
|
int Len, rest = BUFLEN10, imS = storedima->W * storedima->H * sizeof(uint16_t);
|
||||||
size_t rest = BUFLEN10, imS = storedima->W * storedima->H * sizeof(uint16_t);
|
|
||||||
#define PUT(key, val) do{Len = snprintf((char*)bptr, rest, "%s=%i\n", key, (int)storedima->val); \
|
#define PUT(key, val) do{Len = snprintf((char*)bptr, rest, "%s=%i\n", key, (int)storedima->val); \
|
||||||
if(Len > 0){rest -= Len; bptr += Len;}}while(0)
|
if(Len > 0){rest -= Len; bptr += Len;}}while(0)
|
||||||
PUT("binning", binning);
|
PUT("binning", binning);
|
||||||
@ -174,7 +184,7 @@ int send_ima(int sock, int webquery){
|
|||||||
Len = snprintf((char*)bptr, rest, "imdata=");
|
Len = snprintf((char*)bptr, rest, "imdata=");
|
||||||
if(Len){rest -= Len; bptr += Len;}
|
if(Len){rest -= Len; bptr += Len;}
|
||||||
if(rest < imS){
|
if(rest < imS){
|
||||||
red("rest = %zd, need %zd\n", rest, imS);
|
red("rest = %d, need %d\n", rest, imS);
|
||||||
return 0; // not enough memory - HOW???
|
return 0; // not enough memory - HOW???
|
||||||
}
|
}
|
||||||
if(!memcpy(bptr, storedima->imdata, imS)){
|
if(!memcpy(bptr, storedima->imdata, imS)){
|
||||||
@ -183,15 +193,10 @@ int send_ima(int sock, int webquery){
|
|||||||
}
|
}
|
||||||
rest -= imS;
|
rest -= imS;
|
||||||
// send data
|
// send data
|
||||||
size_t send = BUFLEN10 - rest;
|
int send = BUFLEN10 - rest;
|
||||||
// OK buffer ready, prepare to send it
|
// OK buffer ready, prepare to send it
|
||||||
if(webquery){
|
if(webquery){
|
||||||
Len = snprintf((char*)obuff, BUFLEN,
|
Len = addwebhdr((char*)obuff, BUFLEN, "multipart/form-data", send);
|
||||||
"HTTP/2.0 200 OK\r\n"
|
|
||||||
"Access-Control-Allow-Origin: *\r\n"
|
|
||||||
"Access-Control-Allow-Methods: GET, POST\r\n"
|
|
||||||
"Access-Control-Allow-Credentials: true\r\n"
|
|
||||||
"Content-type: multipart/form-data\r\nContent-Length: %zd\r\n\r\n", send);
|
|
||||||
if(Len < 0){
|
if(Len < 0){
|
||||||
WARN("sprintf()");
|
WARN("sprintf()");
|
||||||
return 0;
|
return 0;
|
||||||
@ -202,12 +207,12 @@ int send_ima(int sock, int webquery){
|
|||||||
}
|
}
|
||||||
DBG("%s", obuff);
|
DBG("%s", obuff);
|
||||||
}
|
}
|
||||||
red("send %zd bytes\n", send);
|
red("send %d bytes\n", send);
|
||||||
if(send != (size_t)write(sock, buf, send)){
|
if(send != write(sock, buf, send)){
|
||||||
WARN("write()");
|
WARN("write()");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
putlog("send image to client");
|
putlog("image sent to client");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +284,11 @@ void *handle_socket(void *asock){
|
|||||||
putlog("got command: heater=%ld", htr);
|
putlog("got command: heater=%ld", htr);
|
||||||
if(htr == 0) heater_off();
|
if(htr == 0) heater_off();
|
||||||
else heater_on();
|
else heater_on();
|
||||||
|
int Len = addwebhdr(buff, BUFLEN, "text/html", 12);
|
||||||
|
if(Len > 0){
|
||||||
|
Len += snprintf(buff+Len, BUFLEN, "HEATER %s\r\n", htr ? "ON " : "OFF");
|
||||||
|
write(sock, buff, Len);
|
||||||
|
}
|
||||||
break; // disconnect after command receiving
|
break; // disconnect after command receiving
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,7 +502,7 @@ void daemonize(imstorage *img, char *hostname, char *port){
|
|||||||
char str[INET_ADDRSTRLEN];
|
char str[INET_ADDRSTRLEN];
|
||||||
inet_ntop(AF_INET, &(ia->sin_addr), str, INET_ADDRSTRLEN);
|
inet_ntop(AF_INET, &(ia->sin_addr), str, INET_ADDRSTRLEN);
|
||||||
DBG("canonname: %s, port: %u, addr: %s\n", res->ai_canonname, ntohs(ia->sin_port), str);
|
DBG("canonname: %s, port: %u, addr: %s\n", res->ai_canonname, ntohs(ia->sin_port), str);
|
||||||
putlog("connect to %s:%s", hostname, port);
|
putlog("connect to port %s", port);
|
||||||
// loop through all the results and bind to the first we can
|
// loop through all the results and bind to the first we can
|
||||||
for(p = res; p != NULL; p = p->ai_next){
|
for(p = res; p != NULL; p = p->ai_next){
|
||||||
if((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1){
|
if((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1){
|
||||||
|
|||||||
8
term.c
8
term.c
@ -20,8 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef CLIENT
|
#ifndef CLIENT
|
||||||
|
|
||||||
#include "usefull_macros.h"
|
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
|
#include "usefull_macros.h"
|
||||||
|
|
||||||
#include <strings.h> // strncasecmp
|
#include <strings.h> // strncasecmp
|
||||||
#include <time.h> // time(NULL)
|
#include <time.h> // time(NULL)
|
||||||
|
|
||||||
@ -501,14 +502,17 @@ int start_exposition(imstorage *im, char *imtype){
|
|||||||
if(htr_on_time && time(NULL) - htr_on_time > heater_period){
|
if(htr_on_time && time(NULL) - htr_on_time > heater_period){
|
||||||
set_heater_off = 0;
|
set_heater_off = 0;
|
||||||
set_heater_on = 0;
|
set_heater_on = 0;
|
||||||
|
putlog("heater timeout");
|
||||||
heater(HEATER_OFF);
|
heater(HEATER_OFF);
|
||||||
htr_on_time = 0;
|
htr_on_time = 0;
|
||||||
}
|
}
|
||||||
if(set_heater_off){
|
if(set_heater_off){
|
||||||
set_heater_off = 0;
|
set_heater_off = 0;
|
||||||
|
set_heater_on = 0;
|
||||||
heater(HEATER_OFF);
|
heater(HEATER_OFF);
|
||||||
htr_on_time = 0;
|
htr_on_time = 0;
|
||||||
}else if(set_heater_on){
|
}else if(set_heater_on){
|
||||||
|
set_heater_off = 0;
|
||||||
set_heater_on = 0;
|
set_heater_on = 0;
|
||||||
heater(HEATER_ON);
|
heater(HEATER_ON);
|
||||||
htr_on_time = time(NULL);
|
htr_on_time = time(NULL);
|
||||||
@ -523,7 +527,7 @@ int start_exposition(imstorage *im, char *imtype){
|
|||||||
WARNX(_("Exposition time should be not less than 50us"));
|
WARNX(_("Exposition time should be not less than 50us"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DBG("exp: %lu", exp100us);
|
DBG("exp: %llu", (long long)exp100us);
|
||||||
cmd[1] = (exp100us >> 16) & 0xff;
|
cmd[1] = (exp100us >> 16) & 0xff;
|
||||||
cmd[2] = (exp100us >> 8) & 0xff;
|
cmd[2] = (exp100us >> 8) & 0xff;
|
||||||
cmd[3] = exp100us & 0xff;
|
cmd[3] = exp100us & 0xff;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user