Browse Source

租期锁完成功能测试,但存在异常重启问题,还需排查

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
fc429b704d
4 changed files with 64 additions and 41 deletions
  1. 1 1
      inc/app.h
  2. 50 28
      src/MainTask.c
  3. 9 8
      src/TcpTask.c
  4. 4 4
      src/bsp_custom.c

+ 1 - 1
inc/app.h

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

+ 50 - 28
src/MainTask.c

@@ -98,7 +98,7 @@ static void MainTask(void* arg)
     int32_t inParam = 0xAABBCCDD;
     UINT32  param;
     UINT32 adcValue;
-    UINT8 i=0;
+    UINT8  Adcindex=0;
     slpManSetPmuSleepMode(true,SLP_HIB_STATE,false);
     slpManApplyPlatVoteHandle("MainSlp",&MainSlpHandler);
     slpManPlatVoteDisableSleep(MainSlpHandler, SLP_SLP1_STATE);
@@ -227,6 +227,16 @@ static void MainTask(void* arg)
                         }
                         osMutexRelease(Error_Mutex);
                     }
+                    if(Timer_count%(10*60)==0)
+                    {
+                        #ifdef USING_PRINTF
+                            printf("[%d]\n",__LINE__);
+                        #endif
+                        BattLockFunc();
+                        #ifdef USING_PRINTF
+                            printf("[%d]\n",__LINE__);
+                        #endif
+                    }
                 }
                 if(Work_timer_end)
                 {
@@ -236,7 +246,7 @@ static void MainTask(void* arg)
                 }
                 else
                 {   
-                    switch (i)
+                    switch (Adcindex)
                     {
                         case FAST_CHARGE_TEMP:
                          NB_ADC_Get(&adcValue,FAST_CHARGE_TEMP);
@@ -256,13 +266,13 @@ static void MainTask(void* arg)
                         break;
                         case  VBAT:
                             NB_ADC_Get(&adcValue,VBAT);                        
-                            i = 0;
+                            Adcindex = 0;
                         break;
                         default:
-                            i=0;
+                            Adcindex=0;
                             break;
                     }
-                    i++;   
+                    Adcindex++;   
                 }
                 #ifdef USING_PRINTF1
                     printf("TcpService:%d,UDSSwitch:%d,BMS_Fota_update_flag:%d,battWorkState:%d,Can_Msg_Enble:%d\r\n",TcpService,UDSSwitch,BMS_Fota_update_flag,battWorkState,Can_Msg_Enble);
@@ -867,7 +877,7 @@ void BattWorkStateDelayFunc(UINT8 battWorkCurrentState)
 			BattWorkStateDelay = battWorkCurrentState;
 		}
 	}
-	else if(battWorkCurrentState==BATT_CHARGE_SYM)//从 放电或者静置 转充电 1min延时
+	else if(battWorkCurrentState==BATT_CHARGE_SYM)//从 放电或者静置 转充电30s延时
 	{
 		workDelayCounter++;
 		if(workDelayCounter>=30)
@@ -888,32 +898,34 @@ INT8 rentalEndDetectFunc(void)
 	UTC8TimeType UTC8Time,ExpiryTime;
 	UINT16 year;
     UINT8 month,day,hour,minute,sec;
-	INT8 readRet;
-	readRet = appGetSystemTimeUtcSync(&TimeStracture);
-	if(readRet==0)
+	appGetSystemTimeUtcSync(&TimeStracture);
+    year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
+    month=(TimeStracture.UTCtimer1&0xff00)>>8;
+    day=TimeStracture.UTCtimer1&0xff;
+    hour=(TimeStracture.UTCtimer2&0xff000000)>>24;
+    minute=(TimeStracture.UTCtimer2&0xff0000)>>16;
+    sec=(TimeStracture.UTCtimer2&0xff00)>>8;
+    UTCToBeijing((UTC8TimeType *)&UTC8Time,year,month,day,hour,minute,sec);	
+	if(UTC8Time.year>2000)
 	{
-		year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
-		month=(TimeStracture.UTCtimer1&0xff00)>>8;
-		day=TimeStracture.UTCtimer1&0xff;
-		hour=(TimeStracture.UTCtimer2&0xff000000)>>24;
-		minute=(TimeStracture.UTCtimer2&0xff0000)>>16;
-		sec=(TimeStracture.UTCtimer2&0xff00)>>8;
-		UTCToBeijing((UTC8TimeType *)&UTC8Time,year,month,day,hour,minute,sec);	
-
+		#ifdef USING_PRINTF
+            printf("retal Jug:%d %d %d %d,%d %d %d %d\n",UTC8Time.year,UTC8Time.month,UTC8Time.day,UTC8Time.hour,AppDataInfo.ExpiryTimeArray[0],AppDataInfo.ExpiryTimeArray[1],AppDataInfo.ExpiryTimeArray[2],AppDataInfo.ExpiryTimeArray[3]);
+        #endif
         if(((UTC8Time.year - 0x07D0) & 0xFF)==AppDataInfo.ExpiryTimeArray[0])//年份相等判定月份
         {
             if(UTC8Time.month==AppDataInfo.ExpiryTimeArray[1])//月份相等判定日期
             {
                 if(UTC8Time.day==AppDataInfo.ExpiryTimeArray[2])//日期相等判定小时
                 {
-                    if(UTC8Time.hour<=AppDataInfo.ExpiryTimeArray[3])//小时相等不锁定,小时超出锁定
-                    {
-                        return 0;
-                    }
-                    else
-                    {
-                        return 1;
-                    }
+                    // if(UTC8Time.hour<=AppDataInfo.ExpiryTimeArray[3])//小时相等不锁定,小时超出锁定
+                    // {
+                    //     return 0;
+                    // }
+                    // else
+                    // {
+                    //     return 1;
+                    // }
+                    return 0;
                 }
                 else if(UTC8Time.day>AppDataInfo.ExpiryTimeArray[2])
                 {
@@ -944,7 +956,7 @@ INT8 rentalEndDetectFunc(void)
 	}
     else
     {
-        return 0;//没有获取到时间返回
+        return -1;//没有获取到时间返回
     }
 
 }
@@ -965,13 +977,21 @@ void BattLockFunc(void)
     }
     else if(AppDataInfo.rentaltype==2)// 租赁模式
     {
-        if(rentalEndDetectFunc()==1 && AppDataInfo.rentalLock==FALSE)//租期判定是否超期函数
+        INT8 ret = -1;
+        ret = rentalEndDetectFunc();
+        if(ret==1 && AppDataInfo.rentalLock==FALSE)//租期判定是否超期函数
         {
+            #ifdef USING_PRINTF
+                printf("retal lock,%d\n",ret);
+            #endif
             AppDataInfo.rentalLock=TRUE;
             AppDataInfo.appDataModify=TRUE;
         }
-        else if(rentalEndDetectFunc()==0 && AppDataInfo.rentalLock==TRUE)
+        else if(ret==0 && AppDataInfo.rentalLock==TRUE)
         {
+            #ifdef USING_PRINTF
+                printf("retal unlock,%d\n",ret);
+            #endif
             AppDataInfo.rentalLock=FALSE;
             AppDataInfo.appDataModify=TRUE;
             AppDataInfo.userLock = FALSE;
@@ -988,4 +1008,6 @@ void BattLockFunc(void)
         AppNVMData.isBattLocked = TRUE;
         AppNVMData.appDataModify = TRUE;
     }   
+
+    return;
 }

+ 9 - 8
src/TcpTask.c

@@ -564,7 +564,7 @@ static void TcpDataInfoAssembleSend()
         VerMsgToTcpInfo.VerInfo.BmsInfo = BMS_INFO;
         VerMsgToTcpInfo.VerInfo.DataModuleType = DATA_MODULE_TYPE;
         VerMsgToTcpInfo.CRC = bcc_chk((UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo)-1 );
-        if(NB_Fota_update_flag==FALSE)
+        if(NB_Fota_update_flag==FALSE&&BMS_Fota_update_flag==FALSE)
         {
             len = tcpipConnectionSend(socContext.id, (UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo), 0, 0, 0);
             if(len>0)
@@ -585,9 +585,9 @@ static void TcpDataInfoAssembleSend()
         UINT8 *SendBuffer = NULL;
         UINT8 BufferLen = 0;
         UINT8 rbuf[100];
-        sprintf((char *)rbuf,"%d,%x,%x,%d,%d,%d,%d,%d,,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x",
+        sprintf((char *)rbuf,"%d,%x,%x,%d,%d,%d,%d,%d,,%d,%d,%d,%d,%d,%d,%d",
         Data_Current,BattRemainCap,battProtectState,SOC2,SOC1,battSOC,AppDataInfo.RelayControl,chargerConnectState,
-        Data_33,Data_34,Data_35,Data_37,Data_38,Data_39,Data_3A,Data_3B,Data_3C,Data_3D,Data_3E,Data_3F,Data_40,Data_41,Data_42,Data_43);//累计里程,剩余容量,保护状态,BMS-SOC,acc_soc,disp-soc,relay,
+        AppDataInfo.rentaltype,AppDataInfo.ExpiryTimeArray[0],AppDataInfo.ExpiryTimeArray[1],AppDataInfo.ExpiryTimeArray[2],AppDataInfo.ExpiryTimeArray[3],AppDataInfo.ExpiryTimeArray[4],AppDataInfo.ExpiryTimeArray[5]);
         BufferLen  = strlen(rbuf);
         SendBuffer = malloc(BufferLen+sizeof(DebugMsgInfo));
         memcpy(SendBuffer+sizeof(DebugMsgInfo)-1, rbuf,BufferLen);
@@ -825,8 +825,12 @@ static void TcpDataInfoRecvHandle()
                         MEMCPY(AppDataInfo.ExpiryTimeArray,ExpiryUTC8TimeArray,6);
                         AppDataInfo.appDataModify = TRUE;
                         tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
+                        #ifdef USING_PRINTF
+                            printf("rental!\n");
+                            for(UINT8 i =0 ;i<6;i++)
+                                printf("%d  ",ExpiryUTC8TimeArray[i]);
+                        #endif
                         TcpService=0x00;
-                        
                     }
                     else
                     {
@@ -1011,10 +1015,7 @@ static void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEve
                 #ifdef USING_PRINTF
                     uint8_t* DataPtr;
                     DataPtr=rcvInd->data;
-                    if(rcvInd->length>=43)
-                    {
-                        printf("receive=%u_%x\n",rcvInd->length,*(DataPtr+37)<<24|*(DataPtr+38)<<16|*(DataPtr+39)<<8|*(DataPtr+40));
-                    }  
+                    printf("ID = %u len = %d\n",rcvInd->connectionId,rcvInd->length);  
                 #endif
                 ECOMM_TRACE(UNILOG_PLA_APP, socketAppConnectionCallBack_5, P_INFO, 2, "socketAppConnectionCallBack socket connection %u receive length %u data", rcvInd->connectionId, rcvInd->length);
             }

+ 4 - 4
src/bsp_custom.c

@@ -107,8 +107,8 @@ slpManSlpState_t CheckUsrdefSlpStatus(void)
 void CheckLockOutState(void){
 	if((slpManGetWakeupPinValue() & (0x1<<2)) == 0)
     {
-		#ifdef USING_PRINTF1
-			printf("LOCK_OUT DOWN\r\n");
+		#ifdef USING_PRINTF
+			printf("\n\nLOCK_OUT DOWN\r\n");
 		#endif	
         Lockstatus = true;
 		 #ifdef BL_FILE_LOG
@@ -118,8 +118,8 @@ void CheckLockOutState(void){
     else
     {
         Lockstatus = false;
-		#ifdef USING_PRINTF1
-			printf("LOCK_OUT UP\r\n",__LINE__);
+		#ifdef USING_PRINTF
+			printf("\n\nLOCK_OUT UP\r\n");
 		#endif	
 		 #ifdef BL_FILE_LOG
 			 lockoutState=0;