Przeglądaj źródła

1、修复控制板掉线后(两次超时认为掉线)依然有数据问题;2、修改NTP线程创建成功未回收内存导致内存泄漏问题;3、增加2405项目配置

liyuezong 1 rok temu
rodzic
commit
972a8a7b8b
3 zmienionych plików z 34 dodań i 10 usunięć
  1. 16 3
      pro/config/cfg.h
  2. 15 5
      pro/src/app.c
  3. 3 2
      pro/src/ntpclient.c

+ 16 - 3
pro/config/cfg.h

@@ -32,8 +32,8 @@
 //#define PRJ_INST2106_AC_I1_O1_OLED
 //#define PRJ_YST_AC_I1_O1
 //#define PRJ_YUNNAN_AC_I1_O1
-
 //#define PRJ_DUALWIRES_AC_I3_O2
+//#define PRJ_2405_AC_I1_O1_OLED
 
 //#define PRJ_IP_AC_I3_O3
 //#define PRJ_IP_AC_I3_O1
@@ -224,6 +224,21 @@
 
     #define PROD_POWER_TYPE                     0
     //#define IN_INDEX_MAP                        {2,3,1,0}
+#elif defined PRJ_2405_AC_I1_O1_OLED
+    #define LANGUAGE                            0           //chinese
+    #define SMPLE_TIME                          30          //ms
+    #define SAVE_TIME                           60000       //ms
+    #define CASCADE_CNT                         0
+
+    #define PHASE_GROUP                         4
+    #define CHANNEL_DELAY                      4
+
+    #define PROD_POWER_TYPE                     0
+
+    #define BRD_MAX                             3
+
+    #define USE_UI
+
 #elif defined PRJ_TEST_AC_I3_O1
     #define LANGUAGE                            0           //chinese
     #define SMPLE_TIME                          30          //ms
@@ -357,8 +372,6 @@
     #define CHANNEL_DELAY                       6
 
     #define PROD_POWER_TYPE                     0
-
-    #define USE_CH_CTRL_CONFIG
 	
     #define USE_BEEP                            1
     #define USE_LED                             1

+ 15 - 5
pro/src/app.c

@@ -137,9 +137,9 @@ static void* power_thread(void* arg)
                                                 _globalDeviceManager->pCtrlBoard[i].product_number,
                                                 _globalDeviceManager->pCtrlBoard[i]._PowerInfo,
                                                 _globalDeviceManager->pCtrlBoard[i]._PowerWarninginfo);
-                if(ret < 0)
+                if(ret <0 )
                 {
-                    memset(&_globalDeviceManager->pCtrlBoard[i]._PowerInfo,0,sizeof(PowerInfo));
+                    memset(&_globalDeviceManager->pCtrlBoard[i]._PowerInfo, 0, sizeof(PowerInfo)*AC_SINGLE_S_MAX_CHN_NUM );
                 }
             }
             // 输入总信息(三相)(后续应同步所有类型)
@@ -157,6 +157,10 @@ static void* power_thread(void* arg)
                                                     _globalDeviceManager->pCtrlBoard[i].product_saddr, // saadr
                                                     _globalDeviceManager->pCtrlBoard[i]._globalPowerInManger._PowerInfo,
                                                     _globalDeviceManager->pCtrlBoard[i]._globalPowerInManger._PowerWarninginfo);
+                    if(ret <0 )
+                    {
+                        memset(&_globalDeviceManager->pCtrlBoard[i]._globalPowerInManger._PowerInfo, 0, sizeof(PowerInfo) *3);
+                    }
                 }
                 //计算控制板每相输入总功率因数
 
@@ -1026,15 +1030,21 @@ static void* power_thread(void* arg)
 
 
             //-- 临时加的通道是否可控 lyz 2025.05.01----
-#ifdef USE_CH_CTRL_CONFIG
+#ifdef PRJ_YST_AC_I1_O1
             if (_globalPowerMangerTemp->product_ch_id>6 && _globalPowerMangerTemp->product_ch_id<=10)
             {
                 _globalPowerInfo._power_info.OperAllowFlag=1;
-            }
-            
+            }   
 #endif
 
 
+#ifdef PRJ_2405_AC_I1_O1_OLED
+            if (_globalPowerMangerTemp->product_ch_id==4 )
+            {
+                _globalPowerInfo._power_info.OperAllowFlag=1;
+            }   
+#endif
+
             //全局记录一份数据
             if (!isErrorBreak)
             {

+ 3 - 2
pro/src/ntpclient.c

@@ -129,6 +129,7 @@ NTPClient* createNTPClient(const char* ntp_server, int port, int timeout_sec) {
     client->res = NULL;
     client->flag = 0;
     pthread_create(&tid, NULL, tmp_thread, client);
+    pthread_detach(tid);
     for(int i=0; i<timeout_sec; i++) {
         if(client->flag) {
             break;
@@ -138,8 +139,8 @@ NTPClient* createNTPClient(const char* ntp_server, int port, int timeout_sec) {
     if(client->flag!=1) {
         if(client->flag==0) {
             printf("___getaddrinfo timeout, cancel thread %lu\n", (unsigned long)tid);
-            pthread_cancel(tid);//SIGTERM
-            pthread_join(tid, NULL);
+           // pthread_cancel(tid);//SIGTERM
+           // pthread_join(tid, NULL);
             printf("___cancel ok!\n");
         }
         if(client->res) freeaddrinfo(client->res);