Selaa lähdekoodia

1.增加内存缓冲区个数计算;
2.增加队列部分缓冲功能

libo 2 vuotta sitten
vanhempi
commit
b0473862b1
6 muutettua tiedostoa jossa 60 lisäystä ja 27 poistoa
  1. 2 1
      Inc/main.h
  2. 35 10
      Src/TerminalSlave485_jt808.c
  3. 2 14
      Src/freertos.c
  4. 1 0
      func/func_ram_record.h
  5. 18 1
      lib/lib_buffer.c
  6. 2 1
      lib/lib_buffer.h

+ 2 - 1
Inc/main.h

@@ -65,7 +65,8 @@ extern "C" {
 
 #define REMOTE_IAP_UPDATA 		0 	//是否是远程升级
 #define WATCH_DOG_ON 					0   //是否打开看门狗 //0----关闭看门狗SP706   1----打开看门狗SP706
-#define USE_RAM_RECORD    		0   //是否启用RAM数据缓存重发机制
+#define USE_RAM_RECORD    		1   //是否启用RAM数据缓存重发机制
+#define USE_QUEUE_RECORD			1   //是否启用队列数据缓存重发机制
 
 
 #if REMOTE_IAP_UPDATA>0

+ 35 - 10
Src/TerminalSlave485_jt808.c

@@ -29,7 +29,7 @@
 #include "md5c.h"
 #include "cmsis_os.h"
 #include "func_ram_record.h"
-#include "func_fatfs_record.h"
+#include "func_queue_record.h"
 /* Private macro------------------------------------------------------------------------------*/
 /* Private typedef----------------------------------------------------------------------------*/
 #pragma pack(1)
@@ -48,6 +48,7 @@ typedef struct JT808_DATA_OBJ
 	uint32_t back_cnt;					//接收超时计数
 	uint32_t link_cnt;					//连接计数器
 	uint32_t link_ok;						//连接标志位
+
 	
 	SEND_DATA_UNIT_STC send_data;
 }JT808_DATA_OBJ; 
@@ -667,11 +668,23 @@ void jt808_recv_func_DataBack(uint8_t * buf ,uint8_t len)
 		memset((void *)&(jt808_obj.send_data), 0x00, sizeof(jt808_obj.send_data));
 		
 		
+#if  USE_QUEUE_RECORD==1 
+		if(func_record_queue_flash_get() == true)
+		{
+			read_len = func_record_queue_read((void *)&(jt808_obj.send_data), (uint32_t)DATA_UNIT_SIZE);
+		}
+		else
+#endif		
+		
 #if USE_RAM_RECORD==1
-		//从内存数据栈中读取缓冲数据
-		read_len = func_ram_record_delete((void *)&(jt808_obj.send_data), DATA_UNIT_SIZE);			
-#elif  USE_QUEUE_RECORD==1
-		//read_len = func_record_queue_read((void *)&(jt808_obj.send_data), (uint32_t)DATA_UNIT_SIZE);
+		{		
+			//从内存数据栈中读取缓冲数据
+			read_len = func_ram_record_delete((void *)&(jt808_obj.send_data), DATA_UNIT_SIZE);		
+		}
+#else
+		{
+		;
+		}		
 #endif
 		
 		if( read_len != DATA_UNIT_SIZE)
@@ -726,11 +739,23 @@ void jt808_save_send_data(uint8_t * buf ,uint16_t len)
 	
 	if(jt808_obj.send_data.flowID != 0)
 	{
-#if USE_RAM_RECORD==1
-		func_ram_record_write((uint8_t *)&(jt808_obj.send_data) , DATA_UNIT_SIZE);
-#elif  USE_QUEUE_RECORD==1
-		//func_record_queue_write((uint8_t *)&(jt808_obj.send_data) , DATA_UNIT_SIZE);
-#endif
+		
+#if USE_QUEUE_RECORD==1
+		if(func_record_queue_flash_get() == true)
+		{
+				func_record_queue_write((uint8_t *)&(jt808_obj.send_data) , DATA_UNIT_SIZE);
+		}
+		else
+#endif			
+#if USE_RAM_RECORD==1		
+		{
+				func_ram_record_write((uint8_t *)&(jt808_obj.send_data) , DATA_UNIT_SIZE);
+		}
+#else
+		{
+		;
+		}			
+#endif		
 		
 		memset((void *)&(jt808_obj.send_data), 0x00, sizeof(jt808_obj.send_data));
 	}

+ 2 - 14
Src/freertos.c

@@ -463,21 +463,9 @@ void MX_FREERTOS_Init(void)
 	Usart1_TerminalHandle = osThreadCreate(osThread(Uart_Terminal), NULL);
 #endif	
 
-#if USE_FATFS_RECORD==1
-	/* definition and creation of Data_Process */
-	if(func_record_fatfs_isOK() == true)
-	{	
-		osThreadDef(task_record, func_record_fatfs_main, osPriorityNormal, 0, 512 * 4);
-		task_record_Handle = osThreadCreate(osThread(task_record), NULL);
-	}	
-	
-#elif	USE_LFS_RECORD==1	
-	
-		osThreadDef(task_record, func_record_lfs_main, osPriorityNormal, 0, 512 * 16);
-		task_record_Handle = osThreadCreate(osThread(task_record), NULL);
-#elif	USE_RFS_RECORD==1	
+#if	USE_RFS_RECORD==1	
 	
-		osThreadDef(task_record, func_record_queue_main, osPriorityNormal, 0, 512 * 16);
+		osThreadDef(task_record, func_record_queue_main, osPriorityBelowNormal, 0, 512 * 16);
 		task_record_Handle = osThreadCreate(osThread(task_record), NULL);
 #endif	
 

+ 1 - 0
func/func_ram_record.h

@@ -28,6 +28,7 @@ extern "C" {
 #endif
 
 /* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
 #include "stm32f7xx_hal.h"
 #include "fatfs.h"
 /* Private includes ----------------------------------------------------------*/

+ 18 - 1
lib/lib_buffer.c

@@ -1,4 +1,4 @@
-#include "stdio.h"
+#include <stdio.h>
 #include "string.h"
 #include "stdlib.h"
 #include "lib_buffer.h"
@@ -221,3 +221,20 @@ int TBuffer_discard(TBufffer Object, int size)
     // printf("pop = %s\n",(char*)data);   
     return result;
 }
+uint32_t TBuffer_obj_num(TBufffer Object,int obj_size)
+{
+		uint32_t obj_num = 0;
+	
+		obj_num = 0;
+		if(Object->push_size > Object->pop_size)
+		{
+			obj_num = Object->push_size - Object->pop_size;
+			obj_num = obj_num/obj_size;			
+		}
+		
+		return obj_num;
+}
+
+
+
+

+ 2 - 1
lib/lib_buffer.h

@@ -1,6 +1,7 @@
 #ifndef __BUFFER
 #define __BUFFER
 
+#include <stdint.h>
 
 typedef struct
 {
@@ -20,5 +21,5 @@ void TBuffer_Fini(TBuffferOBJ *data);
 int TBuffer_Push(TBufffer Object, const void *data, int size);
 int TBuffer_Peek(TBufffer Object, void *data, int size); //返回实际尺寸
 int TBuffer_Pop(TBufffer Object, void *data, int size);
-
+uint32_t TBuffer_obj_num(TBufffer Object,int obj_size);
 #endif