Browse Source

no message

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
2341431ad9
17 changed files with 208 additions and 506 deletions
  1. 2 1
      inc/AppConfig.h
  2. 4 1
      inc/AppFunc.h
  3. 33 14
      inc/AppTaskCan.h
  4. 13 11
      inc/AppTaskControl.h
  5. 27 5
      inc/AppTaskGps.h
  6. 1 4
      inc/AppTaskMain.h
  7. 1 1
      inc/app.h
  8. 52 5
      src/AppFunc.c
  9. 1 1
      src/AppSignal.c
  10. 18 229
      src/AppTaskCan.c
  11. 42 0
      src/AppTaskControl.c
  12. 7 164
      src/AppTaskGps.c
  13. 0 48
      src/AppTaskLed.c
  14. 2 2
      src/AppTaskMain.c
  15. 3 3
      src/AppTaskTcp.c
  16. 1 16
      src/AppTaskUart.c
  17. 1 1
      src/app.c

+ 2 - 1
inc/AppConfig.h

@@ -32,7 +32,7 @@ typedef struct AppConfigDataType
     BOOL   appDataModify;		//数据更改标志位
 	UINT8  battSN[BATT_SN_LEN]; //电池SN号码
 	UINT8  EOLState;            //下线检测状态
-    UINT32 AppSwVersion;        //软件版本
+    UINT32 AppSwVersion;        //APP软件版本
     UINT8  BattCellCount;       //电池电压串数
     UINT8  BattTempCount;       //电池温度个数
 }AppConfigDataType;
@@ -54,6 +54,7 @@ typedef struct AppDataType
     UINT8  PosInfoSendFreqLow;          //定位信息发送间隔低频,单位s
     UINT32 AccMileage;                  //累计里程,单位m
     UINT16 SysReStartCount;             //系统重启次数
+    UINT8  RelayControl;                //继电器控制
 }AppDataBody;
 typedef struct _AppDataHeader
 {

+ 4 - 1
inc/AppFunc.h

@@ -10,7 +10,6 @@
 #include "commontypedef.h"
 #include "flash_ec616_rt.h"
 #include "mem_map.h"
-#include "AppTaskTcp.h"
 #include "AppConfig.h"
 #include "ec_tcpip_api.h"
 
@@ -36,6 +35,10 @@ UINT16 GetErrorNum(UINT16 *ErrorArray,UINT8 Errorlen);
 UINT8 PutErrorNum(UINT16 *ErrorArray,UINT8 Errorlen,UINT16 ErrorNum);
 UINT8 LookUpRTtable(UINT32 R_value);
 
+
+void strdel(char * str,char c);
+UINT32 location_handle(char *in1);
+
 static BOOL UDSClearFotaDownloadRegion(void);
 static BOOL UDSAskforDownLoadData(void);
 static UINT8 UDSPositiveAnswer(UINT8 answerLen,UINT8 messageIndex,UINT32 posCode);

+ 33 - 14
inc/AppTaskCan.h

@@ -1,15 +1,35 @@
-
-
-
-extern CAN_Msg_Type CanRxMsg[2];
-extern UINT8	UDSCmd[2];
-extern UINT8	UDSService[2];
-extern UINT8   UDSSubService[2];
-extern UINT8	UDSSubServiceActionCode[2];
-extern UINT8 	UDSSwitch;
-extern UINT8   UDSBattSN[BATT_SN_LEN];
-
-
+/****************************************************************************
+ *
+ * Copy right:   2021-, Copyrigths of RLWL Ltd.Zhen C
+ * File name:    AppTaskCan.h
+ * Description:  App Task Can H file 
+ * History:      Rev3.0   2021-07-06
+ *
+ ****************************************************************************/
+#include "bsp.h"
+#include "bsp_custom.h"
+#include "osasys.h"
+#include "ostask.h"
+#include "queue.h"
+#include "ps_event_callback.h"
+#include "cmisim.h"
+#include "cmimm.h"
+#include "cmips.h"
+#include "sockets.h"
+#include "psifevent.h"
+#include "ps_lib_api.h"
+#include "lwip/netdb.h"
+#include "debug_log.h"
+#include "slpman_ec616.h"
+#include "plat_config.h"
+#include "ec_tcpip_api.h"
+#include "hal_module_adapter.h"
+#include "app.h"
+#include "AppSignal.h"
+#include "AppFunc.h"
+#include "AppConfig.h"
+
+#define 			PROC_CAN_RX_TASK_STACK_SIZE			(1024)
 typedef enum
 {
     PROCESS_CAN_STATE_IDLE = 0,
@@ -17,9 +37,8 @@ typedef enum
     PROCESS_CAN_STATE_SLEEP
 }process_CAN;
 
-void CANTaskInit(void* arg);
+void AppTaskCanInit(void* arg);
 static void Can_Receive(void);
-void CanMsgTx1000ms(void);
 
 
 

+ 13 - 11
inc/AppTaskLed.h → inc/AppTaskControl.h

@@ -1,8 +1,8 @@
 /****************************************************************************
  *
  * Copy right:   Qx.Chen Jie
- * File name:    LedTask.h
- * Description:  Led闪烁逻辑
+ * File name:    AppTaskControl.h
+ * Description:  LED控制和蜂鸣器控制和继电器控制逻辑判定
  * History:      2021-07-05
  * Version:      V3.0
  ****************************************************************************/
@@ -26,14 +26,16 @@
 #include "ec_tcpip_api.h"
 #include "hal_module_adapter.h"
 #include "timers.h"
-#include "Signal.h"
-
-#define PROC_LED_TASK_STACK_SIZE           (256)
+#include "AppFunc.h"
+#include "AppSignal.h"
+#include "AppConfig.h"
+#include "hal_module_adapter.h"
+#define PROC_CONTROL_TASK_STACK_SIZE           (256)
 typedef enum
 {
-    PROCESS_LED_STATE_IDLE = 0,
-    PROCESS_LED_STATE_WORK,
-    PROCESS_LED_STATE_SLEEP
-}process_LED;
-void LedTaskInit(void *arg);
-void LedTaskDeInit(void *arg);
+    PROCESS_CONTROL_STATE_IDLE = 0,
+    PROCESS_CONTROL_STATE_WORK,
+    PROCESS_CONTROL_STATE_SLEEP
+}process_control;
+void AppTaskControlInit(void *arg);
+void AppTaskControlDeInit(void *arg);

+ 27 - 5
inc/AppTaskGps.h

@@ -3,10 +3,32 @@
  * Copy right:   Qx.Chen jie
  * File name:    GpsTask.h
  * Description:  Gps处理任务
- * History:      2021-03-07
- *
+ * History:      2021-03-07 2021-07-15
+ * Version:      V3.0
  ****************************************************************************/
 //
-extern UINT8 GpsData[20];
-extern osMutexId_t GpsMutex;
-INT32 GpsTaskInit(void);
+#include "bsp.h"
+#include "bsp_custom.h"
+#include "osasys.h"
+#include "ostask.h"
+#include "queue.h"
+#include "ps_event_callback.h"
+#include "app.h"
+#include "cmisim.h"
+#include "cmimm.h"
+#include "cmips.h"
+#include "sockets.h"
+#include "psifevent.h"
+#include "ps_lib_api.h"
+#include "lwip/netdb.h"
+#include "debug_log.h"
+#include "slpman_ec616.h"
+#include "plat_config.h"
+#include "ec_tcpip_api.h"
+#include "AppFunc.h"
+#include "AppSignal.h"
+#include "AppConfig.h"
+#include "hal_module_adapter.h"
+
+#define GPS_TASK_STACK_SIZE   								 (512)
+INT32 AppTaskGpsInit(void);

+ 1 - 4
inc/AppTaskMain.h

@@ -26,7 +26,7 @@
 #include "ec_tcpip_api.h"
 #include "hal_module_adapter.h"
 #include "timers.h"
-#include "Signal.h"
+#include "AppSignal.h"
 
 #define PROC_MAIN_TASK_STACK_SIZE           (1024+512)
 
@@ -39,7 +39,4 @@ typedef enum
 
 void MainTaskInit(void* arg);
 void MainTaskDeInit(void* arg);
-extern void GsensorInit(void);
-extern void GsensorI2CHandler(ARM_I2C_SignalEvent_t cb_event);
-extern void GsensorI2CCallback(UINT32 event);
 

+ 1 - 1
inc/app.h

@@ -32,7 +32,7 @@ extern "C" {
 #endif
 extern void AppTaskMainInit(void* arg);
 extern void AppTaskTcpInit(void *arg);
-extern void AppTaskLedInit(void *arg);
+extern void AppTaskControlInit(void *arg);
 extern void AppTaskGpsInit(void *arg);
 extern void AppTaskUartInit(void *arg);
 extern void AppTaskCanInit(void *arg);

+ 52 - 5
src/AppFunc.c

@@ -1011,7 +1011,7 @@ void UDS_Service()
 	}
 }
 
-UINT8 UDSPositiveAnswer(UINT8 answerLen,UINT8 messageIndex,UINT32 posCode)
+static UINT8 UDSPositiveAnswer(UINT8 answerLen,UINT8 messageIndex,UINT32 posCode)
 {
 	CAN_Msg_Type UDSAnswer;
 	UINT8 ret;
@@ -1059,7 +1059,7 @@ UINT8 UDSPositiveAnswer(UINT8 answerLen,UINT8 messageIndex,UINT32 posCode)
 	return ret;
 }
 
-UINT8 UDSNegtiveAnswer(UINT8 answerLen,UINT8 messageIndex, UINT32 negCode)
+static UINT8 UDSNegtiveAnswer(UINT8 answerLen,UINT8 messageIndex, UINT32 negCode)
 {
 	CAN_Msg_Type UDSAnswer;
 	UINT8 ret;
@@ -1108,7 +1108,7 @@ UINT8 UDSNegtiveAnswer(UINT8 answerLen,UINT8 messageIndex, UINT32 negCode)
 	return ret;
 }
 
-BOOL UDSAskforDownLoadData()
+static BOOL UDSAskforDownLoadData()
 {
 	updateDifferDataPackageCounter = 0;
 	downloadReady = true;
@@ -1116,7 +1116,7 @@ BOOL UDSAskforDownLoadData()
 	return TRUE;
 }
 
-BOOL UDSClearFotaDownloadRegion()
+static BOOL UDSClearFotaDownloadRegion()
 {
 	UINT8 ret = FALSE;
 	ret = BSP_QSPI_Erase_Safe(FLASH_FOTA_REGION_START, 0x46000); //512k-32k -200k = 280k -> 0x46000
@@ -1214,7 +1214,12 @@ UINT8 LookUpRTtable(UINT32 R_value)
 		}
 	}//R-2
 }
-
+/*******
+ * 获取故障代码函数
+ * 输入:故障代码列表,长度
+ * 输出:第一个故障代码
+ * 处理:获取第一个,将后面依次前移
+*******/
 UINT16 GetErrorNum(UINT16 *ErrorArray,UINT8 Errorlen)
 {
 	UINT16 OutNum;
@@ -1227,6 +1232,12 @@ UINT16 GetErrorNum(UINT16 *ErrorArray,UINT8 Errorlen)
 	}
 	return OutNum;
 }
+/*******
+ * 放入故障代码函数
+ * 输入:故障代码列表,长度,故障码
+ * 输出:状态
+ * 处理:将故障代码放入故障列表,若存在则不放入,若不存在,则放入
+*******/
 UINT8 PutErrorNum(UINT16 *ErrorArray,UINT8 Errorlen,UINT16 ErrorNum)
 {
 	for(int i=0;i<Errorlen;i++)
@@ -1249,4 +1260,40 @@ UINT8 PutErrorNum(UINT16 *ErrorArray,UINT8 Errorlen,UINT16 ErrorNum)
 		}
 	}
 	return 2;
+}
+/*******
+ * 字符串处理函数
+ * 输入:需要删除的字符,以及目标字符串
+ * 输出:无
+ * 处理:将指定字符串删掉
+*******/
+void strdel(char * str,char c)
+{
+	char *p = str;
+	while(*str)
+	{
+		if(*str!=c)
+			*p++ = *str;
+		str++;
+	}
+	*p = '\0';
+}
+/*******
+ * 位置处理函数
+ * 输入:经纬度
+ * 输出:经纬度
+ * 处理:将经纬度进行处理
+*******/
+UINT32 location_handle(char *in1)
+{
+	UINT32 location_temp;
+	UINT32 location_degree;
+	UINT32 location_min;
+	location_temp = atol(in1);
+	location_degree = location_temp/(1e7);
+	location_degree = location_degree*(1e6);
+	location_min = location_temp-location_degree*10;
+	location_min = location_min/6;
+	location_temp = location_degree+location_min;
+	return location_temp;
 }

+ 1 - 1
src/AppSignal.c

@@ -68,7 +68,7 @@ UINT32  TimeCounter = 0x00;             //主任务定时器计数
 
 /**declear the Handle vars**/
 osMutexId_t Error_Mutex = NULL;         //故障互锁句柄
-
+osMutexId_t GpsMutex = NULL;           //GPS互锁句柄
 
 
 /**declear other vars**/   

+ 18 - 229
src/AppTaskCan.c

@@ -1,55 +1,26 @@
-#include "bsp.h"
-#include "bsp_custom.h"
-#include "osasys.h"
-#include "ostask.h"
-#include "queue.h"
-#include "ps_event_callback.h"
-#include "cmisim.h"
-#include "cmimm.h"
-#include "cmips.h"
-#include "sockets.h"
-#include "psifevent.h"
-#include "ps_lib_api.h"
-#include "lwip/netdb.h"
-#include <cis_def.h>
-#include "debug_log.h"
-#include "slpman_ec616.h"
-#include "plat_config.h"
-#include "ec_tcpip_api.h"
-#include "hal_module_adapter.h"
-#include "UartTask.h"
-#include "MainTask.h"
-#include "app.h"
-#include "CANTask.h"
-#include "UDSService.h"
-#include "signal.h"
+/****************************************************************************
+ *
+ * Copy right:   2021-, Copyrigths of RLWL Ltd.Zhen C
+ * File name:    AppTaskCan.h
+ * Description:  App Task Can H file 
+ * History:      Rev3.0   2021-07-06
+ *
+ ****************************************************************************/
+#include "AppTaskCan.h"
 
-extern UINT32 Timer_count;
-extern volatile BOOL Sleep_flag;
 
-CAN_Msg_Type CanRxMsg[2];
-/*线程声明*/
-#define 			PROC_CAN_RX_TASK_STACK_SIZE			(1024)
 static StaticTask_t gProcess_Can_Rx_Task_t;
 static UINT8 		gProcess_Can_Rx_TaskStack[PROC_CAN_RX_TASK_STACK_SIZE];
-
-
 static process_CAN	gProcess_CAN_Task = PROCESS_CAN_STATE_IDLE;
 #define 			PROC_CAN_STATE_SWITCH(a)  (gProcess_CAN_Task = a)
-volatile bool 		CAN_Sleep_State = false;
-UINT8 				CanSendSlpHandler	= 0xfd;
-
-extern updateBMSStatus MS_BMS_Update_Service();
 
-
-void CANTaskInit(void* arg)
+void AppTaskCanInit(void* arg)
 {
-    osThreadAttr_t task_rx_attr,task_tx_attr;
+    osThreadAttr_t task_rx_attr;
     Can_InitType param;
     param.baudrate = CAN_250Kbps;
 	param.mode = REQOP_NORMAL;	
 	param.packType = STD_PACK;
-	
     memset(&task_rx_attr,0,sizeof(task_rx_attr));
     memset(gProcess_Can_Rx_TaskStack, 0, PROC_CAN_RX_TASK_STACK_SIZE);
     task_rx_attr.name = "Can_Task";
@@ -58,216 +29,34 @@ void CANTaskInit(void* arg)
     task_rx_attr.priority = osPriorityBelowNormal7;
     task_rx_attr.cb_mem = &gProcess_Can_Rx_Task_t;
     task_rx_attr.cb_size = sizeof(StaticTask_t);
-	
     HAL_Can_Init(param);
     osDelay(1000);
     osThreadNew(Can_Receive, NULL, &task_rx_attr);
 }
 
-
 static void Can_Receive()
 {    
-	slpManSlpState_t State;
-    uint8_t udsFlag,msgFlag=0;
-	UINT8 i = 0;
-	UINT16 delayconuter = 0;
-	CAN_Sleep_State = false;
     while(true)
-    {
-		memset(CanRxMsg, 0, sizeof(CanRxMsg));    		
+    {	
 		switch(gProcess_CAN_Task)
 		{
 			case PROCESS_CAN_STATE_IDLE:
-				osDelay(2000);
-				PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_WORK);
+			{
 				break;				
-			
+			}
 			case PROCESS_CAN_STATE_WORK:
-				
-				if(Sleep_flag)
-				{
-					PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_SLEEP);
-				}
-				if(HAL_Can_Receive(CanRxMsg)>0)					
-				{
-					delayconuter=0;						
-					for(i=0; i<2; i++)
-					{								
-						if(CanRxMsg[i].Id == 0x7A0)
-						{	
-							udsFlag = 1;
-							UDSService[i] =  CanRxMsg[i].Data[0];
-							UDSSubService[i] = CanRxMsg[i].Data[1];
-							UDSSubServiceActionCode[i] = CanRxMsg[i].Data[2];
-							if(UDSService[i] == 0x10)
-							{
-								if(UDSSubService[i] == 0x02)
-								{
-									UDSSwitch = 1;
-								}								
-							}
-						}
-						else if(CanRxMsg[i].Id == 0x7A1)
-						{
-							if(CanRxMsg[i].Data[0] != 0x00)
-							{
-								msgFlag = 1;	
-							}
-							else
-							{
-								msgFlag = 0;
-							}
-						}
-					}	
-					if(udsFlag==1)
-					{	
-						UDS_Service();
-						udsFlag = 0;
-					}
-					else if(msgFlag == 1)
-					{
-						CanMsgTx1000ms();							
-					}				
-				}
-				else
-				{
-					delayconuter++;
-					osDelay(10);
-					if(delayconuter>=0xfffe)
-					{
-						delayconuter=0;
-					}
-				}
-				if(delayconuter>100)
-				{
-					delayconuter=0;
-					PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_IDLE);
-				}
+			{
 				break;
-				
+			}	
 	        case PROCESS_CAN_STATE_SLEEP:
 	        {	            
-	            HAL_Can_Sleep();	 
-	            
-	            CAN_Sleep_State = true;
-	            while(true)
-	            {
-	                osDelay(60000/portTICK_PERIOD_MS);
-	            }
-				osThreadExit();	            
+	            HAL_Can_Sleep();	           
 	            break;
-	       }
+	       	}
 	   }
-	   //osDelay(50);
 	}      
 }
 
 
-void CanMsgTx1000ms()
-{
-	UINT16	COMOutTable[28]	=	{0x6A0,0x6A1,0x6A2,0x6A3,0x6A4,0x6A5,0x6A6,0x6B0,0x6BA,0x6C0,0x6C1,0x6C2,0x6C3,0x6C4,0x7C0,0x7C1,0x7C2,0x7C3,0x7C4,0x7C5,0x7C6,0x7C7,0x7C8,0x7C9,0x7CA,0x7CB,0x7CC,0x7CD};
-	static UINT32 timerRecord = 0;
-	UINT8 count = 0;
-	CAN_Msg_Type canMsg;
-	
-	if(Timer_count - timerRecord > 0)
-	{
-		timerRecord = Timer_count;
-		count = Timer_count%10;
-		switch (count)
-		{
-			case 0:  //send cell batt info 0x6A0、0x6A1	
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2],  canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-				
-				break;
-
-			case 1:  //send cell batt info 0x6A2、0x6A3
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-				break;
-
-			case 2: //send cell batt info 0x6A4、 0x6A5
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-				break;
-			
-			case 3:	//send cell batt info 0x6A6、0x6B0
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-				
-				break;
-			
-			case 4: //send batt temp info 0x6BA、0x6C0
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-			break;
-			
-			case 5: //send batt other info 0x6C1、0x6C2
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2],  canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-			break;
-
-			case 6:	//send batt other info 0x6C3、0x6C4
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2];
-				CANEncodeFunction( COMOutTable[count*2],  canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-
-				canMsg.DLC = 8;
-				canMsg.Id = COMOutTable[count*2+1];
-				CANEncodeFunction( COMOutTable[count*2+1], canMsg.Data);
-				HAL_Can_Transmit(canMsg);
-			break;
-			
-			default:
-			break;
-			
-		}
-	}
-}
-
 
 

+ 42 - 0
src/AppTaskControl.c

@@ -0,0 +1,42 @@
+/****************************************************************************
+ *
+ * Copy right:   Qx.Chen Jie
+ * File name:    AppTaskControl.c
+ * Description:  LED控制和蜂鸣器控制和继电器控制逻辑判定
+ * History:      2021-07-05
+ * Version:      V3.0
+ ****************************************************************************/
+#include "AppTaskControl.h"
+
+static StaticTask_t                 gProcess_Control_Task_t;
+static UINT8                        gProcess_Control_TaskStack[PROC_CONTROL_TASK_STACK_SIZE];
+static osThreadId_t                 LedTaskId = NULL;
+static process_control 		        gProcess_Control_Task = PROCESS_CONTROL_STATE_IDLE;
+#define PROC_CONTROL_STATE_SWITCH(a)    (gProcess_Control_Task = a)
+
+static void ControlTask(void* arg)
+{
+    osDelay(5000);
+    while (true)
+    {
+        osDelay(100);
+    }
+}
+void AppTaskControlInit(void *arg)
+{
+    osThreadAttr_t task_attr;
+    memset(&task_attr,0,sizeof(task_attr));
+    memset(gProcess_Led_TaskStack, 0xA5, PROC_CONTROL_TASK_STACK_SIZE);
+    task_attr.name = "Led_Task";
+    task_attr.stack_mem = gProcess_Control_TaskStack;
+    task_attr.stack_size = PROC_CONTROL_TASK_STACK_SIZE;
+    task_attr.priority = osPriorityBelowNormal;
+    task_attr.cb_mem = &gProcess_Control_Task_t;
+    task_attr.cb_size = sizeof(StaticTask_t);
+    ControlTaskId = osThreadNew(ControlTask, NULL, &task_attr);
+}
+void AppTaskControlDeInit(void *arg)
+{
+    osThreadTerminate(ControlTaskId);
+    ControlTaskId = NULL;
+}

+ 7 - 164
src/AppTaskGps.c

@@ -2,159 +2,28 @@
  *
  * Copy right:   Qx.Chen jie
  * File name:    GpsTask.c
- * Description:  Gps处理任务
- * History:      2021-03-07
- *
+ * Description:  Gps处理任务和三轴数据处理及获取
+ * History:      2021-03-07 2021-07-15
+ * Version:      V3.0
  ****************************************************************************/
-#include "bsp.h"
-#include "bsp_custom.h"
-#include "osasys.h"
-#include "ostask.h"
-#include "queue.h"
-#include "ps_event_callback.h"
-#include "app.h"
-#include "cmisim.h"
-#include "cmimm.h"
-#include "cmips.h"
-#include "sockets.h"
-#include "psifevent.h"
-#include "ps_lib_api.h"
-#include "lwip/netdb.h"
-#include "debug_log.h"
-#include "slpman_ec616.h"
-#include "plat_config.h"
-#include "ec_tcpip_api.h"
-#include "app.h"
-#include "MainTask.h"
-#include "GpsTask.h"
-#include "TcpTask.h"
-//全局变量区输入
-extern volatile BOOL Sleep_flag; 
-extern AppDataBody AppDataInfo;
-extern UINT8 WorkFlag;
-//全局变量区输出
-UINT8 GpsData[20];
-osMutexId_t GpsMutex = NULL;
-//线程定义区
-#define GPS_TASK_STACK_SIZE   								 (512)
+#include "AppTaskGps.h"
 static QueueHandle_t norGpsHandle = NULL;
 static osThreadId_t gpsTaskHandle = NULL;
 static StaticTask_t gpsTask = NULL;
 static UINT8 gpsTaskStack[GPS_TASK_STACK_SIZE];
 
-//函数声明区
-void strdel(char * str,char c);
-UINT32 location_handle(char *in1);
-
 static void GpsTask(void* arg)
 {
-    gpsReqMsg msg;
-	char *p=NULL;
-	const char *delim = "\n";
-	char *databuffer[14];
-    UINT32 speedtemp;
-    UINT32 latitude;
-	UINT32 longitude;
-    UINT16 direction;
-    posGGAServiceStart(norGpsHandle);
-    posGGAReset();
     if(GpsMutex == NULL)
     {
         GpsMutex = osMutexNew(NULL);
-    }
+    }    
     while(1)
     {
-        //char temp[] = "$GNRMC,082626.000,A,2939.91801,N,10637.09500,E,0.543,30.254,261120,,,A,V*17";
-        osStatus_t ret = osMessageQueueGet(norGpsHandle, &msg, 0, osWaitForever);
-        if(ret==0)
-        {
-            if (msg.dataPtr)
-            {	
-                osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);//Gps数据锁	
-                p = strtok(msg.dataPtr,delim);//将信息进行分割
-                #ifdef USING_PRINTF1
-                    printf("\nP msgptr data:%s\r\n",p);
-                #endif
-                p = strtok(p,",");//只取第1行的信息RMC
-                //p = strtok(temp,",");//模拟测试
-                if (strcmp(p,"$GNRMC")==0)
-                {
-                    UINT8 i=0;			
-                    while (p)
-                    {	
-                        databuffer[i]=p;
-                        p = strtok(NULL,",");
-                        i++;;
-                    }
-                    if (strcmp(databuffer[1],"V")==0|strcmp(databuffer[2],"V")==0)
-                    {
-                        memset(GpsData,0x00,sizeof(GpsData));
-                    }
-                    else if (strcmp(databuffer[2],"A")==0)
-                    {
-                        GpsData[0] = 0x01;//有效,东经,北纬写定
-                        GpsData[1] = 03;//卫星数目写入1
-                        strdel(databuffer[3],'.');
-                        strdel(databuffer[5],'.');
-                        strdel(databuffer[7],'.');
-                        speedtemp = atol(databuffer[7])*1852/1e5;//节换算单位,1节=1.852km每小时
-                        GpsData[4] = (speedtemp>>8)&0xFF;
-                        GpsData[5] = speedtemp&0xFF; 
-                        latitude =location_handle(databuffer[3]);
-                        GpsData[8] = latitude>> 24;
-                        GpsData[9] = latitude>> 16;
-                        GpsData[10] = latitude>> 8;
-                        GpsData[11] = latitude;
-                        longitude = location_handle(databuffer[5]);
-                        GpsData[12] = longitude>>24;
-                        GpsData[13] = longitude>>16;
-                        GpsData[14] = longitude>>8;
-                        GpsData[15] = longitude;
-
-                        GpsData[6] = 0x03;
-                        GpsData[7] = 0xE8;
-                        if(speedtemp>=50)//大于5km/h才输出方位
-                        {
-                            direction = atol(databuffer[8]);
-                            GpsData[2] = direction>>8;
-                            GpsData[3] = direction;
-                        }
-                        else
-                        {
-                            GpsData[2] = 0xff;
-                            GpsData[3] = 0xfe;
-                        }
-                        if(speedtemp>=30 && speedtemp<=1500 && WorkFlag==0x01)
-                        {
-                            AppDataInfo.appDataModify = true;
-                            AppDataInfo.AccMileage = speedtemp/36 + AppDataInfo.AccMileage;
-                            if(AppDataInfo.AccMileage>=0xfffffffe)
-                            {
-                                AppDataInfo.AccMileage = 0;
-                            }
-
-                        }
-                        GpsData[16] = AppDataInfo.AccMileage>>24;
-                        GpsData[17] = AppDataInfo.AccMileage>>16;
-                        GpsData[18] = AppDataInfo.AccMileage>>8;
-                        GpsData[19] = AppDataInfo.AccMileage;
-                    }
-                }
-                osMutexRelease(GpsMutex);
-            }
-            if(msg.dataPtr)
-                free(msg.dataPtr);
-            msg.dataPtr=NULL;
-        }
-        if (Sleep_flag)
-		{
-            posGGAServiceStop();
-			osThreadExit();
-			break;
-		}
+        osDelay(1000);
     }
 }
-INT32 GpsTaskInit(void)
+INT32 AppTaskGpsInit(void)
 {
 
 	if(norGpsHandle == NULL)
@@ -181,29 +50,3 @@ INT32 GpsTaskInit(void)
 	
 	return 0;
 }
-/*----------------------------------------*/
-// 字符串删除函数
-void strdel(char * str,char c)
-{
-	char *p = str;
-	while(*str)
-	{
-		if(*str!=c)
-			*p++ = *str;
-		str++;
-	}
-	*p = '\0';
-}
-UINT32 location_handle(char *in1)
-{
-	UINT32 location_temp;
-	UINT32 location_degree;
-	UINT32 location_min;
-	location_temp = atol(in1);
-	location_degree = location_temp/(1e7);
-	location_degree = location_degree*(1e6);
-	location_min = location_temp-location_degree*10;
-	location_min = location_min/6;
-	location_temp = location_degree+location_min;
-	return location_temp;
-}

+ 0 - 48
src/AppTaskLed.c

@@ -1,48 +0,0 @@
-/****************************************************************************
- *
- * Copy right:   Qx.Chen jie
- * File name:    LedTask.c
- * Description:  主要负责:Led闪烁逻辑
- * History:      2021-07-05
- * Version:      V3.0
- ****************************************************************************/
-#include "LedTask.h"
-
-//局部变量申请
-static StaticTask_t                 gProcess_Led_Task_t;
-static UINT8                        gProcess_Led_TaskStack[PROC_LED_TASK_STACK_SIZE];
-static osThreadId_t                 LedTaskId = NULL;
-static process_LED 		            gProcess_Led_Task = PROCESS_LED_STATE_IDLE;
-#define PROC_LED_STATE_SWITCH(a)    (gProcess_Led_Task = a)
-
-//函数声明区
-
-//线程任务区
-static void LedTask(void* arg)
-{
-    osDelay(5000);//等待驻网延时5s
-    while (true)
-    {
-        osDelay(100);
-    }//while 循环
-}
-//Tcp线程初始化
-void LedTaskInit(void *arg)
-{
-    osThreadAttr_t task_attr;
-    //registerPSEventCallback(NB_GROUP_ALL_MASK, socketRegisterPSUrcCallback);
-    memset(&task_attr,0,sizeof(task_attr));
-    memset(gProcess_Led_TaskStack, 0xA5, PROC_LED_TASK_STACK_SIZE);
-    task_attr.name = "Led_Task";
-    task_attr.stack_mem = gProcess_Led_TaskStack;
-    task_attr.stack_size = PROC_LED_TASK_STACK_SIZE;
-    task_attr.priority = osPriorityBelowNormal;
-    task_attr.cb_mem = &gProcess_Led_Task_t;
-    task_attr.cb_size = sizeof(StaticTask_t);
-    LedTaskId = osThreadNew(LedTask, NULL, &task_attr);
-}
-void LedTaskDeInit(void *arg)
-{
-    osThreadTerminate(LedTaskId);
-    LedTaskId = NULL;
-}

+ 2 - 2
src/AppTaskMain.c

@@ -130,7 +130,7 @@ static void MainTask(void* arg)
         }
     }
 }
-void MainTaskInit(void *arg)
+void AppTaskMainInit(void *arg)
 {
     #ifndef USING_PRINTF
     if(BSP_GetPlatConfigItemValue(PLAT_CONFIG_ITEM_LOG_CONTROL) != 0)
@@ -150,7 +150,7 @@ void MainTaskInit(void *arg)
     MainTaskId = osThreadNew(MainTask, NULL, &task_attr);
 
 }
-void MainTaskDeInit(void *arg)
+void AppTaskMainDeInit(void *arg)
 {
     osThreadTerminate(MainTaskId);
     MainTaskId = NULL;

+ 3 - 3
src/AppTaskTcp.c

@@ -6,7 +6,7 @@
  * History:      2021-07-05
  * Version:      V3.0
  ****************************************************************************/
-#include "TcpTask.h"
+#include "AppTaskTcp.h"
 
 //局部变量申请
 static StaticTask_t                 gProcess_Tcp_Task_t;
@@ -33,7 +33,7 @@ static void TcpTask(void* arg)
     }//while 循环
 }
 //Tcp线程初始化
-void TcpTaskInit(void *arg)
+void AppTaskTcpInit(void *arg)
 {
     osThreadAttr_t task_attr;
     //registerPSEventCallback(NB_GROUP_ALL_MASK, socketRegisterPSUrcCallback);
@@ -47,7 +47,7 @@ void TcpTaskInit(void *arg)
     task_attr.cb_size = sizeof(StaticTask_t);
     TcpTaskId = osThreadNew(TcpTask, NULL, &task_attr);
 }
-void TcpTaskDeInit(void *arg)
+void AppTaskTcpDeInit(void *arg)
 {
     osThreadTerminate(TcpTaskId);
     TcpTaskId = NULL;

+ 1 - 16
src/AppTaskUart.c

@@ -33,25 +33,10 @@
 #include "numeric.h"
 #include "Fota.h"
 #include "signal.h"
-//全局变量输入区
-extern UINT32 Timer_count;
-extern volatile BOOL Sleep_flag; 
-extern AppNVMDataType AppNVMData;
-extern AppDataBody AppDataInfo;
-extern UINT8 WorkFlag;
-//全局变量输出区
-BOOL UartBattInfoRecvFlag  = false;
-QueueHandle_t UartWriteCmdHandle = NULL;
-UINT8 BattChrgEndFlag;
-
-
-
-//
 
 extern ARM_DRIVER_USART Driver_USART1;
 static ARM_DRIVER_USART *USARTdrv = &Driver_USART1;
-volatile bool isRecvTimeout = false;
-volatile bool isRecvComplete = false;
+
 
 //线程声明区
 static StaticTask_t             gProcess_Uart_Task_t;

+ 1 - 1
src/app.c

@@ -11,7 +11,7 @@ void appInit(void *arg)
 {
     AppTaskMainInit(arg);
     AppTaskTcpInit(arg);
-    AppTaskLedInit(arg);
+    AppTaskControlInit(arg);
     AppTaskGpsInit(arg);
     AppTaskUartInit(arg);
     AppTaskCanInit(arg);