# PX4 控制台/Shell

用户可以通过 MAVLink Shell系统控制台 访问 PX4 终端。

这里将说明它们的主要区别,以及如何使用。

# System Console vs. Shells

PX4_系统控制台_提供对底层访问的能力,输出调试信息和分析系统启动过程分析。

只有一个_系统控制台_,它运行在特定的UART上(调试端口,如Nuttx中配置),并且通常通过FTDI电缆(或者其他的一些调试器,如Dronecode probe (opens new window))连接到计算机。

  • 使用_底层陶氏/开发_:bootup,NuttX,启动脚本,飞控板启动,PX4核心部分的开发(例如uORB)。
  • 更具体一点,这里是包括自启动的用户应用在内的整个PX4系统下所有启动过程唯一的输出位置。

Shell 提供对系统的上层访问能力:

  • 用于执行基础的模块调试运行命令。
  • 只_直接_显示你启动的模块输出。
  • 无法_直接_显示运行在工作队列上的任务输出。
  • 在 PX4 系统无法启动时无助于调试(它并没有运行)。

注解

The dmesg command is now available through the shell on some boards, enabling much lower level debugging than previously possible. For example, with dmesg -f & you also see the output of background tasks.

系统控制台(System Console)在调试系统无法启动时十分必要,它会在飞控板上电后输出启动日志。 但是 MAVLink Shell 则更加易于配置使用,因此通常都推荐用它调试。

The System Console is essential when the system does not boot (it displays the system boot log when power-cycling the board). The MAVLink Shell is much easier to setup, and so is more generally recommended for most debugging.

# 使用控制台/Shell

The MAVLink shell/console and the System Console are used in much the same way.

For example, type ls to view the local file system, free to see the remaining free RAM, dmesg to look at boot output.

nsh> ls
nsh> free
nsh> dmesg

瞎main是一些可以在NuttShell (opens new window)中使用的命令来深入了解系统。

此 NSH 命令提供剩余的可用内存:

free

top命令显示每个应用成虚使用的堆栈情况:

top

注意堆栈使用量是通过堆栈着色计算的,并且是任务开始以来的最大值(不是当前使用量)。

要查看工作队列的运行抢空以及运行速度,使用:

work_queue status

调试 uORB 主题:

uorb top

检查特定的 uORB 主题:

listener <topic_name>

Many other system commands and modules are listed in the Modules and Command Reference (e.g. top, listener, etc.).

提示

Some commands may be disabled on some boards (i.e. the some modules are not included in firmware for boards with RAM or FLASH constraints). In this case you will see the response: command not found