Эх сурвалжийг харах

Some fixes. Update problem.

Dmitry Telenkov 10 сар өмнө
parent
commit
207804e4f7

+ 4 - 1
.vscode/settings.json

@@ -48,6 +48,9 @@
         "settings_api.h": "c",
         "board_bt6709.h": "c",
         "lwip_hook_ip4_input.h": "c",
-        "atomic": "c"
+        "atomic": "c",
+        "optional": "c",
+        "istream": "c",
+        "ostream": "c"
     }
 }

+ 1 - 1
config/board_bt6711_v1.h

@@ -52,7 +52,7 @@ WDG_PIN(X)
 /**
   * @brief  Версия прошивки
   */
-#define VERSION                         "1.8"
+#define VERSION                         "1.9"
 
 /**
   * brief  Текст сообщения при запуске CLI

+ 47 - 1
modules/MegaTec/megatec.c

@@ -879,6 +879,7 @@ void ups_buzzer_cntrl_response(char *data)
 
 void ups_mode_response(char *data)
 {
+    static char fault_status[50] = {0};
     char value[50];
     uint8_t len = 0;
     DBG printf("ups_serialresponse: %s\r\n", data);
@@ -894,6 +895,51 @@ void ups_mode_response(char *data)
 
     DBG printf("UPS ups_mode_parser_start: %s\r\n", data);
 
+    // -----------------------------------------------------------------------
+    // Тестовый 
+    // Если значение режима изменилось или режим "Fault"
+    if ((UPS.Mode != data[0]) || (data[0] == 'F')) {
+#ifdef UPS_MODE_MONITOR
+        memset(value, 0, sizeof(value));
+        GetModeStr(value, &len);
+        // В режиме "Fault" запрашиваем статус
+        if (data[0] == 'F') {
+            
+            memset(ups_pdu.data, 0, UPS_PDU_MAX_LEN);
+            send_MegaTec_cmd(ups_fault_status);
+            if (ups_megatec_rx_pdu()) {
+                if (ups_pdu.data[0] != '(' || strncmp(ups_pdu.data, "(OK", 3) == 0) {
+                    return;
+                }
+                UPS.fault_type = (ups_pdu.data[1] - 0x30) << 4 | (ups_pdu.data[2] - 0x30);
+                strncat(value, &ups_pdu.data[1], 6);
+                strncat(value, &ups_pdu.data[14], 4);
+                strncat(value, &ups_pdu.data[25], 8);
+                strncat(value, &ups_pdu.data[35], 4);
+                strncat(value, &ups_pdu.data[41], 4);
+                strncat(value, &ups_pdu.data[47], 4);
+                strncat(value, &ups_pdu.data[53], 4);
+                strncat(value, &ups_pdu.data[59], 8);
+
+                if ((strncmp(value, fault_status, sizeof(value)) != 0) || (UPS.Mode != data[0])) 
+                {
+                    SNMP_SendUserTrap(UPS_MODE);
+                    syslog(SYSLOG_INFORMATIONAL, "Режим ИБП: %s", value);
+                    log_event_data(LOG_UPS_MODE, value);
+                }
+                memcmp(fault_status, value, sizeof(value));
+            }
+        }
+        SNMP_SendUserTrap(UPS_MODE);
+        syslog(SYSLOG_INFORMATIONAL, "Режим ИБП: %s", value);
+        log_event_data(LOG_UPS_MODE, value);
+#endif        
+        UPS.Mode = data[0];
+    }
+    // -----------------------------------------------------------------------
+
+
+#if 0 // Пока закроем
     if (UPS.Mode != data[0]) {
         UPS.Mode = data[0]; 
 #ifdef UPS_MODE_MONITOR
@@ -922,7 +968,7 @@ void ups_mode_response(char *data)
         log_event_data(LOG_UPS_MODE, value);
 #endif
     }
-   
+#endif
 }
 
 #define BIT_OFFSET(c, offset) ((c - 0x30) << offset)

+ 1 - 1
modules/monitor/ups_monitor.c

@@ -1763,7 +1763,7 @@ void UPS_EPOMonitor(void)
 #ifdef OVERTEMPRATURE_MONITOR
 void UPS_OverTempratureMonitor(void)
 {
-    if ((UPS.fault_type == 0x41) && (UPS.Temp < 55) && ((UPS.Status >> 7) & 0x01)) {
+    if (((UPS.fault_type == 0x41) || (UPS.fault_type == 0x13)) && (UPS.Temp < 55) && ((UPS.Status >> 7) & 0x01)) {
         UPScmd(ups_remote_turn_off);
         xTimerStart(UPSRestartTimer, 0);
         UPS.fault_type = 0;

+ 1 - 1
peripheral_modules/src/rtc.c

@@ -580,7 +580,7 @@ void TM_RTC_GetDateTimeFromUnix(TM_RTC_t* data, uint32_t unix) {
 	for (data->month = 0; data->month < 12; data->month++) {
 		if (TM_RTC_LEAP_YEAR(year) && unix >= (uint32_t)TM_RTC_Months[1][data->month]) {
 			unix -= TM_RTC_Months[1][data->month];
-		} else if (unix >= (uint32_t)TM_RTC_Months[0][data->month]) {
+		} else if (!TM_RTC_LEAP_YEAR(year) && unix >= (uint32_t)TM_RTC_Months[0][data->month]) {
 			unix -= TM_RTC_Months[0][data->month];
 		} else {
 			break;