【移植问题】移植nr_micro_shell输入命令无回显问题

nr_micro_shell是一款为MCU编写的开源命令行工具

问题描述

串口输入命令后有反应,命令能解析,但是没有显示输入的内容。ansi_show_charshell_printf均能正常使用。问题现象如下图所示
请添加图片描述

原因分析和解决方法

配置文件nr_micro_shell_config.h定义了宏#define NR_MICRO_SHELL_SIMULATOR。因为是裸机环境,所以移植时需要注释掉RTOS相关头文件。
在这里插入图片描述
应该直接将这部分代码删掉或注释掉,不要定义宏NR_MICRO_SHELL_SIMULATOR
在这里插入图片描述
因为命令行回显是在文件ansi_port.c中的nr_ansi_common_char_slover函数调用ansi_show_char实现的

void nr_ansi_common_char_slover(ansi_st *ansi, char x)
{
    unsigned int i;

    if (ansi->counter < NR_ANSI_LINE_SIZE - 2) {
        if (ansi->p < (short)(ansi->counter)) {
            for (i = ansi->counter; (short)i > ansi->p; i--) {
                ansi->current_line[i] = ansi->current_line[i - 1];
            }
        }

        ansi->p++;
        ansi->counter++;

        ansi->current_line[ansi->p] = x;

        ansi->current_line[ansi->counter] = '\0';
        if (ansi->p + 1 < (short)(ansi->counter)) {
            shell_printf("\033[1@");
        }

#ifndef NR_MICRO_SHELL_SIMULATOR
        ansi_show_char(x); // 这个地方
#endif
    } else {
        ansi->counter = NR_ANSI_LINE_SIZE - 3;
        if (ansi->p >= (short)(ansi->counter)) {
            ansi->p = ansi->counter - 1;
        }
        ansi->current_line[ansi->counter] = '\0';
    }
}

删除宏后运行正常
请添加图片描述

移植参考以下文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值