Просмотр исходного кода

add:提交一个cmux跑通版本(发现heap3有问题)

Dozingfiretruck 4 лет назад
Родитель
Сommit
287fa39ea3
4 измененных файлов с 35 добавлено и 26 удалено
  1. 16 7
      app/port/luat_shell_air101.c
  2. BIN
      lib/libapp.a
  3. BIN
      lib/libwmarch.a
  4. 19 19
      src/os/rtos/include/FreeRTOSConfig.h

+ 16 - 7
app/port/luat_shell_air101.c

@@ -31,14 +31,19 @@ static int16_t luat_shell_uart_cb(uint16_t len, void* user_data){
 	if(uartid >= 100)
 	{
 		int l = 1;
-		while (l > 0) {
+		while (l > 0 && l <= 512) {
 			l = luat_uart_read(0, buff, 512);
 			//printf("uart read buff %d %s\n", l, buff);
-			if (l > 0){
+			if (l > 0 && l <= 512){
 				// luat_shell_push(buff, l);
-				uart_data* send_buf = (uart_data*)luat_heap_malloc(sizeof(uart_data)+l);
+				// 多一个字节放\0
+				uart_data* send_buf = (uart_data*)luat_heap_malloc(sizeof(uart_data)+l+1);
+				if(send_buf == NULL)
+					break;
+				
 				send_buf->len = l;
-    			memcpy(send_buf->buff, buff, l);
+    			memmove(send_buf->buff, buff, l);
+				send_buf->buff[l] = 0; // 放个0x0, 确认一下
 				tls_os_queue_send(shell_queue, (void *)send_buf, sizeof(uart_data)+l);
 			}
 		}
@@ -48,9 +53,13 @@ static int16_t luat_shell_uart_cb(uint16_t len, void* user_data){
 
 static void luat_shell(void *sdata){
 	uart_data* receive_buf;
+	// char* receive_buf;
+	int ret = 0;
 	while (1) {
-		tls_os_queue_receive(shell_queue, (void **) &receive_buf, 0, 0);
-		// printf("uart read buff %s\n", (char*)msg);
+		ret = tls_os_queue_receive(shell_queue, (void **) &receive_buf, 0, 0);
+		if (ret) {
+			break;
+		}
 		luat_shell_push(receive_buf->buff, receive_buf->len);
 		luat_heap_free(receive_buf);
 	}
@@ -60,7 +69,7 @@ static void luat_shell(void *sdata){
 static OS_STK __attribute__((aligned(4))) 			TaskStartStk[TASK_START_STK_SIZE] = {0};
 void luat_shell_poweron(int _drv) {
     tls_uart_rx_callback_register(0, luat_shell_uart_cb, NULL);
-	tls_os_queue_create(&shell_queue, 512);
+	tls_os_queue_create(&shell_queue, 1024);
 	tls_os_task_create(NULL, NULL,
 				luat_shell,
 				NULL,


BIN
lib/libwmarch.a


+ 19 - 19
src/os/rtos/include/FreeRTOSConfig.h

@@ -68,28 +68,28 @@
  * See http://www.freertos.org/a00110.html.
  *----------------------------------------------------------*/
 
-#define configUSE_PREEMPTION		1	//使用抢先式内核
-#define configUSE_IDLE_HOOK			1	//使用空闲钩子
-#define configUSE_TICK_HOOK			1	//不使用时间片钩子
-
-#define configCPU_CLOCK_HZ			( ( unsigned long ) 40000000 )	/* =12.0MHz xtal multiplied by 5 using the PLL. *///内部处理器执行频率
-
-#define configTICK_RATE_HZ			( ( portTickType ) 1000u )	//时间片中断的频率
-#define configMAX_PRIORITIES		( ( unsigned portBASE_TYPE ) 63)	//应用程序中可用优先级的数
-#define configMINIMAL_STACK_SIZE	( ( unsigned short ) 90 )	//空闲任务使用的堆栈大
-#define configTOTAL_HEAP_SIZE		( ( size_t ) 12 * 1024 )		//内核中可用的RAM数量,heap2使用
-#define configMAX_TASK_NAME_LEN		( 8 )	//创建任务名称最大允许长度
-#define configUSE_TRACE_FACILITY	0		//是否使用可视化追踪
-#define configUSE_16_BIT_TICKS		0	//定义portTickType
-#define configIDLE_SHOULD_YIELD		1	//讲阻止空闲任务让出时间直到他的时间片用完
-#define configUSE_HEAP3				1
+#define configUSE_PREEMPTION		1	//使锟斤拷锟斤拷锟斤拷式锟节猴拷
+#define configUSE_IDLE_HOOK			1	//使锟矫匡拷锟叫癸拷锟斤拷
+#define configUSE_TICK_HOOK			1	//锟斤拷使锟斤拷时锟斤拷片锟斤拷锟斤拷
+
+#define configCPU_CLOCK_HZ			( ( unsigned long ) 40000000 )	/* =12.0MHz xtal multiplied by 5 using the PLL. *///锟节诧拷锟斤拷锟斤拷锟斤拷执锟斤拷频锟斤拷
+
+#define configTICK_RATE_HZ			( ( portTickType ) 1000u )	//时锟斤拷片锟叫断碉拷频锟斤拷
+#define configMAX_PRIORITIES		( ( unsigned portBASE_TYPE ) 63)	//应锟矫筹拷锟斤拷锟叫匡拷锟斤拷锟斤拷锟饺硷拷锟斤拷锟斤拷
+#define configMINIMAL_STACK_SIZE	( ( unsigned short ) 90 )	//锟斤拷锟斤拷锟斤拷锟斤拷使锟矫的讹拷栈锟斤拷
+#define configTOTAL_HEAP_SIZE		( ( size_t ) 12 * 1024 )		//锟节猴拷锟叫匡拷锟矫碉拷RAM锟斤拷锟斤拷,heap2使锟斤拷
+#define configMAX_TASK_NAME_LEN		( 8 )	//锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
+#define configUSE_TRACE_FACILITY	0		//锟角凤拷使锟矫匡拷锟接伙拷追锟斤拷
+#define configUSE_16_BIT_TICKS		0	//锟斤拷锟斤拷portTickType
+#define configIDLE_SHOULD_YIELD		1	//锟斤拷锟斤拷止锟斤拷锟斤拷锟斤拷锟斤拷锟矫筹拷时锟斤拷直锟斤拷锟斤拷锟斤拷时锟斤拷片锟斤拷锟斤拷
+#define configUSE_HEAP3				0
 
 #define configQUEUE_REGISTRY_SIZE 	0
-#define configSEMAPHORE_INIT_VALUE	5	//创建信号量的最大计数
+#define configSEMAPHORE_INIT_VALUE	5	//锟斤拷锟斤拷锟脚猴拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
 
 /* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 		0	//不使用合作轮转式程序
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )	//合作式应用程序中可用的优先级数
+#define configUSE_CO_ROUTINES 		0	//锟斤拷使锟矫猴拷锟斤拷锟斤拷转式锟斤拷锟斤拷
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )	//锟斤拷锟斤拷式应锟矫筹拷锟斤拷锟叫匡拷锟矫碉拷锟斤拷锟饺硷拷锟斤拷
 
 #define configTIMER_TASK_STACK_DEPTH 400
 
@@ -108,7 +108,7 @@ to exclude the API function. */
 #define configUSE_MUTEXES               1
 #define configUSE_RECURSIVE_MUTEXES     1
 
-#define INCLUDE_xTaskGetCurrentTaskHandle   1 //可以获取当前任务
+#define INCLUDE_xTaskGetCurrentTaskHandle   1 //锟斤拷锟皆伙拷取锟斤拷前锟斤拷锟斤拷
 
 
 #endif /* FREERTOS_CONFIG_H */