Browse Source

进行了部分修改,1、电流方向变为自判断方向

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
7dd5bc022f
7 changed files with 54 additions and 34 deletions
  1. 4 1
      inc/Signal.h
  2. 1 0
      inc/app.h
  3. 1 0
      src/MainTask.c
  4. 4 3
      src/Signal.c
  5. 28 4
      src/TcpTask.c
  6. 2 2
      src/UDSService.c
  7. 14 24
      src/UartTask.c

+ 4 - 1
inc/Signal.h

@@ -1,6 +1,6 @@
 #include "commontypedef.h"
 
-extern	UINT32	COMOutTable[28];
+extern	UINT16	COMOutTable[28];
 //declear the UINT8 vars
 extern	UINT8	battCellTemp[8];
 extern	UINT8	MOSTemp;
@@ -50,4 +50,7 @@ extern	UINT32	battBalanceoInfo;
 
 
 
+extern UINT8 	TcpSendLen;
+
+
 

+ 1 - 0
inc/app.h

@@ -97,6 +97,7 @@ typedef struct AppDataType
     UINT8  BmsDisChrgInfoSendFreq;
     UINT8  GpsChrgInfoSendFreq;
     UINT8  GpsDisChrgInfoSendFreq;
+    INT8  BattCurrentNegFlag;
     UINT32 CumulativeCapacity;
 }AppDataBody;
 typedef struct _AppDataHeader

+ 1 - 0
src/MainTask.c

@@ -748,6 +748,7 @@ static void setDefaultAppDataInfo(void)
     AppDataInfo.BmsDisChrgInfoSendFreq = 30;
     AppDataInfo.GpsChrgInfoSendFreq = 30;
     AppDataInfo.GpsDisChrgInfoSendFreq = 5;
+    AppDataInfo.BattCurrentNegFlag = 1;
     AppDataInfo.CumulativeCapacity = 0;
     return;
 }

+ 4 - 3
src/Signal.c

@@ -1,6 +1,6 @@
 #include "Signal.h"
 
-UINT32	COMOutTable[28]	=	{
+UINT16	COMOutTable[28]	=	{
 0x6A0,
 0x6A1,
 0x6A2,
@@ -61,8 +61,6 @@ UINT8	reservedSignal6 = 0xFF;
 UINT8	reservedSignal7 = 0xFF;
 UINT8	reservedSignal8 = 0xFF;
 
-
-
 //declear the UINT16 vars
 UINT16	battCellU[28] = {0xFFFF};
 UINT16	minCellVol = 0xFFFF;
@@ -79,5 +77,8 @@ UINT32	battWarningState = 0xFFFFFFFF;
 UINT32	nbSwVersion = 0xFFFFFFFF;
 UINT32	battBalanceoInfo = 0xFFFFFFFF;
 
+//Tcp
+UINT8 	TcpSendLen = 0;
+
 
 

+ 28 - 4
src/TcpTask.c

@@ -239,7 +239,7 @@ static void TcpDataInfoAssembleSend()
     UINT8 WorkState=0;
     static UINT8 WorkFlag;
 	int i = 0;
-	UINT8 len = 0;
+	INT8 len = -1;
     WorkState = battWorkState;
     if(WorkState==0x00 && WorkFlag==0x01)
     {
@@ -352,6 +352,14 @@ static void TcpDataInfoAssembleSend()
         if(UartBattInfoRecvFlag)
         {
             len = tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
+            if(len>0)
+            {
+                TcpSendLen = 0x02 | TcpSendLen;
+            }
+            else
+            {
+                TcpSendLen = 0xFD & TcpSendLen;
+            }
         }
     }
     if(send_counter%GpsSendFreq==0)
@@ -385,7 +393,15 @@ static void TcpDataInfoAssembleSend()
         osMutexRelease(GpsMutex);
         if(GpsToTcpInfo.gpsInfo.locateMark==0x01)
         {
-            tcpipConnectionSend(socContext.id, (UINT8 *)&GpsToTcpInfo, sizeof(GpsToTcpInfo), 0, 0, 0);
+            len = tcpipConnectionSend(socContext.id, (UINT8 *)&GpsToTcpInfo, sizeof(GpsToTcpInfo), 0, 0, 0);
+            if(len>0)
+            {
+                TcpSendLen = 0x04 | TcpSendLen;
+            }
+            else
+            {
+                TcpSendLen = 0xFB & TcpSendLen;
+            }
         }
     }
     if(send_counter==0)
@@ -446,9 +462,17 @@ static void TcpDataInfoAssembleSend()
         VerMsgToTcpInfo.VerInfo.BmsInfo = BMS_INFO;
         VerMsgToTcpInfo.VerInfo.DataModuleType = DATA_MODULE_TYPE;
         VerMsgToTcpInfo.CRC = bcc_chk((UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo)-1 );
-        if(UartBattInfoRecvFlag)
+        if(1)
         {
-            tcpipConnectionSend(socContext.id, (UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo), 0, 0, 0);
+            len = tcpipConnectionSend(socContext.id, (UINT8 *)&VerMsgToTcpInfo, sizeof(VerMsgToTcpInfo), 0, 0, 0);
+            if(len>0)
+            {
+                TcpSendLen = 0x01 | TcpSendLen;
+            }
+            else
+            {
+                TcpSendLen = 0xFE & TcpSendLen;
+            }
         }
         else
         {

+ 2 - 2
src/UDSService.c

@@ -22,7 +22,7 @@
 #include "app.h"
 #include "CANTask.h"
 #include "flash_ec616_rt.h"
-
+#include "Signal.h"
 #include "UDSService.h"
 
 
@@ -203,7 +203,7 @@ void UDS_Service()
 									}									
 									else if(UDSSubService[i] == 0x06)	//check the tcp link of NB
 									{
-										UDSPositiveAnswer(0x06,i,socContext.status);  //TcpconnectStatus
+										UDSPositiveAnswer(0x06,i,TcpSendLen);  //TcpconnectStatus
 									}
 									else if(UDSSubService[i] == 0x07)  //check the GPS link of NB
 									{

+ 14 - 24
src/UartTask.c

@@ -37,15 +37,9 @@
 extern UINT32 Timer_count;
 extern volatile BOOL Sleep_flag; 
 extern AppNVMDataType AppNVMData;
+extern AppDataBody AppDataInfo;
 //全局变量输出区
-
-
-
 BOOL UartBattInfoRecvFlag  = false;
-
-
-
-osMutexId_t UartMutex = NULL;//Uart数据锁
 QueueHandle_t UartWriteCmdHandle = NULL;
 UINT8 BattChrgEndFlag;
 //
@@ -108,10 +102,6 @@ static void UartTask(void* arg)
 	{
 		UartWriteCmdHandle = osMessageQueueNew(3,sizeof(Uart_Write_Data_Type), NULL);
 	}
-    if(UartMutex == NULL)
-    {
-        UartMutex = osMutexNew(NULL);
-    }
     //上电起始控制区域
     while (1)
     {
@@ -277,7 +267,6 @@ static void UartTask(void* arg)
 //Uart 接收的数据解码
 static BOOL uartBattInfoDecode(UINT8* dataPtr)
 {
-	OsaUtcTimeTValue TimeStracture;
 	//BattInfoType battInfo;
 	UINT8 i,temp=0;
     UINT8 TEMP_NUM = BATT_TEMP_NUM + BATT_OTHER_TEMP_NUM;
@@ -301,17 +290,25 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
 		printf("Batt_current = %x\n",Batt_current);
 	#endif
     //原始数据:充电为负,放电为正
+	if(battWorkState==0x02&&Batt_current>0x8000)
+	{
+		AppDataInfo.BattCurrentNegFlag = 1;
+	}
+	if(battWorkState==0x02&&Batt_current<0x8000)
+	{
+		AppDataInfo.BattCurrentNegFlag = -1;
+	}
     if (Batt_current>0x8000) //为负,充电数据
     {
         Batt_current = (UINT16)((UINT16)(~(Batt_current))+1);
         Batt_current = Batt_current/10;
-        Batt_current = -Batt_current + 0x2710;//平台数据:充电为负
+        Batt_current = -Batt_current*AppDataInfo.BattCurrentNegFlag + 0x2710;//平台数据:充电为负
         //Batt_current = Batt_current;
     }
     else  //为正,数据
     {
         Batt_current = Batt_current/10;
-        Batt_current = Batt_current + 0x2710;//平台数据:充电为负
+        Batt_current = Batt_current*AppDataInfo.BattCurrentNegFlag + 0x2710;//平台数据:充电为负
         //Batt_current = Batt_current;
     }
     battI = Batt_current;
@@ -509,7 +506,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
     *(Uart_Read_Msg+6) = CRC_chk_buffer;
     *(Uart_Read_Msg+7)  = CRC_chk_buffer>>8;
     USARTdrv->Send(Uart_Read_Msg,8);
-    #ifdef USING_PRINTF
+    #ifdef USING_PRINTF1
         printf("Uart_Send_buffer:  ");
         for(int i=0;i<8;i++)
         {
@@ -520,9 +517,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
     USARTdrv->Receive(Uart_Recv_Buffer,Data_Len);
 	while(true)
     {
-        
         timeout++;
-
         if((isRecvTimeout == true) || (isRecvComplete == true))
         {
             break;
@@ -537,7 +532,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
             }
         } 
     }
-     #ifdef USING_PRINTF
+     #ifdef USING_PRINTF1
          printf("Uart_Rece_buffer1: ");
          for(int i=0;i<Data_Len;i++)
          {
@@ -549,7 +544,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
         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);
-	    #ifdef USING_PRINTF
+	    #ifdef USING_PRINTF1
 	         printf("Uart_Rece_buffer after Crc: ");
 	         for(int i=0;i<Data_Len;i++)
 	         {
@@ -598,12 +593,8 @@ BOOL BattHeaterSwitch(UINT8* heaterSwitch)
 	
 	UINT8 i =0;	
 	UINT8 currentSwitchState = 0;
-
 	//get the current switch state and the cell temp
 	currentSwitchState = battMOSSwitchState & 0x01;
-	
-	
-    
 	if(currentSwitchState==0) 	//当前状态为关闭,判断是否应该开启
 	{
 		if(minCellTemp<=5+40 && maxCellTemp<25+40 && battSOC>=12)//温度偏移为40 
@@ -636,7 +627,6 @@ void battSOCDisplay()
 	{
 		return;
 	}
-	
 	if(UartBattInfoRecvFlag == true)
 	{ 
 		lightTimer++;