5 Commits 5afbc9c664 ... c908159934

Author SHA1 Message Date
  LAPTOP-KB7QFH2U\ChenJie-PC c908159934 丰都软件版本发布V0.1.0.4 1 year ago
  LAPTOP-KB7QFH2U\ChenJie-PC b4c92261dc V0.1.0.2 新增LED指示 1 year ago
  LAPTOP-KB7QFH2U\ChenJie-PC e85783de53 电压温度 接收发送优化 1 year ago
  LAPTOP-KB7QFH2U\ChenJie-PC 56f3438146 发送代码更改测试 1 year ago
  LAPTOP-KB7QFH2U\ChenJie-PC e34746f8c3 0.0.0.4 GPS变频测试程序 1 year ago

+ 2 - 2
.cproject

@@ -31,7 +31,7 @@
 							<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">
 								<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1168627068" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.size" valueType="enumerated"/>
-								<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.option.debugging.level.1120041103" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+								<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.option.debugging.level.1120041103" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.functionsections.1916093778" name="Function sections (-ffunction-sections)" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.functionsections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.datasections.499071697" name="Data sections (-fdata-sections)" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.datasections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.debugging.format.155687014" name="Debug format" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.debugging.format" useByScannerDiscovery="true"/>
@@ -148,7 +148,7 @@
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.archiver.50914677" name="Standard S32DS Archiver" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.archiver"/>
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.339533218" name="Standard S32DS Assembler" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler">
 								<option id="com.freescale.s32ds.cross.gnu.tool.assembler.usepreprocessor.608521688" name="Use preprocessor" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
-								<option defaultValue="gnu.c.debugging.level.max" id="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level.935781758" name="Debug Level" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/>
+								<option defaultValue="gnu.c.debugging.level.max" id="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level.935781758" name="Debug Level" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
 								<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.libraries.2115819142" name="Libraries support" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.libraries" useByScannerDiscovery="false" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.libraries.newlib_nano_noio" valueType="enumerated"/>
 								<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.sysroot.1519150514" name="Sysroot" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.sysroot" useByScannerDiscovery="false" value="--sysroot=&quot;${S32DS_ARM32_NEWLIB_DIR}&quot;" valueType="string"/>
 								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.763521555" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" useByScannerDiscovery="false" valueType="includePath">

+ 4 - 4
.settings/language.settings.xml

@@ -5,7 +5,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-875669050657868906" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>
@@ -16,7 +16,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-875669050657868906" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>
@@ -27,7 +27,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-875669050657868906" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>
@@ -38,7 +38,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-875669050657868906" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>

+ 1 - 1
FreeRTOS/Source/include/FreeRTOSConfig.h

@@ -29,7 +29,7 @@
 #ifndef FREERTOS_CONFIG_H
 #define FREERTOS_CONFIG_H
 //#define SEGGER_SYSTEMVIEW //选择SYSTEM查看
-//#define SEGGER_RTT_PRINTF //选择RTT打印
+//#define SEGGER_RTT_PRINTF 	//选择RTT打印
 #ifdef SEGGER_SYSTEMVIEW
 	#include "SEGGER_SYSVIEW_FreeRTOS.h"
 #endif

+ 5 - 4
code/app/AppGlobalVar.c

@@ -35,7 +35,7 @@ uint16 WebSitePort = 8812;
 #endif
 
 //*全局变量*//
-const uint32 AppSwVersion = 0x00010003;
+const uint32 AppSwVersion = 0x00010004;
 const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x0101;
 const uint32 BlSwVersion = 0x00000001;
@@ -65,7 +65,7 @@ QueueHandle_t CanRecvQueueHandle2;
 TaskHandle_t Uart_Hal_RecvTask_Handle, Uart_Hal_SendTask_Handle, MainTask_Handle, Uart0Task_Handle, CanTask_Handle, GpsTask_Handle, Uart_4G_Task_Handle;
 SemaphoreHandle_t sleep_mutex = NULL;
 
-bool TcpSysReboot = 1;
+bool TcpSysReboot = 0;
 char ImeiNum[15] = {0};
 char IccidNum[20] = {0};
 uint8 CSQValue = 0;
@@ -73,6 +73,7 @@ sint8 SocketId = -1;
 sint8 RegChkRet = 0;
 char WebSiteIp[20] = {0};
 uint8 TcpWorkState = 0;
+uint16 DeviceSpeed = 0;
 
 real_T returnFreq[3][5];
 real_T returnP[3][5];
@@ -89,7 +90,6 @@ uint32 ODO = 0;
 uint8 dcdcWorkStatus = 0;
 uint8 numOfChrgableSubsys = 0;
 uint8 chrgableSubsysCode = 0;
-
 uint16 vcuDCVol = 0;
 // EBC相关
 uint8 ebcStatus = 0;
@@ -137,6 +137,7 @@ UINT8 BcuRxFlag[28];
 /************************************************************
  *BCU->4G解码变量存放区
  ************************************************************/
+UINT8 BMS_CellRecvCounter=0;						//每个电压收取标志位
 UINT8 BMS_ReqVIN = 0x00;						// 是否请求VIN码,0:预留;1:请求VIN;2:不请求VIN;3:无效;,Re-1,Off-0,
 UINT8 BMS_ReqHVOff = 0x00;						// 是否请求下高压,0:预留;1:请求下高压;2:不请求下高压;3:无效;,Re-1,Off-0,
 UINT8 BMS_ProtocolEditionH = 0x00;				// 通讯协议版本高位(例 : 版本为3 .1, 则此处发3),	, Re - 1, Off - 0,
@@ -251,7 +252,7 @@ UINT8 BMS_CellTemp[BMS_TEMP_MAX_NUM] = {0x00};	// 当前CSC下的第N个探针
 UINT8 BMS_Checksum = 0x00;						// 电池编码信息1的CheckSum,Byte0=Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 XOR Byte7,Re-1,Off-0,
 UINT8 BMS_PackComp = 0x00;						// 电池厂家,1:"CATL" 2:"Li Shen" 3:"MGL" 4:"SAMSUN" 5:"LG",Re-1,Off-0,
 UINT8 BMS_BattCodeLeng = 0x00;					// 电池编码长度,0:Do not transmit this Code,Re-1,Off-0,
-UINT8 BMS_SN[27] = {0x00};						// 电池编码(SN)字符1(ASCII),,Re-1,Off-0,
+UINT8 BMS_SN[27] = {0};							// 电池编码(SN)字符1(ASCII),,Re-1,Off-0,
 UINT8 BMS_BattType = 0x00;						// 电池类型,1:铅酸电池; 2:镍氢电池; 3:磷酸铁锂电池; 4:锰酸锂电池; 5:钴酸锂电池; 6:三元材料电池; 7:聚合物锂离子电池; 8:钛酸锂电池; 9:超级电容; 10~13:保留; 14:燃料电池;15:保留,Re-1,Off-0,
 UINT8 BMS_CoolType = 0x00;						// 电池冷却方式,0:其他冷却方式1 : 自然冷却 2 : 风扇冷却 3 : 水冷却, Re - 1, Off - 0,
 UINT8 BMS_CSC_Total = 0x00;						// 电池系统中CSC总的数目,,Re-1,Off-0,

+ 3 - 0
code/app/AppGlobalVar.h

@@ -42,6 +42,8 @@ extern uint16 ErrorArray[10];
 extern uint8 Fota_update_flag;
 extern boolean Fota_Process_Going;
 extern uint8 Fota_error_flag;
+extern uint16 DeviceSpeed;
+
 typedef struct
 {
     uint8 RealLen;
@@ -116,6 +118,7 @@ extern BOOL BcuRxShortError[28];
 extern BOOL BcuRxLongError[28];
 extern UINT8 BcuRxErrorCounter[28];
 extern UINT8 BcuRxFlag[28];
+extern UINT8 BMS_CellRecvCounter;
 extern UINT8 BMS_ReqVIN;
 extern UINT8 BMS_ReqHVOff;
 extern UINT8 BMS_ProtocolEditionH;

+ 62 - 14
code/app/AppTaskCan.c

@@ -45,10 +45,17 @@ void CanTask(void *pvParameters)
 				}
 				else
 				{
-					BcuDecodeFunction(CanRxMsg.id, CanRxMsg.data); // can协议解析
+					if(CanRxMsg.id==0x1C00EDEA)
+					{
+						UDSAnsFunc(CanRxMsg.data);
+					}
+					else
+					{
+						BcuDecodeFunction(CanRxMsg.id, CanRxMsg.data); // can协议解析
+					}
 				}
 			}
-			if (timerCANIdle > 20000)
+			if (timerCANIdle > 10*1000)
 			{
 				timerCANIdle = 0;
 				xSemaphoreGive(sleep_mutex);
@@ -246,6 +253,7 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 		{
 			break;
 		}
+		BMS_CellRecvCounter = (BMS_CellRecvCounter + 1) >= 128 ? 128 : (BMS_CellRecvCounter + 1);
 		for (UINT8 i = 0; i < 3; i++)
 		{
 			BMS_CellVolt[(BMS_CellVoltFramNum - 1) * 3 + i] = (UINT16)(((*(UINT8 *)(rawData + i * 2 + 2)) | (*(UINT8 *)(rawData + i * 2 + 3) << 8)) & 0xFFFF);
@@ -255,19 +263,26 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 	case 0x18C2D0F3:
 		BMS_CellTempFramNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
 		BMS_CSC_Code = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		if (BMS_CellTempFramNum == 0 || BMS_CellTempFramNum > 12)
+		if (BMS_CSC_Code == 0 || BMS_CSC_Code > 8)
 		{
 			break;
 		}
-		for (UINT8 i = 0; i < 6; i++)
+		uint8 tempCount = 0,offvalue = 0;
+		if(BMS_CellTempFramNum%2==0)
+		{
+			tempCount = 2;
+			offvalue = 6;
+		}
+		else
+		{
+			tempCount = 6;
+			offvalue = 0;
+		}
+		for(uint8 i=0; i<tempCount; i++)
 		{
-			if (((BMS_CellTempFramNum - 1) * 6 + i) < sizeof(BMS_CellTemp))
+			if (((BMS_CSC_Code - 1) * 8 + i + offvalue) < sizeof(BMS_CellTemp) && ((UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF) >= 10))
 			{
-				BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] = (UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF);
-				if (BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] <= (0xFF - 10) && BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] >= 10)
-				{
-					BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] = BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] - 10; // the tcp offset is -40, while the can message offset is -50
-				}
+				BMS_CellTemp[(BMS_CSC_Code - 1) * 8 + i + offvalue] = (UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF)- 10;
 			}
 		}
 		BcuRxFlag[14] = 0x01;
@@ -412,9 +427,23 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 		TMS_FaultLevel = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
 		BcuRxFlag[27] = 0x01;
 		break;
-	case 0x1C00EDEA:
-		UDSAnsFunc(rawData);
+	case 0x18E1F3D0:
+	{
+		uint8 VIN_FrameNo;
+		VIN_FrameNo = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
+		if (VIN_FrameNo - 1  > 2)
+		{
+			break;
+		}
+		for (UINT8 i = 0; i < 7; i++)
+		{
+			if (((VIN_FrameNo-1) * 7 + i) < sizeof(VIN))
+			{
+				VIN[(VIN_FrameNo-1) * 7 + i] = (UINT8)(((*(UINT8 *)(rawData + 1 + i))) & 0xFF);
+			}
+		}
 		break;
+	}
 	default:
 		break;
 	}
@@ -624,12 +653,12 @@ static void UDSAnsFunc(uint8 *rawData)
 				if (Data[3] < 0x04)
 				{
 					memcpy(&AppConfigInfo.deviceSn[Data[3] * 4], &Data[4], 4);
-					UdsAns(true, UdsService, UdsSubService, 0x00, &Data[3], 1);
+					UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 4);
 				}
 				else if (Data[3] == 0x04)
 				{
 					memcpy(&AppConfigInfo.deviceSn[Data[3] * 4], &Data[4], 1);
-					UdsAns(true, UdsService, UdsSubService, 0x00, &Data[3], 1);
+					UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 4);
 				}
 				if (deviceSnRecvFlg == 0x1F)
 				{
@@ -639,6 +668,24 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
+			case 0x02://出厂检测联网测试
+			{
+				if(Data[4]==0x01)
+				{
+					AppConfigInfo.eolFlg = true;
+					AppConfigInfo.appSaveFlg = false;
+				}
+				else
+				{
+					AppConfigInfo.eolFlg = false;
+					AppConfigInfo.appSaveFlg = true;
+				}
+				UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 1);
+				break;
+			}
+			default:
+				UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
+				break;
 			}
 		}
 		else
@@ -1072,6 +1119,7 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 		break;
 	case 0x18C1D0F3:
 		BMS_CellVoltFramNum = 0xFF;
+		BMS_CellRecvCounter = 0;
 		for (UINT16 i = 0; i < sizeof(BMS_CellVolt) / 2; i++)
 		{
 			BMS_CellVolt[i] = 0xFFFF;

+ 38 - 5
code/app/AppTaskGps.c

@@ -14,6 +14,8 @@ uint32 location_handle(char *in1);
 void GpsDataDecode(uint8 *msg);
 uint8 GpsRecvPtr[1024];
 uint32 timerCounterGetdata = 0;
+uint32 ledCounterTmp = 0;
+uint32 triaxiCounterTmp = 0;
 static void vtimerCallback(TimerHandle_t pxTimer)
 {
 	uint32 ulTimerID;
@@ -44,8 +46,32 @@ void GpsTask(void *pvParameters)
 		{
 			GpsDataDecode(GpsRecvPtr);
 		}
-		if (timerCounterGetdata % 10 == 0)
+		/*LED控制*/
+		if((timerCounterGetdata - ledCounterTmp) > 200)
 		{
+			Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
+			ledCounterTmp = timerCounterGetdata;
+			if(SocketId>=0)//网络连接成功
+			{
+				Dio_FlipChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2);
+			}
+			else
+			{
+				Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2,STD_OFF);
+			}
+			if(DeviceSpeed>0)//GPS定位成功
+			{
+				Dio_FlipChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3);
+			}
+			else
+			{
+				Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3,STD_OFF);
+			}
+		}
+		/*三轴计算*/
+		if ((timerCounterGetdata - triaxiCounterTmp)> 10)
+		{
+			triaxiCounterTmp = timerCounterGetdata;
 			SL_SC7A20_Read_XYZ_Data(xyzData);
 			S0[fftIdx] = (real_T)xyzData[0];
 			S1[fftIdx] = (real_T)xyzData[1];
@@ -95,8 +121,7 @@ void GpsDataDecode(uint8 *msg)
 			strdel(databuffer[5], '.');
 			strdel(databuffer[7], '.');
 			speedtemp = atol(databuffer[7]) * 1852 / 1e5; //节换算单位,1节=1.852km每小时
-			GpsInfoData.speed[0] = (speedtemp >> 8) & 0xFF;
-			GpsInfoData.speed[1] = speedtemp & 0xFF;
+			DeviceSpeed = speedtemp+1;
 			latitude = location_handle(databuffer[3]);
 			GpsInfoData.latitude[0] = latitude >> 24;
 			GpsInfoData.latitude[1] = latitude >> 16;
@@ -112,11 +137,15 @@ void GpsDataDecode(uint8 *msg)
 				direction = atol(databuffer[8]);
 				GpsInfoData.direction[0] = direction >> 8;
 				GpsInfoData.direction[1] = direction;
+				GpsInfoData.speed[0] = (speedtemp >> 8) & 0xFF;
+				GpsInfoData.speed[1] = speedtemp & 0xFF;
 			}
 			else
 			{
-				GpsInfoData.direction[0] = 0xff;
-				GpsInfoData.direction[1] = 0xff;
+				GpsInfoData.direction[0] = 0;
+				GpsInfoData.direction[1] = 0;
+				GpsInfoData.speed[0] = 0;
+				GpsInfoData.speed[1] = 0;
 			}
 			if (speedtemp >= 50 && speedtemp <= 1500)
 			{
@@ -128,6 +157,10 @@ void GpsDataDecode(uint8 *msg)
 				}
 			}//累计里程的累加
 		}
+		else
+		{
+			DeviceSpeed = 0;
+		}
 		GpsInfoData.AccMileage[0] = AppConfigInfo.AppDataInfo.AccMileage >> 24;
 		GpsInfoData.AccMileage[1] = AppConfigInfo.AppDataInfo.AccMileage >> 16;
 		GpsInfoData.AccMileage[2] = AppConfigInfo.AppDataInfo.AccMileage >> 8;

+ 2 - 0
code/app/AppTaskMain.c

@@ -48,7 +48,9 @@ void MainTask(void *pvParameters)
 			HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
 			SystemSoftwareReset();
 		}
+#ifndef SEGGER_RTT_PRINTF
 		MCUEnterSleep();
+#endif
 	}
 }
 static void vTimerCallback(TimerHandle_t pxTimer)

+ 190 - 119
code/app/AppTaskUart1.c

@@ -25,7 +25,6 @@ const ATCmdFunc Atcmdfunc[] = {
 	{AT_CSQ, "AT+CSQ\r\n", at_callbackFunc},
 	{AT_NETOPEN, "AT+NETOPEN\r\n", at_callbackFunc},
 	{AT_CGIP, "AT+CDNSGIP=", at_callbackFunc},
-	//{AT_CONNECT, "AT+CIPOPEN=0,\"TCP\",\"120.26.68.165\",14319\r\n", at_callbackFunc},
 	{AT_CONNECT, "AT+CIPOPEN=", at_callbackFunc},
 	{AT_CONNECTCHK, "AT+CIPOPEN?\r\n", at_callbackFunc},
 	{AT_SEND, "AT+CIPSEND=", at_callbackFunc},
@@ -35,22 +34,28 @@ const ATCmdFunc Atcmdfunc[] = {
 
 static process_Tcp gProcess_Tcp_Task = PROCESS_TCP_INIT;
 #define PROC_TCP_STATE_SWITCH(a) (gProcess_Tcp_Task = a)
-void InitFunc(void);
+sint8 InitFunc(void);
 sint8 TcpConnectFunc(sint8 *ConnectId);
-sint8 TcpDataSendFunc(sint8 ConnectId);
+sint8 TcpDataSendFunc(sint8 ConnectId,uint8 DataSendIdxIn);
 sint8 TcpRegisterChkFunc(void);
-void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen);
-void GetUtc8Time(UTC8TimeType *UTC8TimeTcp);
+void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen);
+void GetUtc8Time(UTC8TimeType *UTC8TimeTcpPtr);
+void TimeUpdate(UTC8TimeType *UTC8TimeTcpPtr);
+static void TcpDataSendFeqHandFunc(uint8 *DataIdx);
 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(uint8 *dataPtrIn);
 void tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr);
 static void vTimer1000msCallback(TimerHandle_t pxTimer);
-bool SendTimerFlg = false;
-static uint32 TcpSendTimeCounter = 0;
+
+volatile TcpFeq_type TcpDataFeq={
+		{0x01,60*60*2,0},{0x86,60*60,0},{0x91,10,0},
+		{0x82,10,0},{0x90,60,0},{0x92,60,0},{0x8C,10,0}};//默认发送频率
+static UTC8TimeType UTC8TimeTcp;//全局真实时间存储
 extern boolean waitForSleepFlag;
 boolean Uart_4G_Task_Sleep_FLag = false;
+TimerHandle_t monitorTimer1000ms;
 void Uart_4G_Task(void *pvParameters)
 {
 	(void)pvParameters;
@@ -58,17 +63,6 @@ void Uart_4G_Task(void *pvParameters)
 	uint8 UartRecvPtr[512];
 	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(500));
-								  //	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
-								  //	vTaskDelay(pdMS_TO_TICKS(50));
-								  //	AtcmdDelayRecvFunc(UART_LPUART1,(char *)("SMS DONE"),30000);
-								  //	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
-								  //	_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
-								  //	InitFunc(); // 4G模块初始化,注:AT同步不通过,没有进行次数判定及跳转
-	TimerHandle_t monitorTimer1000ms;
 	monitorTimer1000ms = xTimerCreate("monitor1000ms", 1000, pdTRUE, (void *)0, vTimer1000msCallback);
 	xTimerStart(monitorTimer1000ms, 0);
 	for (;;)
@@ -82,23 +76,22 @@ void Uart_4G_Task(void *pvParameters)
 		{
 		case PROCESS_TCP_INIT:
 		{
-			Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
-			vTaskDelay(pdMS_TO_TICKS(500));
-
-			Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
-			vTaskDelay(pdMS_TO_TICKS(50));
-			Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
-
-			AtcmdDelayRecvFunc(UART_LPUART1, (char *)("SMS DONE"), 30000);
-			_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
-			InitFunc();
-			TcpSendTimeCounter = 0;
-			PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
+			sint8 InitFlg = -1;
+			InitFlg  = InitFunc();
+			if(InitFlg==0)
+			{
+				PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
+			}
+			else
+			{
+				TcpSysReboot = 1;
+				PROC_TCP_STATE_SWITCH(PROCESS_TCP_ERROR);
+			}
 			break;
 		}
 		case PROCESS_TCP_IDLE: // 空闲状态
 		{
-			UART_Receive_Data(UART_LPUART1, UartRecvPtr, &pReadLen, 100); // 100ms检测
+			Tcp_Receive_Data (UartRecvPtr, &pReadLen, 100); // 100ms检测
 			if (SocketId < 0)
 			{
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_REGCHK);
@@ -108,12 +101,11 @@ void Uart_4G_Task(void *pvParameters)
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_RECV);
 				RecvTimerDelay = TimerCounter;
 			}
-			else if (AppConfigInfo.eolFlg == 1 && TcpWorkState == 0 && SendTimerFlg == true)
+			else if (AppConfigInfo.eolFlg == 1 && TcpWorkState == 0)
 			{
-				SendTimerFlg = false;
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_SEND);
 			}
-			if ((TimerCounter - RecvTimerDelay) >= 30000 && TcpWorkState == 1) // 10s内没有命令下发,进行正常发送任务
+			if ((TimerCounter - RecvTimerDelay) >= 30000 && TcpWorkState == 1) // 30s内没有命令下发,进行正常发送任务
 			{
 				TcpWorkState = 0;
 			}
@@ -141,7 +133,6 @@ void Uart_4G_Task(void *pvParameters)
 				if (ConnectRet > 0)
 				{
 					PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
-					TcpSendTimeCounter = 0;
 				}
 				else
 				{
@@ -153,16 +144,22 @@ void Uart_4G_Task(void *pvParameters)
 		case PROCESS_TCP_SEND: // 网络数据发送
 		{
 			sint8 SendRet = -1;
-			SendRet = TcpDataSendFunc(SocketId);
-			if (SendRet == 0)
-			{
-				PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
-				tcpErrorCounter = 0;
-			}
-			else
+			uint8 DataSendIdx = 0;
+			//发送判定
+			TcpDataSendFeqHandFunc(&DataSendIdx);
+			if(DataSendIdx!=0)//有数据处理
 			{
-				SocketId = -1;
-				PROC_TCP_STATE_SWITCH(PROCESS_TCP_ERROR);
+				SendRet = TcpDataSendFunc(SocketId,DataSendIdx);//发送函数
+				if (SendRet == 0)
+				{
+					PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
+					tcpErrorCounter = 0;
+				}
+				else
+				{
+					SocketId = -1;
+					PROC_TCP_STATE_SWITCH(PROCESS_TCP_ERROR);
+				}
 			}
 			break;
 		}
@@ -181,7 +178,6 @@ void Uart_4G_Task(void *pvParameters)
 		}
 		case PROCESS_TCP_SLEEP: // 网络休眠状态
 		{
-
 			while (waitForSleepFlag == true)
 			{
 				Uart_4G_Task_Sleep_FLag = true;
@@ -194,7 +190,7 @@ void Uart_4G_Task(void *pvParameters)
 		{
 			vTaskDelay(pdMS_TO_TICKS(1000));
 			tcpErrorCounter++;
-			if (tcpErrorCounter > 60 && TcpSysReboot == 1) // 无法驻网或者联网
+			if (tcpErrorCounter > 60 || TcpSysReboot == 1) // 无法驻网或者联网
 			{
 				Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
 				vTaskDelay(pdMS_TO_TICKS(2500));
@@ -207,7 +203,6 @@ void Uart_4G_Task(void *pvParameters)
 			{
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
 			}
-
 			break;
 		}
 		}
@@ -217,23 +212,53 @@ static void vTimer1000msCallback(TimerHandle_t pxTimer)
 {
 	uint32 ulTimerID;
 	ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
+	sint16 *TcpDataFeqPtr =NULL;
+	TcpDataFeqPtr = (sint16 *)&TcpDataFeq;
 	if (ulTimerID == 0)
 	{
-		SendTimerFlg = true;
-		TcpSendTimeCounter++;
+		if(SocketId>=0)
+		{
+			for(uint8 i=2;i<sizeof(TcpDataFeq)/sizeof(sint16);i=i+3)
+			{
+				*(TcpDataFeqPtr+i) = (*(TcpDataFeqPtr+i)-1)<0 ? 0 : (*(TcpDataFeqPtr+i)-1);
+			}
+		}
+		TimeUpdate(&UTC8TimeTcp);
 	}
 }
-sint8 TcpDataSendFunc(sint8 ConnectId)
+static void TcpDataSendFeqHandFunc(uint8* DataIdx)
+{
+	sint16 *TcpDataFeqPtr =NULL;
+	TcpDataFeqPtr = (sint16 *)&TcpDataFeq;
+	for(uint8 i=2;i<sizeof(TcpDataFeq)/sizeof(sint16);i=i+3)
+	{
+		if(*(TcpDataFeqPtr+i)==0)
+		{
+			*DataIdx = *(TcpDataFeqPtr+i-2);
+			*(TcpDataFeqPtr+i) = *(TcpDataFeqPtr+i-1);
+			break;
+		}
+		else
+		{
+			*DataIdx = 0;
+		}
+	}
+	return;
+}
+sint8 TcpDataSendFunc(sint8 ConnectId,uint8 DataSendIdxIn)
 {
 	sint8 outValue = -1;
 	uint32 pSendDataAddr = 0;
 	uint16 DataSendLen = 0;
-	TcpDataEncode(&pSendDataAddr, &DataSendLen); // 数据组包,malloc申请在里面,pSendData指向申请的地址
-	if (DataSendLen == 0)
+	TcpDataEncode(DataSendIdxIn,&pSendDataAddr, &DataSendLen); // 数据组包,malloc申请在里面,pSendData指向申请的地址
+	if(DataSendLen==0)//长度为0 不调用发送数据函数
+	{
+		outValue = 0;
+	}
+	else
 	{
-		return 0; // 暂时无数据可以发
+		outValue = tcpipConnectionSend(ConnectId, (uint8 *)pSendDataAddr, DataSendLen); // 发送函数
 	}
-	outValue = tcpipConnectionSend(ConnectId, (uint8 *)pSendDataAddr, DataSendLen); // 发送函数
 	if (pSendDataAddr != 0)
 	{
 		vPortFree((uint8 *)(pSendDataAddr));
@@ -257,8 +282,8 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
 		ret = UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdSend, AtCmdSendTotalLen, UartRecvPtr, &ReadLen, 1000);
 		if (((ret == 0) && (ReadLen > 0) && ((uint8 *)strstr((char *)UartRecvPtr, (char *)(">")))) || 1) // 此IF条件默认通过
 		{
-			UART_Send_Data(UART_LPUART1, (uint8 *)SendDataPtr, SendDataLen, 1000);
-			sint8 ret = AtcmdDelayRecvFunc(UART_LPUART1, (char *)("+CIPSEND"), 2000);
+			UART_Send_Data(UART_LPUART1, (uint8 *)SendDataPtr, SendDataLen, 100);
+			sint8 ret = AtcmdDelayRecvFunc(UART_LPUART1, (char *)("+CIPSEND"), 3000);
 			if (ret == 0)
 			{
 				outValue = 0;
@@ -453,7 +478,7 @@ sint8 TcpRegisterChkFunc(void)
 		}
 	}
 }
-void InitFunc(void)
+sint8 InitFunc(void)
 {
 	// 4G模块初始化
 	uint8 _4G_InitStep = 0;
@@ -464,6 +489,14 @@ void InitFunc(void)
 	uint8 UartRecvPtr[50];
 	uint16 ATerrorCnt = 0;
 	uint8 *retptr = NULL;
+	Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
+	Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
+	vTaskDelay(pdMS_TO_TICKS(500));
+	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
+	vTaskDelay(pdMS_TO_TICKS(50));
+	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
+	AtcmdDelayRecvFunc(UART_LPUART1, (char *)("SMS DONE"), 10000);
+	_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
 	while (1)
 	{
 		switch (_4G_InitStep)
@@ -482,7 +515,7 @@ void InitFunc(void)
 				ATerrorCnt++;
 				if (ATerrorCnt > 60 * 5)
 				{
-					SystemSoftwareReset();
+					return -1;
 				}
 			}
 			break;
@@ -586,8 +619,7 @@ void InitFunc(void)
 		}
 		default:
 		{
-			return;
-			break;
+			return 0;
 		}
 		}
 	}
@@ -751,48 +783,14 @@ sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pRead
 	}
 	return OutValue;
 }
-void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
+void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 {
-	static UTC8TimeType UTC8TimeTcp;
 	uint8 *SendBuffer = NULL;
-	uint8 DataIdx = 0;
-	if ((TcpSendTimeCounter) % (60 * 60) == 1)
-	{
-		DataIdx = VerMsg; // 版本信息发送
-	}
-	else if (TcpSendTimeCounter % 10 == 2)
-	{
-		DataIdx = TruckBattMsg; // 电池信息发送
-	}
-	else if ((TcpSendTimeCounter) % 60 == 3)
-	{
-		DataIdx = TruckVehiMsg; // 车辆信息发送
-	}
-	else if ((TcpSendTimeCounter) % 60 == 4)
-	{
-		DataIdx = TruckAcclMsg; // 累计信息发送
-	}
-	else if ((TcpSendTimeCounter) % 10 == 5)
-	{
-		DataIdx = GpsMsg; // 定位信息发送
-	}
-	else if ((TcpSendTimeCounter) % (60 * 60 * 2) == 6)
-	{
-		DataIdx = 0x01; // 时间校准
-	}
-	else if ((TcpSendTimeCounter) % 10 == 7)
+	memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
+	if(UTC8TimeTcp.month==0)
 	{
-		DataIdx = DebugMsg; // 调试信息发送,含FFT结果
+		DataIdx = 0x01;
 	}
-	else
-	{
-		*SendLen = 0;
-		DataIdx = 0; // 不发送,返回
-		return;
-	}
-	memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
-	GetUtc8Time(&UTC8TimeTcp); // 时间获取
-	vTaskDelay(pdMS_TO_TICKS(100));
 	switch (DataIdx)
 	{
 	case 0x01: // 时间校准
@@ -802,7 +800,9 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 		uint8 ReadLen = 0;
 		uint8 UartRecvPtr[20];
 		UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(500));
+		GetUtc8Time(&UTC8TimeTcp); // 时间获取
 		*SendLen = 0; // 不发送,长度为0
+		xTimerReset(monitorTimer1000ms,0);
 		return;
 	}
 	case 0x82:
@@ -934,6 +934,8 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 	case DebugMsg:
 	{
 		char rbuf[512]={0};
+		char tmp[13] = {0};
+		memcpy(tmp,BMS_SN,12);
 		DebugMsgtoTcpType DebugMsgInfo;
 		UINT16 DataLen = 0;
 		UINT16 BufferLen = 0;
@@ -942,7 +944,7 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 								{%.2f,%.2f,%.2f,%.2f,%.2f;\
 								%.2f,%.2f,%.2f,%.2f,%.2f,}\
 								{%.2f,%.2f,%.2f,%.2f,%.2f;\
-								%.2f,%.2f,%.2f,%.2f,%.2f,}",
+								%.2f,%.2f,%.2f,%.2f,%.2f,},%s",
 				returnFreq[0][0], returnFreq[0][1], returnFreq[0][2], returnFreq[0][3], returnFreq[0][4],
 				returnP[0][0], returnP[0][1], returnP[0][2], returnP[0][3], returnP[0][4],
 
@@ -950,13 +952,9 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 				returnP[1][0], returnP[1][1], returnP[1][2], returnP[1][3], returnP[1][4],
 
 				returnFreq[2][0], returnFreq[2][1], returnFreq[2][2], returnFreq[2][3], returnFreq[2][4],
-				returnP[2][0], returnP[2][1], returnP[2][2], returnP[2][3], returnP[2][4]);
+				returnP[2][0], returnP[2][1], returnP[2][2], returnP[2][3], returnP[2][4],tmp);
 
 		BufferLen = strlen((const char *)rbuf);
-#ifdef SEGGER_RTT_PRINTF
-			SEGGER_RTT_printf("[%d]BufferLen=%d\r\n",__LINE__,BufferLen);
-			SEGGER_RTT_printf("[%d]rbuf=%s\r\n",__LINE__,rbuf);
-#endif
 		*SendLen = BufferLen + sizeof(DebugMsgInfo);
 		SendBuffer = pvPortMalloc(*SendLen);
 		memcpy(SendBuffer + sizeof(DebugMsgInfo) - 1, rbuf, BufferLen);
@@ -1056,6 +1054,11 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 	}
 	case 0x91:
 	{
+		if(BMS_CellRecvCounter<128)
+		{
+			*SendLen = 0; // 不发送,长度为0
+			return;
+		}
 		GetCSQValue(&CSQValue);
 		*SendLen = 0x54 + min(BMS_CellTotal, BMS_CELL_MAX_NUM) * 2 + min(BMS_TempTotal, BMS_TEMP_MAX_NUM);
 		SendBuffer = pvPortMalloc(*SendLen);
@@ -1198,29 +1201,97 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 		break;
 	}
 }
-void GetUtc8Time(UTC8TimeType *UTC8TimeTcp)
+void TimeUpdate(UTC8TimeType *UTC8TimeTcpPtr)
+{
+	int year = 0, month = 0, day = 0, hour = 0,minute = 0,second = 0;
+	int lastday = 0;
+
+	year = UTC8TimeTcpPtr->year + 2000;
+	month = UTC8TimeTcpPtr->month;
+	day = UTC8TimeTcpPtr->day;
+	hour = UTC8TimeTcpPtr->hour;
+	minute = UTC8TimeTcpPtr->minute;
+	second = UTC8TimeTcpPtr->second;
+	second+=1;
+	if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
+	{
+		lastday = 31;
+	}
+	else if (month == 4 || month == 6 || month == 9 || month == 11)
+	{
+		lastday = 30;
+	}
+	else
+	{
+		if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
+			lastday = 29;
+		else
+			lastday = 28;
+	}
+	if(second >=60)
+	{
+		second -=60;
+		minute +=1;
+		if(minute >=60)
+		{
+			minute -=60;
+			hour +=1;
+		}
+	}
+	if (hour >= 24)
+	{
+		hour -= 24;
+		day += 1;
+		if (day > lastday)
+		{
+			day -= lastday;
+			month += 1;
+			if (month > 12)
+			{
+				month -= 12;
+				year += 1;
+			}
+		}
+	}
+	UTC8TimeTcpPtr->year = year - 2000;
+	UTC8TimeTcpPtr->month = month;
+	UTC8TimeTcpPtr->day = day;
+	UTC8TimeTcpPtr->hour = hour;
+	UTC8TimeTcpPtr->minute = minute;
+	UTC8TimeTcpPtr->second = second;
+}
+void GetUtc8Time(UTC8TimeType *UTC8TimeTcpPtr)
 {
 	char *AtCmdAsk = (char *)("AT+CCLK?\r\n");
 	uint8 AtCmdLen = mstrlen(AtCmdAsk);
 	uint16 ReadLen = 0;
 	uint8 *retptr = NULL;
 	uint8 UartRecvPtr[128];
-	UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdAsk, AtCmdLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
-	if (ReadLen > 0)
+	uint8 ErrCnt = 0;
+	while(ErrCnt<3)
 	{
-		if ((uint8 *)strstr((char *)UartRecvPtr, (char *)("OK")))
+		UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdAsk, AtCmdLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
+		if (ReadLen ==39 )
 		{
-			retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("+CCLK:"));
-			if (retptr)
+			if ((uint8 *)strstr((char *)UartRecvPtr, (char *)("OK")))
 			{
-				UTC8TimeTcp->year = CharToHex(*(retptr + 8)) * 10 + CharToHex(*(retptr + 9));
-				UTC8TimeTcp->month = CharToHex(*(retptr + 11)) * 10 + CharToHex(*(retptr + 12));
-				UTC8TimeTcp->day = CharToHex(*(retptr + 14)) * 10 + CharToHex(*(retptr + 15));
-				UTC8TimeTcp->hour = CharToHex(*(retptr + 17)) * 10 + CharToHex(*(retptr + 18));
-				UTC8TimeTcp->minute = CharToHex(*(retptr + 20)) * 10 + CharToHex(*(retptr + 21));
-				UTC8TimeTcp->second = CharToHex(*(retptr + 23)) * 10 + CharToHex(*(retptr + 24));
+				retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("+CCLK:"));
+				if (retptr)
+				{
+					UTC8TimeTcpPtr->year = CharToHex(*(retptr + 8)) * 10 + CharToHex(*(retptr + 9));
+					UTC8TimeTcpPtr->month = CharToHex(*(retptr + 11)) * 10 + CharToHex(*(retptr + 12));
+					UTC8TimeTcpPtr->day = CharToHex(*(retptr + 14)) * 10 + CharToHex(*(retptr + 15));
+					UTC8TimeTcpPtr->hour = CharToHex(*(retptr + 17)) * 10 + CharToHex(*(retptr + 18));
+					UTC8TimeTcpPtr->minute = CharToHex(*(retptr + 20)) * 10 + CharToHex(*(retptr + 21));
+					UTC8TimeTcpPtr->second = CharToHex(*(retptr + 23)) * 10 + CharToHex(*(retptr + 24));
+					break;
+				}
 			}
 		}
+		else
+		{
+			ErrCnt++;
+		}
 	}
 }
 static void GetCSQValue(uint8 *out)
@@ -1230,13 +1301,12 @@ static void GetCSQValue(uint8 *out)
 	uint16 ReadLen = 0;
 	uint8 *retptr = NULL;
 	uint8 UartRecvPtr[30];
+	static uint8 CSQValue = 0;
 	UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdAsk, AtCmdLen, UartRecvPtr, &ReadLen, pdMS_TO_TICKS(100));
-	*out = 99;
 	if (ReadLen > 0)
 	{
 		if ((uint8 *)strstr((char *)UartRecvPtr, (char *)("OK")))
 		{
-			*out = 0;
 			retptr = (uint8 *)strstr((char *)UartRecvPtr, (char *)("+CSQ:"));
 			char CsqStr[5];
 			for (uint8 i = 0; i < 5; i++)
@@ -1247,9 +1317,10 @@ static void GetCSQValue(uint8 *out)
 				}
 				memcpy((CsqStr + i), (retptr + i + 6), 1);
 			}
-			*out = atoi(CsqStr);
+			CSQValue = atoi(CsqStr);
 		}
 	}
+	*out = CSQValue;
 	return;
 }
 static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)

+ 10 - 0
code/app/AppTaskUart1.h

@@ -226,6 +226,16 @@ typedef enum
 	PROCESS_TCP_SLEEP,
 	PROCESS_TCP_ERROR
 } process_Tcp;
+typedef struct
+{
+	sint16 TimeCalibCnt[3];
+	sint16 VersionFeqCnt[3];
+	sint16 TrkBattFeqCnt[3];
+	sint16 GpsFeqCnt[3];
+	sint16 TrkVehichleFeqCnt[3];
+	sint16 TrkAccMsgFeqCnt[3];
+	sint16 DebugMsgFeqCnt[3];
+}TcpFeq_type;
 void Uart_4G_Task(void *pvParameters);
 sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDataLen);
 #endif /* APPTASKUART1_H_ */

+ 0 - 28
code/app/lib/AppFuncLib.c

@@ -892,8 +892,6 @@ void fft(real_T *S, uint16_T N, real_T freq, real_T *returnFreq, real_T *returnP
 	creal_T W[SIZE_FFT];
 	real_T Y1[SIZE_FFT];
 
-//	real_T Y2[SIZE_FFT / 2 + 1];
-//	real_T F[SIZE_FFT / 2 + 1];
 	fft_type fft_data[SIZE_FFT / 2 + 1];
     uint16_T i = 0;
     uint16_T j = 0;
@@ -949,32 +947,6 @@ void fft(real_T *S, uint16_T N, real_T freq, real_T *returnFreq, real_T *returnP
     	fft_data[i].freq = freq * i / N;
     }
     // 从大到小 排序
-//    real_T temp;
-//    uint16_T temp_idx;
-//    uint16_T idx[N / 2 + 1];
-//    for (i = 0; i < N / 2 + 1; i++)
-//    {
-//        idx[i] = i;
-//    }
-//
-//    for (j = 0; j < N / 2 + 1; j++) // 比较n-1轮
-//    {
-//        for (k = 0; k < N / 2 - j; k++) // 每轮比较n-1-i次,
-//        {
-//
-//            if (Y2[k] < Y2[k + 1]) // 从大到小
-//            {
-//                temp = Y2[k];
-//                Y2[k] = Y2[k + 1];
-//                Y2[k + 1] = temp;
-//
-//                temp_idx = idx[k];
-//                idx[k] = idx[k + 1];
-//                idx[k + 1] = temp_idx;
-//            }
-//        }
-//    }
-//    // 输出前5个
     qsort(fft_data,sizeof(fft_data) / sizeof(fft_data[0]),sizeof(fft_data[0]),fft_cmp);
     for (i = 0; i < 5; i++)
     {

+ 33 - 126
code/hal/hal_adapter.c

@@ -21,13 +21,14 @@ 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 TcpRecvQueue;
 QueueHandle_t UartSendQueue[3];
 QueueHandle_t UartHalQueueHandle;
 Std_ReturnType UartStartRecvFunc(uint8 channel);
 Std_ReturnType ADC_Converter(Adc_ValueGroupType *Buffer, TP_Value_Type *ConvertedValueR);
 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 write_ringBuffer(uint8_t *buffer, uint16_t size, ringbuffer_t *ringBuf,uint32 *uartDataAddr);
 uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
 uint8 ringBufferforUart[3][BUFFER_SIZE];
 ringbuffer_t uartRingBuffer[3];
@@ -95,20 +96,20 @@ void clear_ringBuffer(ringbuffer_t *ringBuf)
     ringBuf->bw         = 0;
     ringBuf->btoRead    = 0;
 }
-uint32_t write_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf)
+uint32_t write_ringBuffer(uint8_t *buffer, uint16_t size, ringbuffer_t *ringBuf,uint32 *uartDataAddr)
 {
-    uint32_t len            = 0;
     volatile uint32_t ringBuf_bw     = ringBuf->bw;
     uint32_t ringBuf_len    = ringBuf->length;
     uint8_t *ringBuf_source = ringBuf->source;
-
-    if( (ringBuf_bw + size) > ringBuf_len  )
+    if( (ringBuf_bw + size + 1) > ringBuf_len  )
     {
     	ringBuf_bw = 0;
     }
     memcpy(ringBuf_source + ringBuf_bw, buffer, size);
-    ringBuf->bw = (ringBuf_bw + size) % ringBuf_len;
+    memset(ringBuf_source + ringBuf_bw + size + 1,0x00,1);//环形buffer 插入分隔符截断字符串
+    ringBuf->bw = (ringBuf_bw + size + 1) % ringBuf_len;//数据长度不变,起始地址移位1
     ringBuf->btoRead += size;
+    *uartDataAddr = (uint32)(ringBuf->source + ringBuf->bw - size - 1);
 /*
     if(ringBuf->br!=0)
     {
@@ -174,7 +175,6 @@ Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, uint8 *txB
 		if(Recvret == pdTRUE)
 		{
 			*rxlen = UartRecvMsg.DataLen;
-	//		read_ringBuffer(rxBuffer, queueRecvSize, &uartRingBuffer[recvChannel]);
 			memcpy(rxBuffer,(uint8 *)(UartRecvMsg.dataAddr),UartRecvMsg.DataLen);
 			retVal = E_OK;
 		}
@@ -189,7 +189,7 @@ Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, uint8 *txB
 	}
 	return retVal;
 }
-Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 *rxBuffer, uint8 *rxlen, uint32 T_timeout)
+Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout)
 {
 	UartMsg_t UartRecvMsg;
 	BaseType_t ret = pdFALSE;
@@ -199,7 +199,21 @@ Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 *rxBuffer, uint8 *rxle
 	if(ret == pdTRUE)
 	{
 		*rxlen = UartRecvMsg.DataLen;
-//		read_ringBuffer(rxBuffer, queueRecvSize, &uartRingBuffer[recvChannel]);
+		memcpy(rxBuffer,(uint8 *)UartRecvMsg.dataAddr,UartRecvMsg.DataLen);
+		retVal = E_OK;
+	}
+	return retVal;
+}
+Std_ReturnType Tcp_Receive_Data(uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout)
+{
+	UartMsg_t UartRecvMsg;
+	BaseType_t ret = pdFALSE;
+	uint32 retVal = E_NOT_OK;
+	*rxlen = 0;
+	ret = xQueueReceive(TcpRecvQueue,&UartRecvMsg,T_timeout);
+	if(ret == pdTRUE)
+	{
+		*rxlen = UartRecvMsg.DataLen;
 		memcpy(rxBuffer,(uint8 *)UartRecvMsg.dataAddr,UartRecvMsg.DataLen);
 		retVal = E_OK;
 	}
@@ -233,6 +247,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(6, sizeof(UartMsg_t));
+	 TcpRecvQueue = xQueueCreate(2, sizeof(UartMsg_t));
 	 UartSendQueue[0] = xQueueCreate(3, sizeof(UartMsg_t));
 	 UartSendQueue[1] = xQueueCreate(1, sizeof(UartMsg_t));
 	 UartSendQueue[2] = xQueueCreate(1, sizeof(UartMsg_t));
@@ -312,19 +327,19 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 			  {
 					if(UartHalMsgRecv.value>0)
 					{
-						recvSize = write_ringBuffer(RX_Buffer[UartHalMsgRecv.Channel],UartHalMsgRecv.value,&uartRingBuffer[UartHalMsgRecv.Channel]);
+						recvSize = write_ringBuffer(RX_Buffer[UartHalMsgRecv.Channel],UartHalMsgRecv.value,&uartRingBuffer[UartHalMsgRecv.Channel],&(UartRecvMsg.dataAddr));
 						UartRecvMsg.DataLen = UartHalMsgRecv.value;
-						UartRecvMsg.dataAddr = (uint32)(uartRingBuffer[UartHalMsgRecv.Channel].bw + uartRingBuffer[UartHalMsgRecv.Channel].source - UartHalMsgRecv.value);
-						ret_send = xQueueSend(UartRecvQueue[UartHalMsgRecv.Channel],&UartRecvMsg,10);
-#ifdef SEGGER_RTT_PRINTF1
-						if(UartHalMsgRecv.Channel==1)
+						if(UartHalMsgRecv.Channel==1 && strstr((char *)UartRecvMsg.dataAddr, (char *)("RECV FROM")))//网络接收数据放入其他队列
 						{
-							SEGGER_RTT_printf("[%d]source=%X,dataAddr=%s\r\n",__LINE__,uartRingBuffer[UartHalMsgRecv.Channel].source,(uint8 *)UartRecvMsg.dataAddr);
+							ret_send = xQueueSend(TcpRecvQueue,&UartRecvMsg,10);
 						}
-#endif
+						else
+						{
+							ret_send = xQueueSend(UartRecvQueue[UartHalMsgRecv.Channel],&UartRecvMsg,10);
+						}
+						T_timeout[UartHalMsgRecv.Channel] = 0;
+						UartState[UartHalMsgRecv.Channel] = UartRecvComplete;
 					}
-					T_timeout[UartHalMsgRecv.Channel] = 0;
-					UartState[UartHalMsgRecv.Channel] = UartRecvComplete;
 			  }
 		  }
 	 }
@@ -1117,7 +1132,6 @@ void coreInit(void)
 
 void SystemModulesInit(void)
 {
-//	Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
 	/* Initialize Mcl module */
 	Mcl_Init(NULL_PTR);
 
@@ -1192,111 +1206,4 @@ void displayResetReasonWithLED(void)
 {
 	Mcu_ResetType bootreason;
 	bootreason = Mcu_GetResetReason();
-	if(bootreason == MCU_STOP_ACKNOWLEDGE_ERROR_RESET)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_MDM_AP_SYSTEM_RESET)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-
-	}
-	else if(bootreason == MCU_SW_RESET)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_CORE_LOCKUP_RESET)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_JTAG_RESET)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_POWER_ON_RESET)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_EXTERNAL_PIN_RESET)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_WATCHDOG_RESET)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-
-	else if(bootreason == MCU_CMU_LOSS_OF_CLOCK_RESET)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_LOSS_OF_LOCK_RESET)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_LOSS_OF_CLOCK_RESET)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_LOW_OR_HIGH_VOLTAGE_DETECT_RESET)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_NO_RESET_REASON)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-//		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_MULTIPLE_RESET_REASON)
-	{
-//		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
-	else if(bootreason == MCU_RESET_UNDEFINED)
-	{
-		Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-		Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
-	}
 }

+ 4 - 3
code/hal/hal_adapter.h

@@ -241,15 +241,16 @@ Std_ReturnType ADC_ReadValue(void);
 sint8 AtcmdDelayRecvFunc(uint8 recvChannel, char *ResultStrPtr, uint16 delayTime);
 Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, uint8 *txBuffer, uint16 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, uint8 *rxlen, uint32 T_timeout);
+Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout);
+Std_ReturnType Tcp_Receive_Data(uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout);
 Std_ReturnType UART_Reset(uint8 recvChannel);
 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);
+//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);
 
 void coreInit(void);
 void SystemModulesInit(void);

+ 1 - 1
code/main.c

@@ -83,7 +83,7 @@ int main(void)
 	SEGGER_RTT_printf("boot\n");
 #endif
 	UartInit();
-	xTaskCreate(MainTask, (const char *const)"MainTask", 4096, (void *)0, main_TASK_PRIORITY + 6, MainTask_Handle);
+	xTaskCreate(MainTask, (const char *const)"MainTask", 512, (void *)0, main_TASK_PRIORITY + 6, &MainTask_Handle);
 	//xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, Uart0Task_Handle);
 	xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, &CanTask_Handle);
 	xTaskCreate(GpsTask, (const char *const)"GpsTask", 2048, (void *)0, main_TASK_PRIORITY + 1, &GpsTask_Handle);