Browse Source

FTP测试完成,测试版本

LAPTOP-KB7QFH2U\ChenJie-PC 2 years ago
parent
commit
4a415d5cd3

+ 5 - 4
.cproject

@@ -24,9 +24,9 @@
 							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.endianness.823522198" name="Endianness" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.endianness" useByScannerDiscovery="false" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.endianness.little" valueType="enumerated"/>
 							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.fpu.abi.2049331992" name="Float ABI" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.fpu.abi" useByScannerDiscovery="false" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.fpu.abi.hard" valueType="enumerated"/>
 							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.fpu.unit.515607088" name="FPU Type" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.fpu.unit" useByScannerDiscovery="false" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.fpu.unit.fpv4spd16" valueType="enumerated"/>
-							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.unalignedaccess.721888033" name="Unaligned access" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.unalignedaccess" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.unalignedaccess.default" valueType="enumerated"/>
-							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createflash.1857588641" name="Create flash image" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createflash" value="true" valueType="boolean"/>
-							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createlisting.1015999347" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createlisting" value="false" valueType="boolean"/>
+							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.unalignedaccess.721888033" name="Unaligned access" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.unalignedaccess" useByScannerDiscovery="false" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.target.unalignedaccess.default" valueType="enumerated"/>
+							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createflash.1857588641" name="Create flash image" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
+							<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createlisting.1015999347" name="Create extended listing" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.option.addtools.createlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
 							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.64147430" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
 							<builder buildPath="${workspace_loc:/S32K146_4G}/Debug_FLASH" id="com.freescale.s32ds.cross.gnu.builder.466747471" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="FSL Make Builder" superClass="com.freescale.s32ds.cross.gnu.builder"/>
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.9.2.tool.c.compiler.1980082058" name="Standard S32DS C Compiler" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.9.2.tool.c.compiler">
@@ -167,7 +167,7 @@
 								<inputType id="com.freescale.s32ds.cross.gnu.tool.assembler.inputType.asmfile.1184782747" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.inputType.asmfile"/>
 							</tool>
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.createflash.655082520" name="Standard S32DS Create Flash Image" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.createflash">
-								<option id="com.freescale.s32ds.cross.gnu.option.createflash.choice.1410567734" superClass="com.freescale.s32ds.cross.gnu.option.createflash.choice" useByScannerDiscovery="false" value="com.freescale.s32ds.cross.gnu.option.createflash.choice.ihex" valueType="enumerated"/>
+								<option id="com.freescale.s32ds.cross.gnu.option.createflash.choice.1410567734" name="Output file format (-O)" superClass="com.freescale.s32ds.cross.gnu.option.createflash.choice" useByScannerDiscovery="false" value="com.freescale.s32ds.cross.gnu.option.createflash.choice.ihex" valueType="enumerated"/>
 							</tool>
 							<tool id="com.freescale.s32ds.cross.gnu.tool.createlisting.958717661" name="Standard S32DS Create Listing" superClass="com.freescale.s32ds.cross.gnu.tool.createlisting">
 								<option id="com.freescale.s32ds.cross.gnu.option.createlisting.source.623943954" name="Display source (--source|-S)" superClass="com.freescale.s32ds.cross.gnu.option.createlisting.source" value="true" valueType="boolean"/>
@@ -798,4 +798,5 @@
 		<COND_TOOLCHAIN_COPY_SOURCES>true</COND_TOOLCHAIN_COPY_SOURCES>
 	</storageModule>
 	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
+	<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
 </cproject>

+ 2 - 2
Project_Settings/Debugger/S32K146_4G_Debug_FLASH_PNE.launch

@@ -77,7 +77,7 @@
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.cyc_usb.STARTUP_USE_SWD" value="true"/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.doContinue" value="true"/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.doGdbServerAllocateSemihostingConsole" value="true"/>
-<booleanAttribute key="com.pemicro.debug.gdbjtag.pne.doPartitioning" value="true"/>
+<booleanAttribute key="com.pemicro.debug.gdbjtag.pne.doPartitioning" value="false"/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.enableSemihosting" value="true"/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.enableSemihostingIoclientGdbClient" value="false"/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.enableSemihostingIoclientTelnet" value="true"/>
@@ -216,5 +216,5 @@
 </listAttribute>
 <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536806032&quot; label=&quot;RX_Buffer[UART_LPUART2]&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536823956&quot; label=&quot;GpsBufferGet&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;255&quot; label=&quot;SocketId&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536805632&quot; label=&quot;0x1fff0100&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536806632&quot; label=&quot;0x1fff04e8&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
-<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="0x8000000,0x80000000,0x140000,0x1400000,0x14000000,0x80080,0x80200,0x1fffbe77,0x1fffbce0,0x1fffbcd7,0x10000010,0x1000000,0x10000000,0x1fffbea0,0x1fff7dee"/>
+<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="0x1fffbcd7,0x10000010,0x1000000,0x10000000,0x1fffbea0,0x1fff7dee,0x1fffbbed,0x1fffbc88,0x1fffbc8a,0x14200,0x80000,0x1fffbb20,0x1fffbb3e,0x1fffb348,0x1fffb5cd"/>
 </launchConfiguration>

+ 18 - 11
Project_Settings/Linker_Files/linker_flash_s32k146.ld

@@ -31,13 +31,19 @@
 
 MEMORY
 {         
-    int_flash_interrupts    : ORIGIN = 0x00000000, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
-    int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
-    int_flash               : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0    /* ~1.0MB */ 
+    int_flash_interrupts    : ORIGIN = 0x00014200, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
+   /* int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
+     int_flash               : ORIGIN = 0x00014600, LENGTH = 0x000EBA00    /* ~1.0MB */ 
+/*	int_flash_interrupts    : ORIGIN = 0x00080200, LENGTH = 0x00000400	/**/
+/*	int_flash               : ORIGIN = 0x00080600, LENGTH = 0x0007FA00	/**/
+	
+	m_flexram				: ORIGIN = 0x14000000, LENGTH = 0x00001000	
+	
     int_sram_results        : ORIGIN = 0x1FFF0000, LENGTH = 0x00000100    /* 256bytes */
     int_sram                : ORIGIN = 0x1FFF0100, LENGTH = 0x0001DF00    /* ~120K */
-    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000    /* 4K  */
-    ram_rsvd2               : ORIGIN = 0x2000F000, LENGTH = 0             /* End of SRAM */
+    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000 - 0x10    /* 4K  */
+    ram_rsvd2               : ORIGIN = 0x2000EFF0, LENGTH = 0             /* End of SRAM */
+    ExchangeInfo            : ORIGIN = 0x2000EFF0, LENGTH = 0x10          
 }
 
 
@@ -54,17 +60,17 @@ SECTIONS
     
 	.flash_interrupts :
 	{
-		. = ALIGN(4096);
+		. = ALIGN(512);
         __interrupts_rom_start = .;
         KEEP(*(.intc_vector))    
-        . = ALIGN(4);
+        . = ALIGN(512);
         __interrupts_rom_end = .;
 	} > int_flash_interrupts
 	
-	.flash_config :
-	{
-		KEEP(*(.flash_config))
-	} > int_flash_config
+/*	.flash_config :				*/
+/*	{							*/
+/*		KEEP(*(.flash_config))	*/
+/*	} > int_flash_config		*/
 	
 	.flash :
 	{
@@ -111,6 +117,7 @@ SECTIONS
 		__DATA_ROM = .;
 	} > int_flash
     
+    
     . = ALIGN(4);
     PROVIDE(__exidx_start = .);
     .ARM.exidx :

+ 11 - 18
Project_Settings/Linker_Files/linker_flash_s32k146.ldota → Project_Settings/Linker_Files/linker_flash_s32k146.ldfls

@@ -31,19 +31,13 @@
 
 MEMORY
 {         
-    int_flash_interrupts    : ORIGIN = 0x00014200, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
-   /* int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
-     int_flash               : ORIGIN = 0x00014600, LENGTH = 0x000EBA00    /* ~1.0MB */ 
-/*	int_flash_interrupts    : ORIGIN = 0x00080200, LENGTH = 0x00000400	/**/
-/*	int_flash               : ORIGIN = 0x00080600, LENGTH = 0x0007FA00	/**/
-	
-	m_flexram				: ORIGIN = 0x14000000, LENGTH = 0x00001000	
-	
+    int_flash_interrupts    : ORIGIN = 0x00000000, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
+    int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
+    int_flash               : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0    /* ~1.0MB */ 
     int_sram_results        : ORIGIN = 0x1FFF0000, LENGTH = 0x00000100    /* 256bytes */
     int_sram                : ORIGIN = 0x1FFF0100, LENGTH = 0x0001DF00    /* ~120K */
-    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000 - 0x10    /* 4K  */
-    ram_rsvd2               : ORIGIN = 0x2000EFF0, LENGTH = 0             /* End of SRAM */
-    ExchangeInfo            : ORIGIN = 0x2000EFF0, LENGTH = 0x10          
+    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000    /* 4K  */
+    ram_rsvd2               : ORIGIN = 0x2000F000, LENGTH = 0             /* End of SRAM */
 }
 
 
@@ -60,17 +54,17 @@ SECTIONS
     
 	.flash_interrupts :
 	{
-		. = ALIGN(512);
+		. = ALIGN(4096);
         __interrupts_rom_start = .;
         KEEP(*(.intc_vector))    
-        . = ALIGN(512);
+        . = ALIGN(4);
         __interrupts_rom_end = .;
 	} > int_flash_interrupts
 	
-/*	.flash_config :				*/
-/*	{							*/
-/*		KEEP(*(.flash_config))	*/
-/*	} > int_flash_config		*/
+	.flash_config :
+	{
+		KEEP(*(.flash_config))
+	} > int_flash_config
 	
 	.flash :
 	{
@@ -117,7 +111,6 @@ SECTIONS
 		__DATA_ROM = .;
 	} > int_flash
     
-    
     . = ALIGN(4);
     PROVIDE(__exidx_start = .);
     .ARM.exidx :

+ 1 - 0
src/AppGlobalVar.c

@@ -22,6 +22,7 @@ uint8 TcpbattSN[17] = {0x31}; //???SN??
 
 volatile uint32 TimerCounter = 0; // msµ¥Î»
 uint8 Fota_update_flag = 0;
+uint8 Fota_error_flag = 0;
 /*GPS*/
 QueueHandle_t GpsDataQueueHandle;
 sint16 xyzData[3] = {0};

+ 4 - 3
src/AppGlobalVar.h

@@ -24,9 +24,9 @@
 #define defaultSn "SPFPFL264S226D001"
 #define BATT_SN_LEN 17
 #define HWVERSION 0x0001
-#define BLSWVERSION 0x00000001
-#define DRVSWVERSION 0x00000001
-#define APPSWVERSION 0x00000003
+#define BLSWVERSION 0x00000002
+#define DRVSWVERSION 0x00000002
+#define APPSWVERSION 0x00000005
 #define BMS_MANUFACTURE 0xFF
 #define BMS_INFO 0xFF
 #define DATA_MODULE_TYPE 0x02
@@ -36,6 +36,7 @@ extern uint8 TcpbattSN[17];
 extern uint8 VIN[17];
 extern volatile uint32 TimerCounter;
 extern uint8 Fota_update_flag;
+extern uint8 Fota_error_flag;
 typedef struct
 {
     uint8 RealLen;

+ 24 - 48
src/AppTaskCan.c

@@ -5,7 +5,6 @@
  *      Author: QiXiang_CHENJIE
  */
 #include "AppTaskCan.h"
-uint32 timerCounterNow = 0;
 static uint8 BattSendFlg = 0;
 static void UDSAnsFunc(uint8 *rawData);
 static void UdsAns(bool PosFlg,uint8 UdsService,uint8 UdsSubService,uint8 Idx,uint8 *AnsData,uint8 AnsDataLen);
@@ -21,6 +20,7 @@ static void vCanRxCallback(TimerHandle_t pxTimer)
 }
 void CanTask(void *pvParameters)
 {
+	uint32 timerCounterNow = 0;
 	(void)pvParameters;
 	CanIf_bRxFlag = false;
 	Can_Msg_Type_Data CanRxMsg;
@@ -56,36 +56,12 @@ void CanTask(void *pvParameters)
 		{
 			BattSendFunc();
 		}
-		if((TimerCounter - timerCounterNow)>100)
+		if((TimerCounter - timerCounterNow)>=100)
 		{
 			timerCounterNow = TimerCounter;
 			//ζȲɼ¯
 			ADC_ReadValue();
 		}
-		if(BattTempR[1]<=0xFF)
-		{
-			Dio_WriteChannel(DioConf_DioChannel_PTD15_GPIO_OUT_MCU_BUZ_EN, STD_ON);
-		}
-		else
-		{
-			Dio_WriteChannel(DioConf_DioChannel_PTD15_GPIO_OUT_MCU_BUZ_EN, STD_OFF);
-		}
-		if(BattTempR[2]<=0xFF)
-		{
-			Dio_WriteChannel(DioConf_DioChannel_PTD16_GPIO_OUT_MCU_RELAY_POW_EN, STD_ON);
-		}
-		else
-		{
-			Dio_WriteChannel(DioConf_DioChannel_PTD16_GPIO_OUT_MCU_RELAY_POW_EN, STD_OFF);
-		}
-		if(BattTempR[3]<=0xFF)
-		{
-			Dio_WriteChannel(DioConf_DioChannel_PTA11_GPIO_OUT_MCU_BMS_WAKEUP_EN, STD_ON);
-		}
-		else
-		{
-			Dio_WriteChannel(DioConf_DioChannel_PTA11_GPIO_OUT_MCU_BMS_WAKEUP_EN, STD_OFF);
-		}
 	}
 }
 //×¢Òâ½âÂ볬ÏÞÎÊÌâ
@@ -343,7 +319,6 @@ static void BattSendFunc(void)
 	case 0x00:
 	{
 		SendStep++;
-		return;
 		break;
 	}
 	case 0x01:
@@ -394,18 +369,19 @@ static void BattSendFunc(void)
 		{
 			SendCounter = 0;
 			SendStep++;
-			return;
 			break;
 		}
-		SendData[0] =  battCellTemp[SendCounter*8 + 0];
-		SendData[1] =  battCellTemp[SendCounter*8 + 1];
-		SendData[2] =  battCellTemp[SendCounter*8 + 2];
-		SendData[3] =  battCellTemp[SendCounter*8 + 3];
-		SendData[4] =  battCellTemp[SendCounter*8 + 4];
-		SendData[5] =  battCellTemp[SendCounter*8 + 5];
-		SendData[6] =  battCellTemp[SendCounter*8 + 6];
-		SendData[7] =  battCellTemp[SendCounter*8 + 7];
-		SendCounter++;
+		else
+		{
+			SendData[0] =  battCellTemp[SendCounter*8 + 0];
+			SendData[1] =  battCellTemp[SendCounter*8 + 1];
+			SendData[2] =  battCellTemp[SendCounter*8 + 2];
+			SendData[3] =  battCellTemp[SendCounter*8 + 3];
+			SendData[4] =  battCellTemp[SendCounter*8 + 4];
+			SendData[5] =  battCellTemp[SendCounter*8 + 5];
+			SendData[6] =  battCellTemp[SendCounter*8 + 6];
+			SendData[7] =  battCellTemp[SendCounter*8 + 7];
+		}
 		break;
 	}
 	case 0x05:
@@ -415,25 +391,25 @@ static void BattSendFunc(void)
 		{
 			SendCounter = 0;
 			SendStep++;
-			return;
 			break;
 		}
-		SendData[0] =  battCellU[SendCounter*4 + 0]>>8;
-		SendData[1] =  battCellU[SendCounter*4 + 0];
-		SendData[2] =  battCellU[SendCounter*4 + 1]>>8;
-		SendData[3] =  battCellU[SendCounter*4 + 1];
-		SendData[4] =  battCellU[SendCounter*4 + 2]>>8;
-		SendData[5] =  battCellU[SendCounter*4 + 2];
-		SendData[6] =  battCellU[SendCounter*4 + 3]>>8;
-		SendData[7] =  battCellU[SendCounter*4 + 3];
-		SendCounter++;
+		else
+		{
+			SendData[0] =  battCellU[SendCounter*4 + 0]>>8;
+			SendData[1] =  battCellU[SendCounter*4 + 0];
+			SendData[2] =  battCellU[SendCounter*4 + 1]>>8;
+			SendData[3] =  battCellU[SendCounter*4 + 1];
+			SendData[4] =  battCellU[SendCounter*4 + 2]>>8;
+			SendData[5] =  battCellU[SendCounter*4 + 2];
+			SendData[6] =  battCellU[SendCounter*4 + 3]>>8;
+			SendData[7] =  battCellU[SendCounter*4 + 3];
+		}
 		break;
 	}
 	default:
 	{
 		SendStep = 0;
 		BattSendFlg = 0;
-		return;
 		break;
 	}
 	}

+ 4 - 1
src/AppTaskMain.c

@@ -22,6 +22,9 @@ void MainTask(void *pvParameters)
 		HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
 	}
 	HAL_EEP_Read(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
+	#if UARTPRINTF==1
+		create_ringBuffer(&printfRingBuffer,ringbuffer,sizeof(ringbuffer));
+	#endif
 	while(1)
 	{
 		vTaskDelay(pdMS_TO_TICKS(10));
@@ -37,7 +40,7 @@ void MainTask(void *pvParameters)
 			AppConfigInfo.appSaveFlg = false;
 			HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
 		}
-		if(Fota_update_flag)//升级指令发出,进行重启
+		if(Fota_update_flag || Fota_error_flag)//升级指令发出,进行重启,或者FTP服务器出现问题,进行重启
 		{
 			//重启前保存数据
 			AppConfigInfo.appSaveFlg = false;

+ 74 - 67
src/AppTaskUart0.c

@@ -41,6 +41,7 @@ void Uart0Task(void *pvParameters)
 		}
 		case PROCESS_UART_STATE_READ:
 		{
+			static uint16 readCnt = 0;
 			/*电压电流数据读取(第一次读取)*/
 			uint8 *UartDataRecv = NULL;
 			pReadLen = 0;
@@ -193,81 +194,87 @@ void Uart0Task(void *pvParameters)
 				PutErrorNum(ErrorArray, sizeof(ErrorArray)/2, 1);
 				vTaskDelay(pdMS_TO_TICKS(5000));
 			}
-
-			/**电表数据读取*/
-			for(uint8 i=0;i<2;i++)
+			if(readCnt%60==0)
 			{
-				/*电表参数读取*/
-				static uint16 pt[2] = {0};
-				static uint16 ct[2] = {0};
-				pReadLen = 0;
-				uint8 *UartRecvPtr=NULL;
-				RegAddrBegin = 0x0FA1;
-				Reg_Num = 0x02;
-				Uart0AskMsg.Bms_Address = METER1_ADDRESS_CODE+i;//第一次读02,第二次读03
-				Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
-				Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
-				Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
-				Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
-				Uart0AskMsg.Reg_Num_L = Reg_Num;
-				CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
-				Uart0AskMsg.CRC_L = CRC_chk_buffer;
-				Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
-				UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
-				UART_Receive_Data(UART_LPUART0, &UartRecvPtr, &pReadLen, 1000);
-				//电表数据解析
-				if (pReadLen > 0)
+				/**电表数据读取*/
+				for(uint8 i=0;i<2;i++)
 				{
-					uint16 CrcChkGet = 0xffff;
-					uint16 CrcChkCal = 0x0000;
-					CrcChkCal = crc_chk(UartRecvPtr, pReadLen-2);
-					CrcChkGet =  ((uint16)(*(UartRecvPtr+pReadLen-1))<<8) | ((uint16)(*(UartRecvPtr+pReadLen-2)));
-					if(CrcChkCal==CrcChkGet)
+					/*电表参数读取*/
+					static uint16 pt[2] = {0};
+					static uint16 ct[2] = {0};
+					pReadLen = 0;
+					uint8 *UartRecvPtr=NULL;
+					RegAddrBegin = 0x03;
+					Reg_Num = 0x02;
+					Uart0AskMsg.Bms_Address = METER1_ADDRESS_CODE+i;//第一次读02,第二次读03
+					Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
+					Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
+					Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
+					Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
+					Uart0AskMsg.Reg_Num_L = Reg_Num;
+					CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
+					Uart0AskMsg.CRC_L = CRC_chk_buffer;
+					Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
+					UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
+					UART_Receive_Data(UART_LPUART0, &UartRecvPtr, &pReadLen, 1000);
+					//电表数据解析
+					if (pReadLen > 0)
 					{
-						pt[i] = ((uint16)(*(UartRecvPtr+3))<<8) | ((uint16)(*(UartRecvPtr+4)));
-						ct[i] = ((uint16)(*(UartRecvPtr+5))<<8) | ((uint16)(*(UartRecvPtr+6)));
+						uint16 CrcChkGet = 0xffff;
+						uint16 CrcChkCal = 0x0000;
+						CrcChkCal = crc_chk(UartRecvPtr, pReadLen-2);
+						CrcChkGet =  ((uint16)(*(UartRecvPtr+pReadLen-1))<<8) | ((uint16)(*(UartRecvPtr+pReadLen-2)));
+						if(CrcChkCal==CrcChkGet)
+						{
+							pt[i] = ((uint16)(*(UartRecvPtr+3))<<8) | ((uint16)(*(UartRecvPtr+4)));
+							ct[i] = ((uint16)(*(UartRecvPtr+5))<<8) | ((uint16)(*(UartRecvPtr+6)));
+						}
 					}
-				}
-				if(UartRecvPtr!=NULL)
-				{
-					free(UartRecvPtr);
-				}
-				UartRecvPtr=NULL;
-				/*电表电量数据读取*/
-				pReadLen = 0;
-				RegAddrBegin = 0x1B58;
-				Reg_Num = 0x08;
-				Uart0AskMsg.Bms_Address = METER1_ADDRESS_CODE+i;//第一次读02,第二次读03
-				Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
-				Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
-				Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
-				Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
-				Uart0AskMsg.Reg_Num_L = Reg_Num;
-				CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
-				Uart0AskMsg.CRC_L = CRC_chk_buffer;
-				Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
-				UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
-				UART_Receive_Data(UART_LPUART0, &UartRecvPtr, &pReadLen, 1000);
-				//电表数据解析
-				if (pReadLen > 0)
-				{
-					uint16 CrcChkGet = 0xffff;
-					uint16 CrcChkCal = 0x0000;
-					CrcChkCal = crc_chk(UartRecvPtr, pReadLen-2);
-					CrcChkGet =  ((uint16)(*(UartRecvPtr+pReadLen-1))<<8) | ((uint16)(*(UartRecvPtr+pReadLen-2)));
-					if(CrcChkCal==CrcChkGet)
+					if(UartRecvPtr!=NULL)
 					{
-						meterAllPwr[i] = pt[i]*ct[i]*(((uint32)(*(UartRecvPtr+3))<<24)|((uint32)(*(UartRecvPtr+4))<<16)|((uint32)(*(UartRecvPtr+5))<<8) | ((uint32)(*(UartRecvPtr+6))));
-						meterPosPwr[i] = pt[i]*ct[i]*((uint32)(*(UartRecvPtr+11))<<24)|((uint32)(*(UartRecvPtr+12))<<16)|((uint32)(*(UartRecvPtr+13))<<8) | ((uint32)(*(UartRecvPtr+14)));
-						meterNegPwr[i] = pt[i]*ct[i]*((uint32)(*(UartRecvPtr+15))<<24)|((uint32)(*(UartRecvPtr+16))<<16)|((uint32)(*(UartRecvPtr+17))<<8) | ((uint32)(*(UartRecvPtr+18)));
+						free(UartRecvPtr);
 					}
+					UartRecvPtr=NULL;
+					/*电表电量数据读取*/
+					pReadLen = 0;
+					RegAddrBegin = 0x3F;
+					Reg_Num = 0x04;
+					Uart0AskMsg.Bms_Address = METER1_ADDRESS_CODE+i;//第一次读02,第二次读03
+					Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
+					Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
+					Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
+					Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
+					Uart0AskMsg.Reg_Num_L = Reg_Num;
+					CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
+					Uart0AskMsg.CRC_L = CRC_chk_buffer;
+					Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
+					UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
+					UART_Receive_Data(UART_LPUART0, &UartRecvPtr, &pReadLen, 1000);
+					//电表数据解析
+					if (pReadLen > 0)
+					{
+						uint16 CrcChkGet = 0xffff;
+						uint16 CrcChkCal = 0x0000;
+						CrcChkCal = crc_chk(UartRecvPtr, pReadLen-2);
+						CrcChkGet =  ((uint16)(*(UartRecvPtr+pReadLen-1))<<8) | ((uint16)(*(UartRecvPtr+pReadLen-2)));
+						if(CrcChkCal==CrcChkGet)
+						{
+							//meterAllPwr[i] = pt[i]*ct[i]*(((uint32)(*(UartRecvPtr+3))<<24)|((uint32)(*(UartRecvPtr+4))<<16)|((uint32)(*(UartRecvPtr+5))<<8) | ((uint32)(*(UartRecvPtr+6))));
+							meterPosPwr[i] = pt[i]*ct[i]*((uint32)(*(UartRecvPtr+3))<<24)|((uint32)(*(UartRecvPtr+4))<<16)|((uint32)(*(UartRecvPtr+5))<<8) | ((uint32)(*(UartRecvPtr+6)));
+							meterNegPwr[i] = pt[i]*ct[i]*((uint32)(*(UartRecvPtr+7))<<24)|((uint32)(*(UartRecvPtr+8))<<16)|((uint32)(*(UartRecvPtr+9))<<8) | ((uint32)(*(UartRecvPtr+10)));
+							meterPosPwr[i] = meterPosPwr[i] * 100;
+							meterNegPwr[i] = meterNegPwr[i] * 100;
+							meterAllPwr[i] = meterPosPwr[i] + meterNegPwr[i];
+						}
+					}
+					if(UartRecvPtr!=NULL)
+					{
+						free(UartRecvPtr);
+					}
+					UartRecvPtr=NULL;
 				}
-				if(UartRecvPtr!=NULL)
-				{
-					free(UartRecvPtr);
-				}
-				UartRecvPtr=NULL;
 			}
+			readCnt++;
 			PROC_UART0_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
 			break;
 		}

+ 1 - 1
src/AppTaskUart0.h

@@ -12,7 +12,7 @@
 #include "AppGlobalVar.h"
 #ifdef APP_UART0_ENABLE
 #define BMS_ADDRESS_CODE 0x01
-#define METER1_ADDRESS_CODE 0x05
+#define METER1_ADDRESS_CODE 0x04
 #define UART_READ_CODE 0x03
 #define UART_WRITE_CODE 0x10
 #define UART_ENCRYPT_CODE 0x05

+ 121 - 162
src/AppTaskUart1.c

@@ -44,24 +44,26 @@ void GetUtc8Time(UTC8TimeType *UTC8TimeTcp);
 static void AtcmdTransmit(sint8 CmdIdx, uint8 *SetValuePtr, uint16 SetValueLen, sint8 *retFunc,uint16 timeout);
 static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen);
 static void GetCSQValue(uint8 *out);
-void Fota_Ftp(void);
+void Fota_Ftp(uint8 *dataPtrIn);
 void tcpUdsFunc(Ptr,TcpCmdAnswer);
 void Uart_4G_Task(void *pvParameters)
 {
 	(void)pvParameters;
+	uint32 SendTimerCounter = 0;
+	uint32 RecvTimerDelay = 0;
+	uint8 *UartRecvPtr=NULL;
+	volatile uint16 tcpErrorCounter = 0;
+	uint16 pReadLen = 0;
 	// 4G开机
+	Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
 	Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
+	vTaskDelay(pdMS_TO_TICKS(50));
 	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
-	Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
+	vTaskDelay(pdMS_TO_TICKS(50));
+	vTaskDelay(pdMS_TO_TICKS(10000));
+	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
 	_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
-	// LED测试
-	Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-	vTaskDelay(pdMS_TO_TICKS(5000));
-	uint16 pReadLen = 0;
 	InitFunc(); // 4G模块初始化,注:AT同步不通过,没有进行次数判定及跳转
-	uint32 SendTimerCounter = 0;
-	uint32 RecvTimerDelay = 0;
-	uint8 *UartRecvPtr=NULL;
 	for (;;)
 	{
 		switch (gProcess_Tcp_Task)
@@ -140,6 +142,7 @@ void Uart_4G_Task(void *pvParameters)
 			if (SendRet == 0)
 			{
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
+				tcpErrorCounter = 0;
 			}
 			else
 			{
@@ -175,10 +178,24 @@ void Uart_4G_Task(void *pvParameters)
 		}
 		case PROCESS_TCP_ERROR: //错误状态
 		{
-//			Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
-//			vTaskDelay(pdMS_TO_TICKS(100));
+			vTaskDelay(pdMS_TO_TICKS(1000));
+			tcpErrorCounter++;
+			if(tcpErrorCounter>60)//无法驻网或者联网,重置4G模组
+			{
+				Dio_WriteChannel(DioConf_DioChannel_PTD3_GPIO_OUT_MCU_4G_RESET, STD_ON);
+				vTaskDelay(pdMS_TO_TICKS(2500));
+				Dio_WriteChannel(DioConf_DioChannel_PTD3_GPIO_OUT_MCU_4G_RESET, STD_OFF);
+				_4G_Status = 0;
+				tcpErrorCounter = 0;
+				while(_4G_Status!=1&&tcpErrorCounter<60)
+				{
+					tcpErrorCounter++;
+					vTaskDelay(pdMS_TO_TICKS(500));
+					_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
+				}
+				tcpErrorCounter = 0;
+			}
 			PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
-//			Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
 			break;
 		}
 		}
@@ -721,27 +738,27 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 	static uint32 TcpSendTimeCounter = 0;
 	TcpSendTimeCounter++;
 
-	if (TcpSendTimeCounter%60 == 0)
+	if (TcpSendTimeCounter%60 == 1)
 	{
 		DataIdx = VerMsg; //版本信息发送
 	}
-	else if (TcpSendTimeCounter % 10 == 0)
+	else if (TcpSendTimeCounter % 10 == 1)
 	{
 		DataIdx = BattMsg; //电池信息发送
 	}
-	else if ((TcpSendTimeCounter+1) % 10 == 0)
+	else if ((TcpSendTimeCounter) % 10 == 2)
 	{
 		DataIdx = 0x83; //储能开关信息发送
 	}
-	else if ((TcpSendTimeCounter+2) % 240 == 0)
+	else if ((TcpSendTimeCounter) % 240 == 3)
 	{
 		DataIdx = GpsMsg; //定位信息发送
 	}
-	else if ((TcpSendTimeCounter+3) % 240 == 0)
+	else if ((TcpSendTimeCounter) % 240 == 4)
 	{
 		DataIdx = 0x93; //储能电量信息发送
 	}
-	else if ((TcpSendTimeCounter+4) % 60 == 0)
+	else if ((TcpSendTimeCounter) % 60 == 5)
 	{
 		DataIdx = 0x8A; //累计信息发送
 	}
@@ -1226,7 +1243,15 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
 				TcpCmdAnswer[2] = TCP_CONCMD_SYM;
 				if (*(Ptr + 30) == 0x83) //远程升级指令
 				{
-					Fota_Ftp();
+                    TcpCmdAnswer[3] = 0x01;
+                    memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
+                    TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
+                    TcpCmdAnswer[22] = 0x00;
+                    TcpCmdAnswer[23] = 0x06;
+                    memcpy(&TcpCmdAnswer[24], (Ptr + 24), 6);
+                    TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer, 30);
+					tcpipConnectionSend(SocketId, TcpCmdAnswer, 31);
+					Fota_Ftp(Ptr + 32);
 				}
                 else if (*(Ptr + 30) == 0x80) //远程锁定命令
                 {
@@ -1287,7 +1312,6 @@ void tcpUdsFunc(uint8 *Ptr,uint8 *AnsPtr)
 	uint16 DIDBuffer = 0;
 	uint8 udsType_SID = 0;
 	uint8 DataBuffer[10];
-	uint8 *DataBufferPtr = NULL;
 	contrlType = *(Ptr + 30);
 	udsDataLen = *(Ptr + 31);
 	udsType_SID = *(Ptr + 32);
@@ -1411,18 +1435,16 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
 	UartRecvPtr1 = NULL;
 	return outValue;
 }
-void Fota_Ftp(void)
+void Fota_Ftp(uint8 *dataPtrIn)
 {
-	uint8 ftp_process = 0;
-	uint8 ftp_EndFlg = 0;
-	uint8 ftp_ErrCnt = 0;
+	static uint8 ftp_process = 0;
 	char *ATCmdSend = NULL;
-	uint8 ATCmdSendLen = 0;
+	sint8 recvRet = -1;
 	char ATSendDataBuffer[100] = {0};
 	uint8 *UartRecvPtr = NULL;
 	uint16 ReadLen = 0;
 	uint8 *retptr = NULL;
-	char temp[70]=",qx,qx900,120.27.243.131,21,0,0.0.1.5,0.0.1.5,/Debug/V0.0.1.5.bin,";
+//	char temp[70]=",qx,qx900,120.27.243.131,21,0,0.0.1.5,0.0.1.5,/Debug/V0.0.1.5.bin,";
 	/*URL信息解析*/
 	char *databuffer[20];
 	char *accountPtr;
@@ -1433,8 +1455,9 @@ void Fota_Ftp(void)
 	char *filenamePtr;
 	char keyFilename[20]={0};
 	char *p = NULL;
-	p = strtok(temp, ",");
+	p = strtok((char *)dataPtrIn, ",");
 	uint8 index = 0;
+	uint8 ftp_EndFlg = 0;
 	while (p)
 	{
 		databuffer[index] = p;
@@ -1461,190 +1484,104 @@ void Fota_Ftp(void)
 	while(!ftp_EndFlg)
 	{
 		vTaskDelay(pdMS_TO_TICKS(100));
-		if(ftp_ErrCnt>5)
-		{
-			ftp_ErrCnt = 0;
-			ftp_EndFlg = 1;
-		}
+#if UARTPRINTF==1
+	myPrintf("ftpProcess-%d",ftp_process);
+#endif
 		switch(ftp_process)
 		{
 		case 0://start
 		{
 			ATCmdSend = (char *)("AT+CFTPSSTART\r\n");
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
-			if (ReadLen > 0)
+			UART_Send_Data(UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), pdMS_TO_TICKS(100));
+			recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSSTART: 0"),2000);
+			if(recvRet==0)
 			{
-				retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
-				if (retptr)
-				{
-					ftp_ErrCnt = 0;
-					ftp_process++;
-				}
+				ftp_process++;
 			}
 			else
 			{
-				ftp_ErrCnt++;
-			}
-			if(UartRecvPtr != NULL)
-			{
-				free(UartRecvPtr);
+				ftp_EndFlg=1;
 			}
-			UartRecvPtr = NULL;
 			break;
 		}
 		case 1://login
 		{
-			uint8 *UartData = NULL;
+			memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
 			sprintf(ATSendDataBuffer, "AT+CFTPSLOGIN=\"%s\",%s,\"%s\",\"%s\",0\r\n", ftpServerIpPtr, ftpServerPort,accountPtr,passwordPtr);
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
-			while (1)
+			UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
+			recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSLOGIN: 0"),30000);
+			if(recvRet==0)
 			{
-				UART_Receive_Data(UART_LPUART1,&UartData, &ReadLen,10000);
-				retptr = (uint8 *)strstr((char *)UartData, (char *)("+CFTPSLOGIN: 0"));
-				if (retptr)
-				{
-					ftp_ErrCnt = 0;
-					ftp_process++;
-					break;
-				}
-				else
-				{
-					ftp_ErrCnt++;
-				}
-				if(UartData != NULL)
-				{
-					free(UartData);
-				}
-				UartData = NULL;
+				ftp_process++;
 			}
-			if(UartRecvPtr != NULL)
+			else
 			{
-				free(UartRecvPtr);
+				ftp_EndFlg=1;
 			}
-			UartRecvPtr = NULL;
 			break;
 		}
 		case 2://transmit bin file from server to module
 		{
 			uint8 *UartData = NULL;
+			memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
 			sprintf(ATSendDataBuffer, "AT+CFTPSGETFILE=\"%s/%s\"\r\n", filePathPtr,filenamePtr);
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
-			while (1)
+			UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
+			recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSGETFILE: 0"),10000);
+			if(recvRet==0)
 			{
-				UART_Receive_Data(UART_LPUART1,&UartData, &ReadLen,10000);
-				retptr = (uint8 *)strstr((char *)UartData, (char *)("+CFTPSGETFILE: 0"));
-				if (retptr)
-				{
-					ftp_ErrCnt = 0;
-					ftp_process++;
-					break;
-				}
-				else
-				{
-					ftp_ErrCnt++;
-				}
-				if(ftp_ErrCnt>5)
-				{
-					ftp_ErrCnt = 0;
-					ftp_process++;
-					break;
-				}
-				if(UartData != NULL)
-				{
-					free(UartData);
-				}
-				UartData = NULL;
+				ftp_process++;
 			}
-			if(UartRecvPtr != NULL)
+			else
 			{
-				free(UartRecvPtr);
+				ftp_EndFlg=1;
 			}
-			UartRecvPtr = NULL;
 			break;
 		}
 		case 3://transmit zl file from server to module
 		{
 			uint8 *UartData = NULL;
+			memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
 			sprintf(ATSendDataBuffer, "AT+CFTPSGETFILE=\"%s/%s\"\r\n", filePathPtr,keyFilename);
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(1000));
-			while (1)
+			UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
+			recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSGETFILE: 0"),10000);
+			if(recvRet==0)
 			{
-				UART_Receive_Data(UART_LPUART1,&UartData, &ReadLen,10000);
-				retptr = (uint8 *)strstr((char *)UartData, (char *)("+CFTPSGETFILE: 0"));
-				if (retptr)
-				{
-					ftp_ErrCnt = 0;
-					ftp_process++;
-					break;
-				}
-				else
-				{
-					ftp_ErrCnt++;
-				}
-				if(ftp_ErrCnt>5)
-				{
-					ftp_ErrCnt = 0;
-					ftp_process++;
-					break;
-				}
-				if(UartData != NULL)
-				{
-					free(UartData);
-				}
-				UartData = NULL;
+				ftp_process++;
 			}
-			if(UartRecvPtr != NULL)
+			else
 			{
-				free(UartRecvPtr);
+				ftp_EndFlg=1;
 			}
-			UartRecvPtr = NULL;
 			break;
 		}
 		case 4://logout
 		{
 			ATCmdSend = (char *)("AT+CFTPSLOGOUT\r\n");
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
-			if (ReadLen > 0)
+			UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
+			recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CFTPSLOGOUT: 0"),2000);
+			if(recvRet==0)
 			{
-				retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
-				if (retptr)
-				{
-					ftp_process++;
-					ftp_ErrCnt = 0;
-				}
+				ftp_process++;
 			}
 			else
 			{
-				ftp_ErrCnt++;
-			}
-			if(UartRecvPtr != NULL)
-			{
-				free(UartRecvPtr);
+				ftp_process++;
 			}
-			UartRecvPtr = NULL;
 			break;
 		}
 		case 5://stop
 		{
 			ATCmdSend = (char *)("AT+CFTPSSTOP\r\n");
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
-			if (ReadLen > 0)
+			UART_Send_Data(UART_LPUART1, ATCmdSend, mstrlen(ATCmdSend), pdMS_TO_TICKS(100));
+			recvRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("CFTPSSTOP: 0"),2000);
+			if(recvRet==0)
 			{
-				retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("OK"));
-				if (retptr)
-				{
-					ftp_process++;
-				}
+				ftp_process++;
 			}
 			else
 			{
-				ftp_ErrCnt++;
-			}
-			if(UartRecvPtr != NULL)
-			{
-				free(UartRecvPtr);
+				ftp_process++;
 			}
-			UartRecvPtr = NULL;
 			break;
 		}
 		case 6://get data from module
@@ -1658,21 +1595,24 @@ void Fota_Ftp(void)
 	        uint32 FlashAddStart = 0;
 	        uint32 appReceviedCRC;
 	        uint16 getDataLenErrCount = 0;
-			sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\",0,6\r\n\r\n",keyFilename);
-			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartData, &ReadLen, pdMS_TO_TICKS(5000));
-			if (ReadLen == (6+45))
+	        memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
+			sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\"\r\n",keyFilename);
+			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(5000));
+			if (ReadLen == (4+45))
 			{
 				retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("+CFTRANTX: DATA"));
 				if (retptr)
 				{
-					fileLen = (*(retptr+22)<<24)|(*(retptr+23)<<16)|(*(retptr+24)<<8)|(*(retptr+25)<<0);
-					appReceviedCRC = (*(retptr+20)<<8)|(*(retptr+21)<<0);
+					fileLen = (*(retptr+21)<<24)|(*(retptr+22)<<16)|(*(retptr+23)<<8)|(*(retptr+24)<<0);
+					appReceviedCRC = (*(retptr+19)<<8)|(*(retptr+20)<<0);
 			        Hal_FlsGetAppVectorTableStartAddr(&FlashAddStart);
-	                Hal_FlsErase(FlashAddStart,fileLen + FLS_INTERNAL_WRITE_SIZE, 50);
+			        Hal_OTAFlashAppInfoInit();
+	                Hal_FlsErase(0,FlashAddStart + fileLen + FLS_INTERNAL_WRITE_SIZE, 100);
 	                Hal_SetAppInfo(fileLen, appReceviedCRC, CONTROLLER_SELF);
 					while(readLenAsk!=0)
 					{
-						sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\",%d,%d\r\n\r\n", filenamePtr,currentAddr, readLenAsk);
+						memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
+						sprintf(ATSendDataBuffer, "AT+CFTRANTX=\"c:/%s\",%d,%d\r\n", filenamePtr,currentAddr, readLenAsk);
 						UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartData, &ReadLen, pdMS_TO_TICKS(5000));
 						sprintf(findDataBuffer, "+CFTRANTX: DATA,%d", readLenAsk);
 						if (ReadLen == (readLenAsk+45))
@@ -1702,20 +1642,35 @@ void Fota_Ftp(void)
 							break;
 						}
 					}
-	                if(getDataLenErrCount<500&&Hal_FlsCheckIsTransferSucceed()==TRUE){
-	                	Fota_update_flag = TRUE;
+	                if(getDataLenErrCount<500&&Hal_FlsCheckIsTransferSucceed()==TRUE)
+	                {
+	                	ftp_process++;
 	                }
 				}
 			}
 			else
 			{
-				ftp_ErrCnt++;
+				ftp_EndFlg = 1;
+			}
+			if(UartRecvPtr != NULL)
+			{
+				free(UartRecvPtr);
 			}
+			UartRecvPtr = NULL;
+			break;
+		}
+		case 7://delete the bin and zl files
+		{
+	        memset(ATSendDataBuffer,0x00,sizeof(ATSendDataBuffer));
+			sprintf(ATSendDataBuffer, "AT+FSDEL=*.*\r\n");
+			UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), &UartRecvPtr, &ReadLen, pdMS_TO_TICKS(5000));
 			if(UartRecvPtr != NULL)
 			{
 				free(UartRecvPtr);
 			}
 			UartRecvPtr = NULL;
+			ftp_process++;
+			Fota_update_flag = TRUE;
 			break;
 		}
 		default:
@@ -1723,4 +1678,8 @@ void Fota_Ftp(void)
 			break;
 		}
 	}
+	if(ftp_process<6)
+	{
+		Fota_error_flag = 1;
+	}
 }

+ 17 - 3
src/Hal_Fls.c

@@ -34,6 +34,12 @@ static tAppDownloadType gs_stAppDownloadInfo = {APP_VECTOR_TABLE_OFFSET,0,0};
         gs_stAppFlashStatus.controllerName = bControolerName;\
     }while(0u)
 
+#define SetAppConter(appCounter)\
+	{\
+		gs_stAppFlashStatus.appCnt = appCounter;\
+		}
+
+
 #define SaveAppResetHandlerAddr(resetHandlerAddr, resetHnadlerAddrLen) \
     do{\
         gs_stAppFlashStatus.appStartAddr = resetHandlerAddr;\
@@ -61,6 +67,8 @@ static tAppDownloadType gs_stAppDownloadInfo = {APP_VECTOR_TABLE_OFFSET,0,0};
 
 static void Hal_FlsSaveFingerPrint(const uint8 *i_pFingerPrint, const uint8 i_FingerPrintLen);
 
+#define InitStAppFlashStatus()  memset(&gs_stAppFlashStatus,0xFF,sizeof(gs_stAppFlashStatus))
+
 
 #define SetFlashStructStatus(bIsAppFlashStructValid) \
     do{\
@@ -157,8 +165,11 @@ void Hal_SetAppInfo(uint32 appLength, uint32 appReceviedCRC,ControllerType contr
 	SetDownloadAppLength(appLength);
 	SetDownloadAppPackCRC(appReceviedCRC);
 	SetAppUpdateControllerName(controllerName);
+	uint8 appCounter = 0;
+	SetAppConter(appCounter);
 	uint32 fingerPrint = 0x5555;
 	Hal_FlsSaveFingerPrint(&fingerPrint, 2); //save finger print
+
 }
 
 
@@ -284,7 +295,7 @@ static uint8 Hal_FlsWriteFlashAppInfo(void)
 
 	if(pAppStatusPtr != NULL_PTR)
 	{
-		 flsRet = Hal_FlsWrite(appInfoStartAddr,(uint8 *)pAppStatusPtr,sizeof(tAppFlashStatus),500);
+		 flsRet = Hal_FlsWrite(appInfoStartAddr,(uint8 *)pAppStatusPtr,(sizeof(tAppFlashStatus)+7)/8*8,500);
 	}
 	if(flsRet == MEMIF_JOB_OK)
 	{
@@ -309,7 +320,7 @@ uint8 Hal_FlsCheckIsTransferSucceed(void)
 	else
 	{
 		SetFlashProgramStatus(FALSE);
-		ret = TRUE;//ÔÝʱÆÁ±ÎCRC
+		ret = FALSE;
 	}
 
 	SetFlashStructStatus(TRUE);
@@ -321,4 +332,7 @@ uint8 Hal_FlsCheckIsTransferSucceed(void)
 	return ret;
 }
 
-
+void Hal_OTAFlashAppInfoInit(void)
+{
+	InitStAppFlashStatus();
+}

+ 2 - 1
src/Hal_Fls.h

@@ -36,7 +36,7 @@ typedef struct
 #define RESET_HANDLER_OFFSET    (4u)     /* From top vector table to reset handle */
 #define RESET_HANDLER_ADDR_LEN  (4u)     /* Pointer length or reset handler length */
 /* Flash finger print length */
-#define FL_FINGER_PRINT_LENGTH  (17u)
+#define FL_FINGER_PRINT_LENGTH  (14u)
 
 /* Program data buffer max length */
 #define MAX_FLASH_DATA_LEN (512u)
@@ -115,6 +115,7 @@ void Hal_SetAppInfo(uint32 appLength, uint32 appReceviedCRC,ControllerType contr
 
 uint8 Hal_FlsCheckIsTransferSucceed(void);
 
+void Hal_OTAFlashAppInfoInit(void);
 extern void CRC_HAL_CreatSoftwareCrc(const uint8_t *i_pucDataBuf, const uint32_t i_ulDataLen, uint32_t *m_pCurCrc);
 
 //extern void CreatSoftwareCrc16(const uint8 *i_pDataBuf, const uint32 i_dataLen, uint32 *m_pCurCrc);

+ 123 - 18
src/hal_adapter.c

@@ -14,25 +14,126 @@ volatile uint32 VarNotification_0 = 0;
 volatile uint32 VarNotification_1 = 0;
 TP_Value_Type ConvertedBuffer[NUM_RESULTS];
 Adc_ValueGroupType ResultBuffer[NUM_RESULTS];
- volatile Uart_StatusType Uart_TransmitStatus[3] = {UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT};
- QueueHandle_t UartRecvQueue[3];
- QueueHandle_t UartSendQueue[3];
- QueueHandle_t UartHalQueueHandle;
- void Uart_Hal_RecvTask(void *pvParameters);
- void Uart_Hal_SendTask(void *pvParameters);
- Std_ReturnType UartStartRecvFunc(uint8 channel);
+volatile Uart_StatusType Uart_TransmitStatus[3] = {UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT};
+QueueHandle_t UartRecvQueue[3];
+QueueHandle_t UartSendQueue[3];
+QueueHandle_t UartHalQueueHandle;
+void Uart_Hal_RecvTask(void *pvParameters);
+void Uart_Hal_SendTask(void *pvParameters);
+Std_ReturnType UartStartRecvFunc(uint8 channel);
 Std_ReturnType ADC_Converter(Adc_ValueGroupType *Buffer, TP_Value_Type *ConvertedValueR);
-static char sprint_buf[1024];
-uint16 myPrintf(const char *fmt, ...)
+void create_ringBuffer(ringbuffer_t *ringBuf, uint8_t *buf, uint32_t buf_len);
+void clear_ringBuffer(ringbuffer_t *ringBuf);
+uint32_t write_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
+uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
+#if UARTPRINTF==1
+	uint8 ringbuffer[1024];
+	ringbuffer_t printfRingBuffer;
+#endif
+sint8 AtcmdDelayRecvFunc(uint8 recvChannel,char *ResultStrPtr,uint16 delayTime)
 {
-    va_list args;
-    int n;
-    va_start(args, fmt);
-    n = vsprintf(sprint_buf, fmt, args);
-    va_end(args);
-    Uart_AsyncSend(UART_LPUART0, sprint_buf, n);
-//    UART_Send_Data(UART_LPUART0, sprint_buf,n, 10);
-    return n;
+	sint8 outValue = -1;
+	uint8 delayCnt = 0;
+	uint8 *UartData = NULL;
+	uint16 ReadLen = 0;
+	uint8 *retptr = NULL;
+	while (delayCnt<(delayTime/1000)&&outValue!=0)
+	{
+		UART_Receive_Data(recvChannel,&UartData, &ReadLen,1000);
+		retptr = (uint8 *)strstr((char *)UartData, ResultStrPtr);
+		if (retptr)
+		{
+			outValue = 0;
+		}
+		else
+		{
+			delayCnt++;
+		}
+		if(UartData != NULL)
+		{
+			free(UartData);
+		}
+		UartData = NULL;
+	}
+	return outValue;
+}
+#if UARTPRINTF==1
+	uint16 myPrintf(const char *fmt, ...)
+	{
+		int n;
+		uint8 databuffer[512]={0};
+		va_list args;
+		va_start(args, fmt);
+		n = vsprintf((char *)databuffer, fmt, args);
+		va_end(args);
+	    if( (printfRingBuffer.bw + n) <= printfRingBuffer.length  )
+	    {
+	        memcpy(printfRingBuffer.source + printfRingBuffer.bw, databuffer, n);
+	        UART_Send_Data(UART_LPUART0, printfRingBuffer.source + printfRingBuffer.bw, n, 10);
+	        printfRingBuffer.bw = printfRingBuffer.bw + n;
+	    }
+	    else
+	    {
+	    	printfRingBuffer.bw = 0;
+	    	memcpy(printfRingBuffer.source + printfRingBuffer.bw, databuffer, n);
+	    	UART_Send_Data(UART_LPUART0, printfRingBuffer.source + printfRingBuffer.bw, n, 10);
+	    }
+		return n;
+	}
+#endif
+void create_ringBuffer(ringbuffer_t *ringBuf, uint8_t *buf, uint32_t buf_len)
+{
+    ringBuf->br         = 0;
+    ringBuf->bw         = 0;
+    ringBuf->btoRead    = 0;
+    ringBuf->source     = buf;
+    ringBuf->length     = buf_len;
+}
+void clear_ringBuffer(ringbuffer_t *ringBuf)
+{
+    ringBuf->br         = 0;
+    ringBuf->bw         = 0;
+    ringBuf->btoRead    = 0;
+}
+uint32_t write_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf)
+{
+    uint32_t len            = 0;
+    uint32_t ringBuf_bw     = ringBuf->bw;
+    uint32_t ringBuf_len    = ringBuf->length;
+    uint8_t *ringBuf_source = ringBuf->source;
+    if( (ringBuf_bw + size) <= ringBuf_len  )
+    {
+        memcpy(ringBuf_source + ringBuf_bw, buffer, size);
+    }
+    else
+    {
+        len = ringBuf_len - ringBuf_bw;
+        memcpy(ringBuf_source + ringBuf_bw, buffer, len);
+        memcpy(ringBuf_source, buffer + ringBuf_bw, size - len);
+    }
+    ringBuf->bw = (ringBuf->bw + size) % ringBuf_len;
+    ringBuf->btoRead += size;
+    return size;
+}
+uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf)
+{
+    uint32_t len            = 0;
+    uint32_t ringBuf_br     = ringBuf->br;
+    uint32_t ringBuf_len    = ringBuf->length;
+    uint8_t *ringBuf_source = ringBuf->source;
+    if( (ringBuf_br + size ) <= ringBuf_len )
+    {
+        memcpy(buffer, ringBuf_source + ringBuf_br, size);
+    }
+    else
+    {
+        len = ringBuf_len - ringBuf_br;
+        memcpy(buffer, ringBuf_source + ringBuf_br, len);
+        memcpy(buffer + len, ringBuf_source, size - len);
+    }
+    ringBuf->br = (ringBuf->br + size) % ringBuf_len;
+    ringBuf->btoRead -= size;
+    return size;
 }
 
 Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, const uint8 *txBuffer, uint32 sendLength, uint8 **rxBuffer, uint16 *rxlen, uint32 T_timeout)
@@ -94,6 +195,10 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 	{
 		retVal = E_OK;
 	}
+	else
+	{
+		retVal = E_NOT_OK;
+	}
 	return retVal;
 }
  void UartInit(void)
@@ -101,7 +206,7 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 	 UartRecvQueue[0] = xQueueCreate(6, sizeof(UartMsg_t));
 	 UartRecvQueue[1] = xQueueCreate(6, sizeof(UartMsg_t));
 	 UartRecvQueue[2] = xQueueCreate(3, sizeof(UartMsg_t));
-	 UartSendQueue[0] = xQueueCreate(1, sizeof(UartMsg_t));
+	 UartSendQueue[0] = xQueueCreate(3, sizeof(UartMsg_t));
 	 UartSendQueue[1] = xQueueCreate(1, sizeof(UartMsg_t));
 	 UartSendQueue[2] = xQueueCreate(1, sizeof(UartMsg_t));
 	 UartHalQueueHandle = xQueueCreate(9, sizeof(UartHalMsg_t));

+ 26 - 14
src/hal_adapter.h

@@ -50,6 +50,7 @@ typedef signed char INT8;
 typedef signed short INT16;
 typedef signed long INT32;
 
+#define UARTPRINTF 1
 #define CAN0 0
 #define CAN1 1
 #ifndef min
@@ -75,7 +76,13 @@ typedef signed long INT32;
 #define BUFFER_SIZE 1024
 #define DMA_SIZE 128
 
-
+typedef struct {
+    uint8_t *source;
+    uint32_t br;
+    uint32_t bw;
+    uint32_t btoRead;
+    uint32_t length;
+}ringbuffer_t;
 
  typedef struct
  {
@@ -111,15 +118,6 @@ typedef signed long INT32;
  }ADC_TP_Channel_Type;
 
 typedef uint32 TP_Value_Type;
-uint16 myPrintf(const char *fmt, ...);
-Std_ReturnType ADC_ReadValue(void);
-// extern uint8 GpsBufferGet[GPSBUFFER_SIZE];
-Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, const uint8 *txBuffer, uint32 sendLength, uint8 **rxBuffer, uint16 *rxlen, uint32 T_timeout);
-Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32 sendLength, uint32 T_timeout);
-Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 **rxBuffer, uint16 *rxlen, sint32 T_timeout);
-void UART_Callback(uint32 hwInstance, Lpuart_Uart_Ip_EventType event);
-void UartInit(void);
-void SystemSoftwareReset(void);
 /*CAN*/
 typedef enum
 {
@@ -147,8 +145,6 @@ typedef struct
     uint8 length;
     uint8 data[8];
 } Can_Msg_Type_Data;
-extern Std_ReturnType CanIf_SendMessage(uint8 ControllerId, Can_Msg_Type CanMsg);
-
 /*EEP*/
 
 typedef enum
@@ -229,11 +225,27 @@ typedef enum
 #define TEST_EEP_EEPROM_CMD_ERASE_SECTOR (0x09UL)
 
 #define EEPROM_CMD_PROGRAM_PARTITION (0x80UL)
-
+extern Std_ReturnType CanIf_SendMessage(uint8 ControllerId, Can_Msg_Type CanMsg);
 void Eep_DepartParitition(TestEep_Eeprom_FlexNvmPartitionType T_EEP_SIZE);
 Std_ReturnType HAL_EEP_Erase(uint32 eepEraseStartAddr, uint32 eepEraseSize);
 Std_ReturnType HAL_EEP_Read(uint32 eepReadStartAddr, uint8 *pDataBuffer, uint32 dataSize);
 Std_ReturnType HAL_EEP_Write(uint32 eepWriteStartAddr, uint8 *pDataNeedtoWrite, uint32 dataSize);
 Std_ReturnType HAL_EEP_Compare(uint32 eepCompareStartAddr, uint8 *pDataNeedtoCompare, uint32 dataSize);
-
+Std_ReturnType ADC_ReadValue(void);
+sint8 AtcmdDelayRecvFunc(uint8 recvChannel,char *ResultStrPtr,uint16 delayTime);
+Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, const uint8 *txBuffer, uint32 sendLength, uint8 **rxBuffer, uint16 *rxlen, uint32 T_timeout);
+Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32 sendLength, uint32 T_timeout);
+Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 **rxBuffer, uint16 *rxlen, sint32 T_timeout);
+void UART_Callback(uint32 hwInstance, Lpuart_Uart_Ip_EventType event);
+void UartInit(void);
+void SystemSoftwareReset(void);
+void create_ringBuffer(ringbuffer_t *ringBuf, uint8_t *buf, uint32_t buf_len);
+void clear_ringBuffer(ringbuffer_t *ringBuf);
+uint32_t write_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
+uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
+#if UARTPRINTF==1
+	uint16 myPrintf(const char *fmt, ...);
+	extern uint8 ringbuffer[1024];
+	extern ringbuffer_t printfRingBuffer;
+#endif
 #endif /* HAL_ADAPTER_H_ */

+ 1 - 1
src/main.c

@@ -170,7 +170,7 @@ int main(void)
 
 	UartInit();
 	xTaskCreate(MainTask, (const char *const)"MainTask", 512, (void *)0, main_TASK_PRIORITY + 3, NULL);
-	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, NULL);
+//	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, NULL);
 	xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, NULL);
 	xTaskCreate(GpsTask, (const char *const)"GpsTask", 512, (void *)0, main_TASK_PRIORITY + 1, NULL);
 	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, NULL);