Просмотр исходного кода

正式版本发布测试1.2.1.5

CHENJIE-PC\QiXiang_CHENJIE 4 лет назад
Родитель
Сommit
fa0f5cc601
6 измененных файлов с 67 добавлено и 46 удалено
  1. 4 4
      inc/TcpTask.h
  2. 1 1
      inc/app.h
  3. 44 37
      src/MainTask.c
  4. 16 3
      src/TcpTask.c
  5. 1 0
      src/UDSService.c
  6. 1 1
      src/UartTask.c

+ 4 - 4
inc/TcpTask.h

@@ -19,11 +19,11 @@ extern UINT32 TcpService;
 #define APP_EVENT_QUEUE_SIZE    (10)
 
 
-// #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

@@ -34,7 +34,7 @@ extern "C" {
 #define HWVERSION		    0x0102    //硬件主版本,现为V1.2板
 #define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
 #define	DRVSWVERSION		0x01030000     //驱动层版本号V1.3.0.0
-#define	APPSWVERSION		0x01020105      
+#define	APPSWVERSION		0x01020106      
 
 //--------------------------------------------------------------------------------
 

+ 44 - 37
src/MainTask.c

@@ -414,7 +414,6 @@ void appLoadConfig(void)
     UINT32  readCount = 0;
     //AppConfigHeader    AppConfigHr;   //4 bytes
     UINT8   crcCheck = 0;
-    BOOL    needAdjust = FALSE;
     void    *pReadAppConfig = (void *)&AppNVMData;
     /*
      * open the NVM file
@@ -434,23 +433,25 @@ void appLoadConfig(void)
      * read the file header
     */
     readCount = OsaFread(&AppConfigHr, sizeof(AppConfigHeader), 1, fp);
-    
-    if (readCount != 1)
+    UINT8 readtimes=0;
+    while (readCount != 1 && readtimes<=5 )
     {
         //ECOMM_TRACE(UNILOG_PLA_MIDWARE, AppLoadNvmConfig_header_e_1, P_ERROR, 1,
         //            "NVM: 'qxappconfig.nvm', can't read header, return: %d, use the defult value", readCount);
-
-	#ifdef USING_PRINTF
-				printf("NVM: 'qxappconfig.nvm', can't read header, return: %d, use the defult value \n");
-	#endif
-
+        #ifdef USING_PRINTF
+                    printf("NVM: 'qxappconfig.nvm', can't read header, return: %d, use the defult value \n");
+        #endif
+        readtimes++;
+        readCount = OsaFread(&AppConfigHr, sizeof(AppConfigHeader), 1, fp);
+        osDelay(10);
+    }
+    if(readtimes>5)
+    {
         OsaFclose(fp);
         setDefaultAppDataValue();
         appSaveConfig();
-
         return;
     }
-
     if (AppConfigHr.version != APP_CONFIG_FILE_LATEST_VERSION)
     {
         //ECOMM_TRACE(UNILOG_PLA_MIDWARE, AppLoadNvmConfig_ver_w_1, P_ERROR, 2,
@@ -473,7 +474,6 @@ void appLoadConfig(void)
             OsaFclose(fp);
             setDefaultAppDataValue();
             appSaveConfig();
-
             return;
         }
 
@@ -497,7 +497,7 @@ void appLoadConfig(void)
 
             return;
         }		
-        needAdjust = TRUE;
+        //needAdjust = TRUE;
     }
     else if (AppConfigHr.fileBodySize != sizeof(AppNVMData))  //file version is the same, but NVM file size not right
     {
@@ -522,10 +522,16 @@ void appLoadConfig(void)
     */
     
     readCount = OsaFread(pReadAppConfig, AppConfigHr.fileBodySize, 1, fp);
-    crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, AppConfigHr.fileBodySize);
-	
-    if (readCount != 1 ||
-        crcCheck != AppConfigHr.checkSum)
+    crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+	readtimes = 0;
+    //while (readtimes<=5 && crcCheck != AppConfigHr.checkSum)
+    while (readtimes<=5 && crcCheck != AppConfigHr.checkSum)
+    {
+        readtimes++;
+        readCount = OsaFread(pReadAppConfig, AppConfigHr.fileBodySize, 1, fp);
+        crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+    }
+    if (readtimes>5)
     {
         //ECOMM_TRACE(UNILOG_PLA_MIDWARE, AppLoadNvmConfig_3, P_ERROR, 2,
         //            "NVM: 'qxappconfig.nvm', can't read body, or body not right, (%u/%u), use the defult value",
@@ -537,35 +543,36 @@ void appLoadConfig(void)
         OsaFclose(fp);
         setDefaultAppDataValue();
         appSaveConfig();
-
+        /*
         if (needAdjust)
         {
             OsaFreeMemory(&pReadAppConfig);
         }
+        */
         return;
     }
 
-#if 1
-    if (needAdjust)
-    {
-        OsaFclose(fp);
-        setDefaultAppDataValue();
-        appSaveConfig();
-
-        /* free memory */
-        OsaFreeMemory(&pReadAppConfig);
-    }
-#endif
-
-#if 0 
-	int i=0;
+    #if 0
+        if (needAdjust)
+        {
+            OsaFclose(fp);
+            setDefaultAppDataValue();
+            appSaveConfig();
 
-	printf("AppConfigHeader:\n");
-	printf("%d,%d,%d\n",AppConfigHr.fileBodySize,AppConfigHr.version,AppConfigHr.checkSum);
-	printf("AppConfigFileBody:\n");
-	printf("%d,%d,%d\n",AppNVMData.chargEndWorkTime,AppNVMData.wakeupWorkTime,AppNVMData.sleepTime);
-	printf("\n");
-#endif
+            /* free memory */
+            OsaFreeMemory(&pReadAppConfig);
+        }
+    #endif
+    #if 0 
+        int i=0;
+
+        printf("AppConfigHeader:\n");
+        printf("%d,%d,%d\n",AppConfigHr.fileBodySize,AppConfigHr.version,AppConfigHr.checkSum);
+        printf("AppConfigFileBody:\n");
+        printf("%d,%d,%d\n",AppNVMData.chargEndWorkTime,AppNVMData.wakeupWorkTime,AppNVMData.sleepTime);
+        printf("\n");
+    #endif
+    OsaFclose(fp);
     return;
 }
 

+ 16 - 3
src/TcpTask.c

@@ -54,6 +54,7 @@ static   eventCallbackMessage_t *queueItem = NULL;
 static UINT8                    gImsi[16] = {0};
 static UINT32                   gCellID = 0;
 static QueueHandle_t TcpRecvHandle = NULL;
+static UINT8                   TcpRecvEnd = 0;
 //Tcp线程堆栈申请区
 
 //函数声明区
@@ -92,9 +93,14 @@ static void TcpTask(void* arg)
         {
             sendQueueMsg(QMSG_ID_SOCK_SENDPKG, 0);
         }
-        else if(Timer_count%100==0)
+        else if(Timer_count%10==0)
+        {
+            TcpRecvEnd++;
+        }
+        if(TcpRecvEnd>=20)
         {
             TcpService = 0x00;
+            TcpRecvEnd=0;
         }
         if (xQueueReceive(psEventQueueHandle, &queueItem, 0))
         {
@@ -142,6 +148,7 @@ static void TcpTask(void* arg)
                 case QMSG_ID_SOCK_RECVPKG:
                     TcpDataInfoRecvHandle();
                     osDelay(100);
+                    TcpRecvEnd = 0;
                     break;
                 case QMSG_ID_NW_IP_SUSPEND:
                     if (socContext.id >= 0 && socContext.status != APP_SOCKET_CONNECTION_CLOSED)
@@ -305,8 +312,14 @@ static void TcpDataInfoAssembleSend()
         BattToTcpInfo.battInfo.battotherTemp[1] = UartReadMsg.data[(0x06+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+1)*2+1];
         BattToTcpInfo.CRC = bcc_chk((UINT8 *)&BattToTcpInfo, sizeof(BattMsgtoTcpType)-1 );
         osMutexRelease(UartMutex);
-        tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
-
+        UINT8 len;
+        len = tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
+        #ifdef USING_PRINTF1
+            printf("Len = %d\n",len);
+            for(int i=0;i<sizeof(BattToTcpInfo);i++)
+                printf("%x  ",*((UINT8 *)&BattToTcpInfo+i));
+            printf("end V4! \n",len);
+        #endif
     }
     if(send_counter%6==0)
     //if(0)

+ 1 - 0
src/UDSService.c

@@ -283,6 +283,7 @@ void UDS_Service()
 											UDSPositiveAnswer(0x04,i,00);
 											MEMCPY(AppNVMData.battSN, UDSBattSN, BATT_SN_LEN);
 											AppNVMData.EOLState = 1; //SN号写入完成,表明已经进行过下线配置
+											appSaveNVMData();
 										}
 										else
 										{

+ 1 - 1
src/UartTask.c

@@ -116,7 +116,7 @@ static void UartTask(void* arg)
                 }
                 else if(Timer_count%10==0)
                 {
-                    #ifdef USING_PRINTF
+                    #ifdef USING_PRINTF1
                         printf("[%d]Uart Timer 5s:%d\n",__LINE__,Timer_count);
                     #endif
                     if(osMessageQueueGet(UartWriteCmdHandle,&UartWriteData,0,0)==osOK)