Преглед изворни кода

0.0.0.4 GPS变频测试程序

LAPTOP-KB7QFH2U\ChenJie-PC пре 1 година
родитељ
комит
e34746f8c3
5 измењених фајлова са 60 додато и 18 уклоњено
  1. 4 4
      code/app/AppGlobalVar.c
  2. 2 0
      code/app/AppGlobalVar.h
  3. 25 4
      code/app/AppTaskGps.c
  4. 1 1
      code/app/AppTaskMain.c
  5. 28 9
      code/app/AppTaskUart1.c

+ 4 - 4
code/app/AppGlobalVar.c

@@ -16,11 +16,11 @@
 
 #include "AppGlobalVar.h"
 
-#define defaultSn "GYTEST00000000001"
+#define defaultSn "ZLTEST00000000001"
 
 #define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
-AppConfigBody AppConfigInfo = {false, false, {defaultSn}, {0}};
+AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 
@@ -35,7 +35,7 @@ uint16 WebSitePort = 8812;
 #endif
 
 //*全局变量*//
-const uint32 AppSwVersion = 0x00010003;
+const uint32 AppSwVersion = 0x00000004;
 const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x0101;
 const uint32 BlSwVersion = 0x00000001;
@@ -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;

+ 2 - 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;

+ 25 - 4
code/app/AppTaskGps.c

@@ -14,6 +14,7 @@ uint32 location_handle(char *in1);
 void GpsDataDecode(uint8 *msg);
 uint8 GpsRecvPtr[1024];
 uint32 timerCounterGetdata = 0;
+uint32 LedCounter  = 0;
 static void vtimerCallback(TimerHandle_t pxTimer)
 {
 	uint32 ulTimerID;
@@ -44,6 +45,19 @@ void GpsTask(void *pvParameters)
 		{
 			GpsDataDecode(GpsRecvPtr);
 		}
+		/*LED控制*/
+		if(timerCounterGetdata - LedCounter>200)
+		{
+			LedCounter = timerCounterGetdata;
+			if(DeviceSpeed>0)
+			{
+				Dio_FlipChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5);
+			}
+			else
+			{
+				Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5,STD_OFF);
+			}
+		}
 		if (timerCounterGetdata % 10 == 0)
 		{
 			SL_SC7A20_Read_XYZ_Data(xyzData);
@@ -95,8 +109,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 +125,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 +145,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;

+ 1 - 1
code/app/AppTaskMain.c

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

+ 28 - 9
code/app/AppTaskUart1.c

@@ -756,23 +756,42 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 	static UTC8TimeType UTC8TimeTcp;
 	uint8 *SendBuffer = NULL;
 	uint8 DataIdx = 0;
-	if ((TcpSendTimeCounter) % (60 * 60) == 1)
+	uint16 GpsFeq = 10;
+	if(DeviceSpeed==0)
 	{
-		DataIdx = VerMsg; // 版本信息发送
+		GpsFeq = 3600;
 	}
-	else if (TcpSendTimeCounter % 10 == 2)
+	else if(DeviceSpeed>0 && DeviceSpeed<=100)
 	{
-		DataIdx = TruckBattMsg; // 电池信息发送
+		GpsFeq = 60;
 	}
-	else if ((TcpSendTimeCounter) % 60 == 3)
+	else if(DeviceSpeed>100 && DeviceSpeed<=200)
 	{
-		DataIdx = TruckVehiMsg; // 车辆信息发送
+		GpsFeq = 10;
 	}
-	else if ((TcpSendTimeCounter) % 60 == 4)
+	else if(DeviceSpeed>200)
 	{
-		DataIdx = TruckAcclMsg; // 累计信息发送
+		GpsFeq = 1;
+	}
+
+	GpsFeq = Saturation_u(GpsFeq,1,3600);
+	if ((TcpSendTimeCounter) % (60 * 60) == 1)
+	{
+		DataIdx = VerMsg; // 版本信息发送
 	}
-	else if ((TcpSendTimeCounter) % 10 == 5)
+//	else if (TcpSendTimeCounter % 10 == 2)
+//	{
+//		DataIdx = TruckBattMsg; // 电池信息发送
+//	}
+//	else if ((TcpSendTimeCounter) % 60 == 3)
+//	{
+//		DataIdx = TruckVehiMsg; // 车辆信息发送
+//	}
+//	else if ((TcpSendTimeCounter) % 60 == 4)
+//	{
+//		DataIdx = TruckAcclMsg; // 累计信息发送
+//	}
+	else if ((TcpSendTimeCounter) % GpsFeq == 0)
 	{
 		DataIdx = GpsMsg; // 定位信息发送
 	}