PX4 控制台/Shell
PX4 enables terminal access to the system through the MAVLink Shell and the System Console. DroneCAN peripheral nodes running PX4 firmware can also be accessed through the DroneCAN Shell (it can't be used to access the flight controller).
这里将说明它们的主要区别,以及如何使用。
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 Zubax BugFace BF1).
- 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.
There can be several shells, either running on a dedicated UART, or tunnelled over a link such as MAVLink or DroneCAN. Most boards use the MAVLink Shell; peripheral nodes with only a CAN connection can use the DroneCAN Shell (requires firmware built with CONFIG_UAVCANNODE_COMMAND_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, DroneCAN Shell, and System Console are all 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> dmesgBelow are a couple of commands which can be used in the NuttShell to get insights of the system.
此 NSH 命令提供剩余的可用内存:
freetop命令显示每个应用成虚使用的堆栈情况:
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.).
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