Sfoglia il codice sorgente

服务器Fota更新测试软件

CHENJIE-PC\QiXiang_CHENJIE 4 anni fa
parent
commit
7bdb64e481
4 ha cambiato i file con 40 aggiunte e 19 eliminazioni
  1. 11 6
      inc/TcpTask.h
  2. 5 4
      inc/app.h
  3. 9 1
      src/MainTask.c
  4. 15 8
      src/TcpTask.c

+ 11 - 6
inc/TcpTask.h

@@ -19,11 +19,15 @@ extern UINT32 TcpService;
 #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
-
+/*---------------测试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-----------------------------------*/
 #define BATT_SN_LEN             17
 #define TCP_START_SYM1			0x23
 #define TCP_START_SYM2			0x23
@@ -56,7 +60,7 @@ typedef struct BattInfoType
 	UINT8	battI[2];
 	UINT8	battLinkVol[2];
 	UINT8	battPackVol[2];
-	UINT8   chrgState;
+	UINT8   mosState;
 	UINT8	battSOC;
 	UINT8	battSOH;
 	UINT8	batCellBalenceState[4];	//uint32 should change to uint8[]: each bit stand for 1 cell, up to 1024
@@ -120,8 +124,9 @@ typedef struct _VerInfoType
 	UINT8	BLVersion[4];
 	UINT8	DRVVersion[4];
 	UINT8	APPVersion[4];
-	CHAR	BmsType;
-	CHAR	BmsInfo;
+	UINT8	BmsType;
+	UINT8	BmsInfo;
+	UINT8   DataModuleType;
 }VerInfoType;
 typedef struct VersionMsgtoTcpType
 {

+ 5 - 4
inc/app.h

@@ -14,17 +14,18 @@ extern "C" {
 #endif
 //全局定义声明区
 #define BMS_MANUFACTURE (1) //BMS制造商表示1-超力源,2-美顺
+#define DATA_MODULE_TYPE (1) //1表示NB模块,2表示4G cat1
 #define BAT4830
 //#define BAT6060
 #ifdef  BAT4830
     #define BATT_CELL_VOL_NUM  (14)
     #define BATT_TEMP_NUM  (3)
-    #define BMS_INFO  (1)
+    #define BMS_INFO  (1)      //1BMS信息表示4830
     #define BATT_OTHER_TEMP_NUM  (2)
 #elif defined BAT6060
     #define BATT_CELL_VOL_NUM  (17)
     #define BATT_TEMP_NUM  (5)
-    #define BMS_INFO  (2)
+    #define BMS_INFO  (2)       //2-BMS信息表示6060
     #define BATT_OTHER_TEMP_NUM  (2)
 #endif
 #define BATT_CELL_VOL_NUM_2 (BATT_CELL_VOL_NUM*2)
@@ -33,8 +34,8 @@ extern "C" {
 #define HWVERSION		    0x0102    //硬件主版本,现为V1.2板
 #define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
 #define	DRVSWVERSION		0x01030000     //驱动层版本号V1.3.0.0
-#define	APPSWVERSION		0x01020104       
-#define APP_CONFIG_FILE_LATEST_VERSION 4
+#define	APPSWVERSION		0x01020101       
+#define APP_CONFIG_FILE_LATEST_VERSION 0
 #define APP_CONFIG_FILE_NAME  "qxappconfig.nvm"
 //--------------------------------------------------------------------------------
 typedef struct AppNVMDataType

+ 9 - 1
src/MainTask.c

@@ -31,7 +31,7 @@
 #include "TcpTask.h"
 #include "Fota.h"
 extern volatile bool Fota_update_flag;
-CHAR BattSN[BATT_SN_LEN] = "GY606000000000001";//SN仍在测试
+CHAR BattSN[BATT_SN_LEN] = "GYTEST00000000003";//SN仍在测试
 //全局变量
 UINT32 Timer_count;//每100ms加1
 volatile bool Sleep_flag = false;//睡眠标志位
@@ -104,6 +104,14 @@ static void MainTask(void* arg)
         printf("%d ",*(pReadAppConfig+i));
     printf("\n");
     #endif
+    if(AppNVMData.AppSwVersion!=APPSWVERSION)
+    {
+        AppNVMData.HwVersion = HWVERSION;
+        AppNVMData.BLSwVersion = BLSWVERSION;
+        AppNVMData.DrvSwVersion = DRVSWVERSION;
+        AppNVMData.AppSwVersion = APPSWVERSION;
+        AppNVMData.appDataModify=TRUE;
+    }
 
 
 	

+ 15 - 8
src/TcpTask.c

@@ -92,6 +92,10 @@ static void TcpTask(void* arg)
         {
             sendQueueMsg(QMSG_ID_SOCK_SENDPKG, 0);
         }
+        else if(Timer_count%100==0)
+        {
+            TcpService = 0x00;
+        }
         if (xQueueReceive(psEventQueueHandle, &queueItem, 0))
         {
             switch(queueItem->messageId)
@@ -138,7 +142,6 @@ static void TcpTask(void* arg)
                 case QMSG_ID_SOCK_RECVPKG:
                     TcpDataInfoRecvHandle();
                     osDelay(100);
-                    TcpService=0x00;
                     break;
                 case QMSG_ID_NW_IP_SUSPEND:
                     if (socContext.id >= 0 && socContext.status != APP_SOCKET_CONNECTION_CLOSED)
@@ -221,8 +224,8 @@ static void TcpDataInfoAssembleSend()
     UINT8 TEMP_NUM=0;
     TEMP_NUM = BATT_TEMP_NUM+2;//TEMP_NUM为BMS温度总检测数量
     UINT16 DataLen;
-    //if(send_counter%1==0)
-    if(0)
+    if(send_counter%1==0)
+    //if(0)
     {
         osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
         appGetSystemTimeUtcSync(&TimeStracture);
@@ -277,7 +280,7 @@ static void TcpDataInfoAssembleSend()
 	    BattToTcpInfo.battInfo.battPackVol[0] = BattU >> 8;
 	    BattToTcpInfo.battInfo.battPackVol[1] = BattU & 0xFF;
         temp = ((UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1])>>1)&0x03;
-        BattToTcpInfo.battInfo.chrgState = ((temp&0x01)<<01)|(temp>>0x01);
+        BattToTcpInfo.battInfo.mosState = ((temp&0x01)<<01)|(temp>>0x01);
         BattToTcpInfo.battInfo.battSOC = UartReadMsg.data[(0x0B+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
         BattToTcpInfo.battInfo.battSOH = UartReadMsg.data[(0x0C+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
         memcpy(BattToTcpInfo.battInfo.batCellBalenceState,&UartReadMsg.data[(0x06+BATT_CELL_VOL_NUM+TEMP_NUM)*2],4);
@@ -298,8 +301,8 @@ static void TcpDataInfoAssembleSend()
         tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
 
     }
-    //if(send_counter%6==0)
-    if(0)
+    if(send_counter%6==0)
+    //if(0)
     {
         osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);
         appGetSystemTimeUtcSync(&TimeStracture);
@@ -389,6 +392,7 @@ static void TcpDataInfoAssembleSend()
         VerMsgToTcpInfo.VerInfo.APPVersion[3] = (APPSWVERSION)& 0xFF;
         VerMsgToTcpInfo.VerInfo.BmsType = BMS_MANUFACTURE;
         VerMsgToTcpInfo.VerInfo.BmsInfo = BMS_INFO;
+        VerMsgToTcpInfo.VerInfo.DataModuleType = DATA_MODULE_TYPE;
         VerMsgToTcpInfo.CRC = bcc_chk((UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo)-1 );
         tcpipConnectionSend(socContext.id, (UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo), 0, 0, 0);
     }
@@ -407,7 +411,6 @@ static void TcpDataInfoAssembleSend()
 static void TcpDataInfoRecvHandle()
 {
     TcpipConnectionRecvDataInd *TcpRecvData;
-    TcpService = 0x01;//应答标志
     osMessageQueueGet(TcpRecvHandle,&TcpRecvData,0,0);
     osDelay(100);
     UINT8 Tcp_Cmd;
@@ -419,6 +422,10 @@ static void TcpDataInfoRecvHandle()
         if((*(Ptr+0)==TCP_START_SYM1)&&(*(Ptr+1)==TCP_START_SYM2))//服务器起始信息
         {
             Tcp_Cmd = *(Ptr+2);//命令标志
+            if(*(Ptr+3)==0xFE)
+            {
+                TcpService=0x01;
+            }
             switch (Tcp_Cmd)
             {
             case TCP_QUERY_SYM:
@@ -595,7 +602,7 @@ static void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEve
                 memcpy(rcvbuffer,rcvInd,sizeof(TcpipConnectionRecvDataInd));
                 osMessageQueuePut(TcpRecvHandle,&rcvbuffer,0,1000);
                 sendQueueMsg(QMSG_ID_SOCK_RECVPKG, 0);
-                #ifdef USING_PRINTF1
+                #ifdef USING_PRINTF
                     uint8_t* Ptr;
                     Ptr=rcvInd->data;
                     printf("socketAppConnectionCallBack socket connection %u receive length %u data:", rcvInd->connectionId, rcvInd->length);