Kaynağa Gözat

2.0.1.0暂时解决重启问题

CHENJIE-PC\QiXiang_CHENJIE 3 yıl önce
ebeveyn
işleme
3369269803
7 değiştirilmiş dosya ile 47 ekleme ve 33 silme
  1. 4 4
      inc/TcpTask.h
  2. 1 1
      inc/app.h
  3. 1 1
      inc/hal_module_adapter.h
  4. 1 1
      src/MainTask.c
  5. 4 3
      src/TcpTask.c
  6. 34 21
      src/UartTask.c
  7. 2 2
      src/bsp_custom.c

+ 4 - 4
inc/TcpTask.h

@@ -21,11 +21,11 @@ extern UINT32 TcpService;
 #define CHRG_END_DELAY    (300)
 #define RUN_END_DELAY    (100)
 
-// #define QX_TCP_IPADRRES				"47.97.127.222"
-// #define QX_TCP_PORT					8712
-/*---------------测试IP地址-----------------------------------*/
-#define QX_TCP_IPADRRES				"39.103.177.126"
+#define QX_TCP_IPADRRES				"47.97.127.222"
 #define QX_TCP_PORT					8712
+/*---------------测试IP地址-----------------------------------*/
+// #define QX_TCP_IPADRRES				"39.103.177.126"
+// #define QX_TCP_PORT					8712
 // #define QX_TCP_IPADRRES				"120.26.68.165"
 // #define QX_TCP_PORT					14319
 /*---------------测试IP地址END-----------------------------------*/

+ 1 - 1
inc/app.h

@@ -16,7 +16,7 @@ extern "C" {
 #define BMS_MANUFACTURE (1) //BMS制造商表示1-超力源,2-美顺
 #define DATA_MODULE_TYPE (1) //1表示NB模块,2表示4G cat1
 #define BMS_INFO  (2)       //1-1表示超力源4830,1-2表示超力源6060,2-1表示美顺6455
-#define EOLSTATE (1) //1标识下线检测跳过,使用默认值
+#define EOLSTATE (0) //1标识下线检测跳过,使用默认值
 
 #if  BMS_MANUFACTURE==1
     #if BMS_INFO==1

+ 1 - 1
inc/hal_module_adapter.h

@@ -8,7 +8,7 @@ extern "C" {
 #include "sensor.h"
 #include "can.h"
 
-//#define USING_PRINTF
+#define USING_PRINTF
 #define DEBUGLOG
 
 #define GPS_DATA_RECV_BUFFER_SIZE     						(1024)

+ 1 - 1
src/MainTask.c

@@ -36,7 +36,7 @@
 extern UINT8 	UDSSwitch;
 extern volatile bool NB_Fota_update_flag;
 extern volatile bool BMS_Fota_update_flag;
-CHAR defaultBattSN[BATT_SN_LEN] = "GYTEST00000000003";//未进行下线检测的默认SN
+CHAR defaultBattSN[BATT_SN_LEN] = "MGYGYN660N214E009";//未进行下线检测的默认SN
 //全局变量
 UINT32 Timer_count;//每100ms加1
 volatile BOOL Sleep_flag = false;//睡眠标志位

+ 4 - 3
src/TcpTask.c

@@ -436,6 +436,9 @@ static void TcpDataInfoAssembleSend()
             }
         }
     }
+    #ifdef USING_PRINTF
+        printf("Version report! send_counter:%d\n",send_counter);
+    #endif
     if(send_counter==1)//版本信息上报
     {
         VersionMsgtoTcpType VerMsgToTcpInfo;
@@ -450,6 +453,7 @@ static void TcpDataInfoAssembleSend()
         hour=(TimeStracture.UTCtimer2&0xff000000)>>24;
         minute=(TimeStracture.UTCtimer2&0xff0000)>>16;
         sec=(TimeStracture.UTCtimer2&0xff00)>>8;
+        UTCToBeijing((UTC8TimeType *)&UTC8TimeTcp,year,month,day,hour,minute,sec);
         DataLen= (UINT16)sizeof(VerMsgToTcpInfo.VerInfo);
         VerMsgToTcpInfo.startSymbol[0] = TCP_START_SYM1;
 	    VerMsgToTcpInfo.startSymbol[1] = TCP_START_SYM2;
@@ -518,9 +522,6 @@ static void TcpDataInfoAssembleSend()
             send_counter = 1;
             return;
         }
-         #ifdef USING_PRINTF
-            printf("Version report! BmsSoftversion:%d.%d\n",bmsSwVersion/10,bmsSwVersion%10);
-        #endif
     }
     if(send_counter==0)//发送本次文件中的调试信息
     {

+ 34 - 21
src/UartTask.c

@@ -61,7 +61,7 @@ static process_Uart             gProcess_Uart_Task = PROCESS_UART_STATE_IDLE;
 
 //函数声明区
 void USART_callback(uint32_t event);
-UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer);
+UINT8 Uart_DataRecv_func(Uart_Read_Msg_Type Uart_Read_Msg_Fun,UINT8* Uart_Recv_Buffer_Fun);
 static BOOL uartBattInfoDecode(UINT8* dataPtr);
 UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData);
 UINT16 crc_chk(UINT8* data, UINT8 length);
@@ -101,7 +101,9 @@ static void UartTask(void* arg)
 	UINT32  currentTimerCount=0;
 	BOOL uartReadSuccessFlag = false;
     Uart_Read_Msg_Type Uart_Read_Msg;
+	memset(&(Uart_Read_Msg),0x00,sizeof(Uart_Read_Msg_Type));
     Uart_Write_Data_Type UartWriteData; //Uart控制命令
+	memset(&(UartWriteData),0x00,sizeof(Uart_Write_Data_Type));
     UartReadMsgType UartReadMsg;
     memset(&(UartReadMsg.UartFlag),0x00,sizeof(UartReadMsgType));
     if(UartWriteCmdHandle == NULL)//Uart控制命令传输指针
@@ -196,7 +198,7 @@ static void UartTask(void* arg)
             }
             case PROCESS_UART_STATE_READ:
             {
-                
+                UINT16 CRC_chk_buffer;
                 Reg_Num = 0x21+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + 2;//按照协议里面的0x21+X+N的结束地址
                 Uart_Read_Msg.Bms_Address = BMS_ADDRESS_CODE;
                 Uart_Read_Msg.Bms_Funcode = UART_READ_CODE;
@@ -206,7 +208,11 @@ static void UartTask(void* arg)
                 Uart_Read_Msg.Reg_Num_L = Reg_Num;
                 Uart_Uds_LEN = Reg_Num*2;
                 memset(UartReadMsg.Header,0x00,Uart_Uds_LEN);
-                Uart_Recv_LEN = Uart_DataRecv_func((UINT8 *)&Uart_Read_Msg,UartReadMsg.Header);
+				CRC_chk_buffer = crc_chk((UINT8 *)&Uart_Read_Msg,6);
+				Uart_Read_Msg.CRC_L = CRC_chk_buffer;
+				Uart_Read_Msg.CRC_H = CRC_chk_buffer>>8;
+                //Uart_Recv_LEN = Uart_DataRecv_func((UINT8 *)&Uart_Read_Msg,(UINT8*)UartReadMsg.Header);
+				Uart_Recv_LEN = Uart_DataRecv_func(Uart_Read_Msg,(UINT8*)(UartReadMsg.Header));
 				if(Uart_Recv_LEN>0)
 				{
 					UartBattInfoRecvFlag =  TRUE;
@@ -497,26 +503,31 @@ UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData)
     }
 }
 //Uart发送接收函数
-UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
+UINT8 Uart_DataRecv_func(Uart_Read_Msg_Type Uart_Read_Msg_Fun,UINT8* Uart_Recv_Buffer_Fun)
 {
     UINT16 CRC_Rece_buffer;
     UINT16 CRC_chk_buffer;
     UINT16 Data_Len ;
     UINT8 timeout = 0x00;
-    Data_Len = (*(Uart_Read_Msg+4)|*(Uart_Read_Msg+5))*2+5;
-    CRC_chk_buffer = crc_chk(Uart_Read_Msg,6);
-    *(Uart_Read_Msg+6) = CRC_chk_buffer;
-    *(Uart_Read_Msg+7)  = CRC_chk_buffer>>8;
-    USARTdrv->Send(Uart_Read_Msg,8);
+	UINT8 pSendCmd[8];
+	memcpy(pSendCmd,(UINT8*)(&Uart_Read_Msg_Fun),8);
+    //Data_Len = (*(Uart_Read_Msg_Fun+4)|*(Uart_Read_Msg_Fun+5))*2+5;
+	Data_Len  = ((Uart_Read_Msg_Fun.Reg_Num_H<<8)|(Uart_Read_Msg_Fun.Reg_Num_L))*2+5;
+
+    //USARTdrv->Send(Uart_Read_Msg_Fun,8);
+	USARTdrv->Send(pSendCmd,8);
     #ifdef USING_PRINTF1
+		
         printf("Uart_Send_buffer:  ");
         for(int i=0;i<8;i++)
-        {
-            printf("%x ",*(Uart_Read_Msg+i));
-        }
-        printf("\n");
+        // {
+             printf("%x ",pSendCmd[i]);
+        // }
+        printf("end\n");
+		//printf("%x ",*(Uart_Read_Msg_Fun));
+	//UINT8 temp = *(Uart_Read_Msg_Fun);
     #endif
-    USARTdrv->Receive(Uart_Recv_Buffer,Data_Len);
+    USARTdrv->Receive(Uart_Recv_Buffer_Fun,Data_Len);
 	while(true)
     {
         timeout++;
@@ -529,6 +540,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
             osDelay(100);
             if (timeout>=10)
             {
+				// Data_Len = 0;
                 timeout =0;
                 isRecvTimeout = true;
             }
@@ -536,21 +548,21 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
     }
      #ifdef USING_PRINTF1
          printf("Uart_Rece_buffer1: ");
-         for(int i=0;i<Data_Len;i++)
+         for(int j=0;j<Data_Len;j++)
          {
-         printf("%x ",*(Uart_Recv_Buffer+i));
+         printf("%x ",*(Uart_Recv_Buffer_Fun+j));
          }
      #endif
     if (isRecvComplete == true)
     {
         isRecvComplete = false;
-        CRC_Rece_buffer =*(Uart_Recv_Buffer+Data_Len-1)<<8|*(Uart_Recv_Buffer+Data_Len-2);
-        CRC_chk_buffer = crc_chk(Uart_Recv_Buffer,Data_Len-2);
+        CRC_Rece_buffer =*(Uart_Recv_Buffer_Fun+Data_Len-1)<<8|*(Uart_Recv_Buffer_Fun+Data_Len-2);
+        CRC_chk_buffer = crc_chk(Uart_Recv_Buffer_Fun,Data_Len-2);
 	    #ifdef USING_PRINTF1
 	         printf("Uart_Rece_buffer after Crc: ");
 	         for(int i=0;i<Data_Len;i++)
 	         {
-	         	printf("%x ",*(Uart_Recv_Buffer+i));
+	         	printf("%x ",*(Uart_Recv_Buffer_Fun+i));
 	   	     }
 	         printf("\tcrcchk:%x,%x\n ",CRC_chk_buffer,CRC_Rece_buffer);
 	    #endif
@@ -569,16 +581,17 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
                       ARM_USART_PARITY_NONE |
                       ARM_USART_STOP_BITS_1 |
                       ARM_USART_FLOW_CONTROL_NONE, 9600);
-            memset(Uart_Recv_Buffer,0xff,Data_Len);
+            memset(Uart_Recv_Buffer_Fun,0xff,Data_Len);
             return 0;
         }
     }
     else
     {
-        memset(Uart_Recv_Buffer,0x00,Data_Len);
+        memset(Uart_Recv_Buffer_Fun,0x00,Data_Len);
         isRecvTimeout = false;
         return 0;
     }
+	return 0;
 }
 
 

+ 2 - 2
src/bsp_custom.c

@@ -126,7 +126,7 @@ static void PMU_WakeupPadInit(void)
 {
     const padWakeupSettings_t cfg =
     {
-        false, true,             // group0 posedge, negedge
+        true, false,             // group0 posedge, negedge
         true, true,             // group1 posedge, negedge
         true, true,             // group2 posedge, negedge
     };
@@ -209,7 +209,7 @@ void Pad0_WakeupIntHandler(void)
 #else	
     ECOMM_TRACE(UNILOG_PLA_APP, pad0_Wk, P_SIG, 0, "PadWakeup0_IRQn");
 #endif
-	//CanTiggerEvt(1);
+	CanTiggerEvt(1);
 }
 
 void Pad1_WakeupIntHandler(void)