mirror of
https://github.com/goldenfishs/MRobot.git
synced 2026-02-04 18:00:19 +08:00
修复mrobot
This commit is contained in:
parent
e47d170066
commit
843936525f
@ -169,7 +169,8 @@ static void uart_rx_callback(void) {
|
|||||||
}
|
}
|
||||||
} else if (ch >= 32 && ch < 127 && ctx.cmd_index < sizeof(ctx.cmd_buffer) - 1) {
|
} else if (ch >= 32 && ch < 127 && ctx.cmd_index < sizeof(ctx.cmd_buffer) - 1) {
|
||||||
ctx.cmd_buffer[ctx.cmd_index++] = ch;
|
ctx.cmd_buffer[ctx.cmd_index++] = ch;
|
||||||
BSP_UART_Transmit(BSP_UART_MROBOT, &ch, 1, false);
|
/* 回显:使用静态变量地址,避免异步发送时局部变量已失效 */
|
||||||
|
BSP_UART_Transmit(BSP_UART_MROBOT, &ctx.uart_rx_char, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BSP_UART_Receive(BSP_UART_MROBOT, &ctx.uart_rx_char, 1, false);
|
BSP_UART_Receive(BSP_UART_MROBOT, &ctx.uart_rx_char, 1, false);
|
||||||
@ -483,9 +484,8 @@ void MRobot_Init(void) {
|
|||||||
/* 创建互斥锁 */
|
/* 创建互斥锁 */
|
||||||
ctx.mutex = xSemaphoreCreateMutex();
|
ctx.mutex = xSemaphoreCreateMutex();
|
||||||
|
|
||||||
/* 初始化状态 */
|
/* 初始化状态(保留已注册的设备) */
|
||||||
memset(ctx.devices, 0, sizeof(ctx.devices));
|
// 注意:不清除 devices 和 device_count,因为其他任务可能已经注册了设备
|
||||||
ctx.device_count = 0;
|
|
||||||
ctx.custom_cmd_count = 0;
|
ctx.custom_cmd_count = 0;
|
||||||
ctx.state = MROBOT_STATE_IDLE;
|
ctx.state = MROBOT_STATE_IDLE;
|
||||||
strcpy(ctx.current_path, "/");
|
strcpy(ctx.current_path, "/");
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
|
/* USER PRIVATE CODE BEGIN */
|
||||||
|
|
||||||
|
/* USER PRIVATE CODE END */
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void {{task_function}}(void *argument) {
|
void {{task_function}}(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|||||||
52
assets/User_code/task/template_task/cli.c
Normal file
52
assets/User_code/task/template_task/cli.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
cli Task
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ----------------------------------------------------------------- */
|
||||||
|
#include "task/user_task.h"
|
||||||
|
/* USER INCLUDE BEGIN */
|
||||||
|
#include "device/mrobot.h"
|
||||||
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
|
/* Private define ----------------------------------------------------------- */
|
||||||
|
/* Private macro ------------------------------------------------------------ */
|
||||||
|
/* Private variables -------------------------------------------------------- */
|
||||||
|
/* USER STRUCT BEGIN */
|
||||||
|
|
||||||
|
/* USER STRUCT END */
|
||||||
|
|
||||||
|
/* Private function --------------------------------------------------------- */
|
||||||
|
/* USER PRIVATE CODE BEGIN */
|
||||||
|
/**
|
||||||
|
* @brief hello 命令回调
|
||||||
|
* @note 命令回调必须返回 0 (pdFALSE) 表示完成,返回非0会继续调用
|
||||||
|
*/
|
||||||
|
static long Cli_Hello(char *buffer, size_t size, const char *cmd) {
|
||||||
|
(void)cmd; /* 未使用cmd,消除警告 */
|
||||||
|
MRobot_Snprintf(buffer, size, "Ciallo~(∠・ω< )⌒★\r\n");
|
||||||
|
return 0; /* 返回0表示命令执行完成 */
|
||||||
|
}
|
||||||
|
/* USER PRIVATE CODE END */
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void Task_cli(void *argument) {
|
||||||
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
|
|
||||||
|
osDelay(CLI_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
|
/* USER CODE INIT BEGIN */
|
||||||
|
/* 初始化 MRobot CLI 系统 */
|
||||||
|
MRobot_Init();
|
||||||
|
MRobot_RegisterCommand("hello", " --hello: 打印问候语\r\n", Cli_Hello, -1);
|
||||||
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
/* USER CODE BEGIN */
|
||||||
|
/* 运行 MRobot 主循环 */
|
||||||
|
MRobot_Run();
|
||||||
|
/* USER CODE END */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
atti_esti:
|
atti_esti:
|
||||||
name: "atti_esti"
|
name: "atti_esti"
|
||||||
frequency: 1000
|
frequency: 1000
|
||||||
delay: 100
|
delay: 0
|
||||||
stack: 512
|
stack: 512
|
||||||
freq_control: false
|
freq_control: false
|
||||||
description: |
|
description: |
|
||||||
@ -16,3 +16,13 @@ atti_esti:
|
|||||||
- 陀螺仪使用前需要校准,校准结果保存在bmi088_cali结构体中
|
- 陀螺仪使用前需要校准,校准结果保存在bmi088_cali结构体中
|
||||||
- 无磁力计版本,适用于干净的电磁环境
|
- 无磁力计版本,适用于干净的电磁环境
|
||||||
- 需要配置PWM通道用于IMU加热控制
|
- 需要配置PWM通道用于IMU加热控制
|
||||||
|
cli:
|
||||||
|
name: "cli"
|
||||||
|
frequency: 500
|
||||||
|
delay: 0
|
||||||
|
stack: 1024
|
||||||
|
freq_control: false
|
||||||
|
description: |
|
||||||
|
命令行接口任务
|
||||||
|
通过串口实现的虚拟终端,配合putty食用更佳
|
||||||
|
需要freertos_cli组件支持,还有mrobot设备驱动
|
||||||
Loading…
Reference in New Issue
Block a user