PX4 控制台/Shell
PX4 enables terminal access to the system through the MAVLink Shell and the System Console.
这里将说明它们的主要区别,以及如何使用。
System Console vs. Shells
The PX4 System Console provides low-level access to the system, debug output and analysis of the system boot process.
There is just one System Console, which runs on one specific UART (the debug port, as configured in NuttX), and is commonly attached to a computer via an FTDI cable (or some other debug adapter like a Dronecode probe).
- Used for low-level debugging/development: bootup, NuttX, startup scripts, board bringup, development on central parts of PX4 (e.g. uORB).
- 更具体一点,这里是包括自启动的用户应用在内的整个PX4系统下所有启动过程唯一的输出位置。
Shell 提供对系统的上层访问能力:
- 用于执行基础的模块调试运行命令。
- Only directly display the output of modules you start.
- Cannot directly display the output of tasks running on the work queue.
- 在 PX4 系统无法启动时无助于调试(它并没有运行)。
INFO
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)在调试系统无法启动时十分必要,它会在飞控板上电后输出启动日志。 Since MAVLink provides more flexibility, currently only the MAVLink Shell is used.
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.
sh
nsh> ls
nsh> free
nsh> dmesg
Below are a couple of commands which can be used in the NuttShell to get insights of the system.
此 NSH 命令提供剩余的可用内存:
sh
free
top命令显示每个应用成虚使用的堆栈情况:
sh
top
注意堆栈使用量是通过堆栈着色计算的,并且是任务开始以来的最大值(不是当前使用量)。
要查看工作队列的运行抢空以及运行速度,使用:
sh
work_queue status
调试 uORB 主题:
sh
uorb top
检查特定的 uORB 主题:
sh
listener <topic_name>
Many other system commands and modules are listed in the Modules and Command Reference (e.g. top
, listener
, etc.).
TIP
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