Procházet zdrojové kódy

完成软件版本上报,在唤醒时上报

CHENJIE-PC\QiXiang_CHENJIE před 4 roky
rodič
revize
859b22892e
7 změnil soubory, kde provedl 129 přidání a 22 odebrání
  1. 8 0
      inc/Fota.h
  2. 33 5
      inc/TcpTask.h
  3. 9 4
      inc/app.h
  4. 9 0
      src/Fota.c
  5. 3 1
      src/MainTask.c
  6. 62 7
      src/TcpTask.c
  7. 5 5
      src/UDSService.c

+ 8 - 0
inc/Fota.h

@@ -0,0 +1,8 @@
+/****************************************************************************
+ *
+ * Copy right:   Qx.ChenJie
+ * File name:    Fota.h
+ * Description:  Fota函数
+ * History:      2021-03-15
+ * 
+ ****************************************************************************/

+ 33 - 5
inc/TcpTask.h

@@ -16,10 +16,10 @@
 #define QMSG_ID_SOCK_EXIT       	(QMSG_ID_BASE + 6)
 #define APP_EVENT_QUEUE_SIZE    (10)
 
-// #define QX_TCP_IPADRRES				"120.26.68.165"
-// #define QX_TCP_PORT					14319
-#define QX_TCP_IPADRRES				"47.97.127.222"
-#define QX_TCP_PORT					8712
+#define QX_TCP_IPADRRES				"120.26.68.165"
+#define QX_TCP_PORT					14319
+// #define QX_TCP_IPADRRES				"47.97.127.222"
+// #define QX_TCP_PORT					8712
 
 #define BATT_SN_LEN             17
 #define TCP_START_SYM1			0x23
@@ -35,6 +35,7 @@
 //message type mark
 #define BATTMSG				0x80
 #define GPSMSG				0x82
+#define VERSIONMSG			0x86
 
 typedef struct BattInfoType
 {	
@@ -71,6 +72,7 @@ typedef struct BattMsgtoTcpType
 	BattInfoType battInfo;	
 	UINT8	CRC;
 }BattMsgtoTcpType;
+/*---------------------------------------------------------------------------*/
 typedef struct _GPSInfoType
 {
 	UINT8	sendTimeUTC[6];
@@ -85,7 +87,6 @@ typedef struct _GPSInfoType
 	UINT8	longitude[4];
 	
 }GPSInfoType;
-
 typedef struct GPSMsgtoTcpType
 {
 	UINT8 	startSymbol[2];
@@ -97,6 +98,33 @@ typedef struct GPSMsgtoTcpType
 	GPSInfoType gpsInfo;	
 	UINT8	CRC;
 }GPSMsgtoTcpType;
+/*---------------------------------------------------------------------------*/
+typedef struct _VerInfoType
+{
+	UINT8	sendTimeUTC[6];
+	UINT8	msgMark;
+	UINT8	msgCollectionTimeUTC[6];
+	UINT8	ICCID[20];
+	UINT8	IMEI[15];
+	UINT8	BMSHwVersion;
+	UINT8	BMSSwVersion;
+	UINT8	NBHwVersion[2];
+	UINT8	BLVersion[4];
+	UINT8	DRVVersion[4];
+	UINT8	APPVersion[4];
+}VerInfoType;
+typedef struct VersionMsgtoTcpType
+{
+	UINT8 	startSymbol[2];
+	UINT8	cmdSymbol;
+	UINT8	ansSymbol;
+	UINT8	SN[BATT_SN_LEN];
+	UINT8	encryptMethod;
+	UINT8	dataLength[2];	
+	VerInfoType VerInfo;	
+	UINT8	CRC;
+}VersionMsgtoTcpType;
+/*---------------------------------------------------------------------------*/
 typedef enum
 {
     APP_SOCKET_CONNECTION_CLOSED,

+ 9 - 4
inc/app.h

@@ -23,9 +23,12 @@ extern "C" {
 #endif
 #define BATT_CELL_VOL_NUM_2 (BATT_CELL_VOL_NUM*2)
 #define BATT_SN_LEN           17
-#define	SWVERSION		0xA21
-#define HWVERSION		0xB22
-#define APP_CONFIG_FILE_LATEST_VERSION 1
+ 
+#define HWVERSION		    0x0102    //NB硬件主版本,现为V1.2板
+#define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
+#define	DRVSWVERSION		0x01030000     //驱动层版本号V1.3.0.0
+#define	APPSWVERSION		0x01020100    //应用层版本号V1.2.1.0
+#define APP_CONFIG_FILE_LATEST_VERSION 2
 #define APP_CONFIG_FILE_NAME  "qxappconfig.nvm"
 //--------------------------------------------------------------------------------
 typedef struct AppNVMDataType
@@ -37,7 +40,9 @@ typedef struct AppNVMDataType
     UINT8  wakeupWorkTime;     //the unit is min
     UINT8  sleepTime;
     UINT16 HwVersion;
-    UINT16 SwVersion;
+    UINT32 BLSwVersion;
+    UINT32 DrvSwVersion;
+    UINT32 AppSwVersion;
 }AppNVMDataType;
 
 typedef struct AppConfigHeader

+ 9 - 0
src/Fota.c

@@ -0,0 +1,9 @@
+/****************************************************************************
+ *
+ * Copy right:   Qx.
+ * File name:    Fota.c
+ * Description:  Fota升级函数
+ * History:      2021-03-15
+ *
+ ****************************************************************************/
+#include "Fota.h"

+ 3 - 1
src/MainTask.c

@@ -540,7 +540,9 @@ static void setDefaultAppDataValue(void)
 	AppNVMData.wakeupWorkTime = 2;	//2min
 	AppNVMData.sleepTime = 5;			//5min
     AppNVMData.HwVersion = HWVERSION;
-    AppNVMData.SwVersion = SWVERSION;
+    AppNVMData.BLSwVersion = BLSWVERSION;
+    AppNVMData.DrvSwVersion = DRVSWVERSION;
+    AppNVMData.AppSwVersion = APPSWVERSION;
     return;
 }
 

+ 62 - 7
src/TcpTask.c

@@ -198,9 +198,10 @@ void TcpTaskDeInit(void *arg)
 
 /*------------------------------函数区域-----------------------*/
 static void TcpDataInfoAssembleSend()
-{   static UINT8 send_counter = 0;
+{   static UINT32 send_counter = 0;
     BattMsgtoTcpType BattToTcpInfo;
     GPSMsgtoTcpType GpsToTcpInfo;
+    VersionMsgtoTcpType VerMsgToTcpInfo;
     OsaUtcTimeTValue TimeStracture;
     UINT8 csq=0;
     INT8 snr=0;
@@ -209,8 +210,10 @@ static void TcpDataInfoAssembleSend()
     UINT16 BattU;
     UINT8 temp=0;
     UINT8 TEMP_NUM=0;
+    TEMP_NUM = BATT_TEMP_NUM+2;//TEMP_NUM为温度总检测数量
     UINT16 DataLen;
-    if(send_counter%1==0)
+    //if(send_counter%1==0)
+    if(0)
     {
         osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
         appGetSystemTimeUtcSync(&TimeStracture);
@@ -239,7 +242,6 @@ static void TcpDataInfoAssembleSend()
         BattToTcpInfo.battInfo.msgCollectionTimeUTC[5] = ((TimeStracture.UTCtimer2) >> 8 ) & 0xFF;							//sec
         BattToTcpInfo.battInfo.signalStrength = csq ;
         //故障等级故障代码未定义
-        TEMP_NUM = UartReadMsg.data[3];//TEMP_NUM为温度总检测数量
         BattToTcpInfo.battInfo.errClass = 0x00;
         BattToTcpInfo.battInfo.errCode[0] = 0x00;
 	    BattToTcpInfo.battInfo.errCode[1] = 0x00;
@@ -286,7 +288,8 @@ static void TcpDataInfoAssembleSend()
         tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
 
     }
-    if(send_counter%6==0)
+    //if(send_counter%6==0)
+    if(0)
     {
         osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);
         appGetSystemTimeUtcSync(&TimeStracture);
@@ -319,11 +322,63 @@ static void TcpDataInfoAssembleSend()
         {
             tcpipConnectionSend(socContext.id, (UINT8 *)&GpsToTcpInfo, sizeof(GpsToTcpInfo), 0, 0, 0);
         }
-    }   
-    if(send_counter>=6*10+1)
+    }
+    if(send_counter==0)
     {
-        send_counter=1;
+        CHAR iccid[20];
+        CHAR imei[15];
+        appGetIccidNumSync(iccid);
+        appGetImeiNumSync(imei);
+        appGetSystemTimeUtcSync(&TimeStracture);
+        DataLen= (UINT16)sizeof(VerMsgToTcpInfo.VerInfo);
+        VerMsgToTcpInfo.startSymbol[0] = TCP_START_SYM1;
+	    VerMsgToTcpInfo.startSymbol[1] = TCP_START_SYM2;
+	    VerMsgToTcpInfo.cmdSymbol = TCP_CMD_SYM;
+	    VerMsgToTcpInfo.ansSymbol = TCP_ANS_SYM;
+        memcpy(VerMsgToTcpInfo.SN, BattSN,BATT_SN_LEN);
+        VerMsgToTcpInfo.encryptMethod = TCP_ENCPT_DISABLE; //not encrypt
+	    VerMsgToTcpInfo.dataLength[0] = (DataLen>>8) & 0xFF;
+	    VerMsgToTcpInfo.dataLength[1] = DataLen & 0xFF;
+        VerMsgToTcpInfo.VerInfo.sendTimeUTC[0] = ((((TimeStracture.UTCtimer1) >> 16) & 0xFFFF) - 0x07D0) & 0xFF; 	//year
+        VerMsgToTcpInfo.VerInfo.sendTimeUTC[1] = ((TimeStracture.UTCtimer1) >> 8 ) & 0xFF;							//month
+        VerMsgToTcpInfo.VerInfo.sendTimeUTC[2] = (TimeStracture.UTCtimer1) & 0xFF;									//day
+        VerMsgToTcpInfo.VerInfo.sendTimeUTC[3] = ((TimeStracture.UTCtimer2) >> 24 ) & 0xFF; 						    //hour
+        VerMsgToTcpInfo.VerInfo.sendTimeUTC[4] = ((TimeStracture.UTCtimer2) >> 16 ) & 0xFF;						    //mins
+        VerMsgToTcpInfo.VerInfo.sendTimeUTC[5] = ((TimeStracture.UTCtimer2) >> 8 ) & 0xFF;							//sec
+        VerMsgToTcpInfo.VerInfo.msgMark = VERSIONMSG;
+        VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[0] = ((((TimeStracture.UTCtimer1) >> 16) & 0xFFFF) - 0x07D0) & 0xFF; 	//year
+        VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[1] = ((TimeStracture.UTCtimer1) >> 8 ) & 0xFF;							//month
+        VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[2] = (TimeStracture.UTCtimer1) & 0xFF;									//day
+        VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[3] = ((TimeStracture.UTCtimer2) >> 24 ) & 0xFF; 						    //hour
+        VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[4] = ((TimeStracture.UTCtimer2) >> 16 ) & 0xFF;						    //mins
+        VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[5] = ((TimeStracture.UTCtimer2) >> 8 ) & 0xFF;
+        memcpy(VerMsgToTcpInfo.VerInfo.ICCID,iccid,20);
+        memcpy(VerMsgToTcpInfo.VerInfo.IMEI,imei,15);
+        osMutexAcquire(UartMutex, osWaitForever);
+        VerMsgToTcpInfo.VerInfo.BMSHwVersion = UartReadMsg.data[(0x08+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
+        VerMsgToTcpInfo.VerInfo.BMSSwVersion = UartReadMsg.data[(0x08+BATT_CELL_VOL_NUM+TEMP_NUM)*2];
+        osMutexRelease(UartMutex);
+        VerMsgToTcpInfo.VerInfo.NBHwVersion[0] = (HWVERSION>>8)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.NBHwVersion[1] = (HWVERSION)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.BLVersion[0] = (BLSWVERSION>>24)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.BLVersion[1] = (BLSWVERSION>>16)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.BLVersion[2] = (BLSWVERSION>>8)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.BLVersion[3] = (BLSWVERSION)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.DRVVersion[0] = (DRVSWVERSION>>24)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.DRVVersion[1] = (DRVSWVERSION>>16)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.DRVVersion[2] = (DRVSWVERSION>>8)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.DRVVersion[3] = (DRVSWVERSION)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.APPVersion[0] = (APPSWVERSION>>24)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.APPVersion[1] = (APPSWVERSION>>16)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.APPVersion[2] = (APPSWVERSION>>8)& 0xFF;
+        VerMsgToTcpInfo.VerInfo.APPVersion[3] = (APPSWVERSION)& 0xFF;
+        VerMsgToTcpInfo.CRC = bcc_chk((UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo)-1 );
+        tcpipConnectionSend(socContext.id, (UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo), 0, 0, 0);
     }
+    if(send_counter>0xffff)
+    {
+        send_counter = 0;
+    }    
     else
     {
         send_counter++;

+ 5 - 5
src/UDSService.c

@@ -224,14 +224,14 @@ void UDS_Service()
 									{
 										UDSAnswer.Id = 0x7A8;
 										UDSAnswer.DLC = 8;
-										UDSAnswer.Data[0] = 0x06;
+										UDSAnswer.Data[0] = 0x08;
 										UDSAnswer.Data[1] = 0x78;
 										UDSAnswer.Data[2] = UDSService[i];
 										UDSAnswer.Data[3] = UDSSubService[i];
-										UDSAnswer.Data[4] = SWVERSION>>8;
-										UDSAnswer.Data[5] = SWVERSION;
-										UDSAnswer.Data[6] = 0x00;
-										UDSAnswer.Data[7] = 0x00;
+										UDSAnswer.Data[4] = APPSWVERSION>>24;
+										UDSAnswer.Data[5] = APPSWVERSION>>16;
+										UDSAnswer.Data[6] = APPSWVERSION>>8;
+										UDSAnswer.Data[7] = APPSWVERSION;
 										ret = HAL_Can_Transmit(UDSAnswer);
 									}
 									else if(UDSSubService[i] == 0x02)  //check the hw of NB