V5.2 修改故障码上报格式
authorkyz <kongyuzhong@google.com>
Tue, 25 Feb 2025 08:13:18 +0000 (16:13 +0800)
committerkyz <kongyuzhong@google.com>
Tue, 25 Feb 2025 08:15:04 +0000 (16:15 +0800)
user/user.h
user/user_report.c

index d968845efe1b36f6dd06112f63393a139651cd92..cd853d688955bae5ba743835fde24154d1b269dd 100644 (file)
@@ -27,7 +27,7 @@
 //#include "fmc.h"
 //--------------------
 #define APP_VER_MAJOR 5
-#define APP_VER_MINOR 1
+#define APP_VER_MINOR 2
 
 #define HW_V2  2
 #define HW_V3  3
index c75246b124f34eba10180425b7cd98711ff09fd0..c522b8641680de89f7f2adaac40611168b920c43 100644 (file)
@@ -52,7 +52,7 @@ static const char *fmt = "{\n\
 \"syncFrequency\":%d,\n\
 \"gasType\":%d,\n\
 \"totalTime\":%d,\n\
-\"alarmType\":%d,\n\
+\"alarmType\":%s,\n\
 \"onTime\":%d\n\
 }";
 
@@ -135,7 +135,16 @@ int32_t get_new_rpt_info( rpt_info_t *rpt )
        }
        
        rpt->weld_time = g_dev.welding_time_total/1000;
-
+#if 1
+/*
+E1 :电流传感器故障
+E2:流量计故障
+E3:压力计故障
+E9:漏气故障
+E10:流量故障
+*/
+       rpt->alarm = g_dev.state;
+#else
        if(g_dev.alarm.leakage == 1)
        {
                rpt->alarm = 2;
@@ -148,7 +157,7 @@ int32_t get_new_rpt_info( rpt_info_t *rpt )
        {
                rpt->alarm = 0;
        }
-       
+#endif
        rpt->on_time = 0;
        
 
@@ -194,6 +203,31 @@ static void mac_str_init( void )
 static const char * weld_method_str[3] = {"TIG", "MIG", "MAG" };
 
 
+char *rpt_fault_code( uint32_t alarm )
+{
+       static char falt_code[128];
+       char buf[16];
+       int nr;
+
+       if( alarm == 0 ){
+               strcpy( falt_code, "[ 0 ]" );
+       }else{
+               sprintf( falt_code, "[ " );
+               nr = 0;
+               for( int i=0; i<32; i++ ){
+                       if( alarm& (1<<i)){
+                               if( nr )
+                                       sprintf( buf, ", %d", i+1 );
+                               else
+                                       sprintf( buf, "%d", i+1 );
+                               nr++;
+                               strcat( falt_code, buf );
+                       }
+               }
+               strcat( falt_code, " ]" );
+       }
+       return falt_code;
+}
 
 char * devinfo_report_str( void )
 {
@@ -238,7 +272,7 @@ char * devinfo_report_str( void )
                          g_rpt_sent.freq,
                          g_rpt_sent.gas,
                          g_rpt_sent.weld_time,
-                         g_rpt_sent.alarm,
+                         rpt_fault_code(g_rpt_sent.alarm),
                          g_rpt_sent.on_time
                                );
        last_rpt_tick = now;