稳定版
authorfuqipeng <1285534278@qq.com>
Thu, 2 Mar 2023 03:10:30 +0000 (11:10 +0800)
committerfuqipeng <1285534278@qq.com>
Thu, 2 Mar 2023 03:10:30 +0000 (11:10 +0800)
Modules/hotcameramodule.cpp
Modules/main.cpp
Modules/mynetmanager.cpp

index 946d44914bd7ab2e9510c66caac12b2512ecbea8..27f3ea039ddd4b702b18d6a2a9d57fc9175e9317 100644 (file)
@@ -118,21 +118,32 @@ void HotCameraModule::moduleParaReadFromFile(HotCameraPara *p)
     {
         QTextStream in(&file);
         p->IP_Adress = in.readLine();
+        qDebug()<<QString("IP_Adress %1").arg( p->IP_Adress);
         p->month = in.readLine().toInt();
+        qDebug()<<QString("month %1").arg( p->month);
         p->week = in.readLine().toInt();
+        qDebug()<<QString("week %1").arg( p->week);
         p->day = in.readLine().toInt();
+        qDebug()<<QString("day %1").arg( p->day);
 
         QString temp = in.readLine();
+        qDebug()<<QString("temp ")<<temp;
         QString hours =temp.left(temp.length()-2);
+        qDebug()<<QString("hours ")<<hours;
         QString minutes =temp.right(2);
+        qDebug()<<QString("hours ")<<minutes;
         p->start_hour = hours.toUInt();
         p->start_minute = minutes.toUInt();
 
         temp = in.readLine();
+        qDebug()<<QString("temp ")<<temp;
+
         hours =temp.left(temp.length()-2);
         minutes =temp.right(2);
         p->end_hour = hours.toUInt();
+        qDebug()<<QString("end_hour %1").arg( p->end_hour);
         p->end_minute = minutes.toUInt();
+        qDebug()<<QString("end_minute %1").arg( p->end_minute);
 
         p->reflectivetemperature = in.readLine().toInt();
         p->emissivity = in.readLine().toFloat();
@@ -338,7 +349,9 @@ bool HotCameraModule::eventTimeChangeCheck()
     {
         qDebug()<< QString("%1 changed!").arg(time_change_file);
         //更新参数文件,时间范围值会被更新
-        moduleParaReadFromFile(&para);
+//        HotCameraPara temp;
+//        moduleParaReadFromFile(&temp);
+//        memcpy(&para, & temp, sizeof(HotCameraPara));
 
         QFile file_change_time(time_change_file);
         file_change_time.remove();
@@ -367,7 +380,7 @@ bool HotCameraModule::eventConnectTimeCheck()
             modleDisConnect();
         }
 
-    }else if(net->KeepState() != NET_DISCONNECT){
+    }else {
         modleDisConnect();
     }
 
@@ -443,5 +456,7 @@ void HotCameraModule::moduleConnect()
 
 void HotCameraModule::modleDisConnect()
 {
-   net->KeepDisconnect();
+    if(net->KeepState() != NET_DISCONNECT){
+         net->KeepDisconnect();
+    }
 }
index d8a48be904488df24bac05dac919ff570df22fce..6ba3ece6408387d49ea5f9dfd5a607b4436d1559 100644 (file)
 #include "hotcameramodule.h"
 
 
+#ifndef WIN32
+
+#include <execinfo.h>
+#include <signal.h>
+#include <stdio.h>
+#include<unistd.h>
+static void print_memory_base(void)
+{
+    char strbuf[512];
+    pid_t pid = getpid();
+    FILE *pf;
+
+    sprintf(strbuf, "/proc/%d/maps", pid);
+    pf = fopen(strbuf, "r");
+    if(NULL == pf) return;
+    while(fgets(strbuf, sizeof(strbuf), pf) != NULL) {
+        printf("%s", strbuf);
+    }
+    fclose(pf);
+}
+static void print_stack_trace(void)
+{
+    char strbuf[256], *pstr;
+    void *array[64];
+    size_t size, i;
+    char **strings;
+
+    size = backtrace(array, 64);
+    strings = backtrace_symbols(array, size);
+    //printf ("Obtained %zd stack frames.\n", size);
+
+    pstr = strbuf;
+    for(i=1; i<=size; i++) {
+        sprintf(pstr, "%08X:", (int)array[i]);
+        pstr += strlen(pstr);
+        if(0 == (i%8)) {
+            printf("%s\n", strbuf);
+            pstr = strbuf;
+        }
+    }
+    if(pstr != strbuf) {
+        printf("%s\n", strbuf);
+    }
+
+    for(i=0; i<size; i++) {
+        printf("%s\n", strings[i]);
+    }
+    free(strings);
+}
+static const char *signal_name(int signum)
+{
+    struct sig_name_s
+    {
+        int signum;
+        const char *name;
+    };
+    static const struct sig_name_s sig_name[] =
+    {
+        {SIGFPE, "SIGFPE"},
+        {SIGINT, "SIGINT"},
+        {SIGQUIT, "SIGQUIT"},
+        {SIGILL, "SIGILL"},
+        {SIGABRT, "SIGABRT"},
+        {SIGPIPE, "SIGPIPE"},
+        {SIGTERM, "SIGTERM"},
+        {SIGTSTP, "SIGTSTP"},
+        {SIGSEGV, "SIGSEGV"},
+    };
+    static const char *def_name = "unknown";
+
+    for(size_t i=0; i<(sizeof(sig_name)/sizeof(sig_name[0])); i++)
+    {
+        if(signum == sig_name[i].signum)
+            return sig_name[i].name;
+    }
+
+    return def_name;
+}
+static void signal_proc(int signum)
+{
+    const char *signame = signal_name(signum);
+
+    printf("\n!!error!!catch signal %d(%s)\n", signum, signame);
+    print_stack_trace();
+    print_memory_base();
+
+    signal(signum, SIG_DFL);
+    raise(signum);
+}
+
+void debug_install_signal(void)
+{
+    signal(SIGFPE, signal_proc);               // 数学相关异常
+    signal(SIGINT, signal_proc);        //中断进程  Ctrl-C
+    signal(SIGQUIT, signal_proc);
+    signal(SIGILL, signal_proc);               // 非法指令异常
+    signal(SIGABRT, signal_proc);
+    signal(SIGPIPE, signal_proc);       //向一个没有读进程的管道写数据
+    signal(SIGTERM, signal_proc);       //软件终止信号
+    signal(SIGTSTP, signal_proc);
+    signal(SIGSEGV, signal_proc);              // 非法内存访问
+
+}
+
+#endif
 
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
     QThread t1, t2;
 
+#ifndef WIN32
+
+    debug_install_signal();
+#endif
+
     HotCameraModule m1(0);
     HotCameraModule m2(1);
     m1.moveToThread(&t1);
index 3a663ef498cb4481aa3c78dae5e50f10858a0093..6cbb167dce4ae0209cd3916ffc2164c69755b060 100644 (file)
@@ -195,7 +195,6 @@ bool MyNetManager::KeepDisconnect()
     if(keep == nullptr){
         return true;
     }
-
     //qDebug() << QString("disconnect\n");
     disconnect(keep,0,0,0);
     /*