mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
90 lines
3.3 KiB
Markdown
90 lines
3.3 KiB
Markdown
# PX4 控制台/Shell
|
||
|
||
PX4 enables terminal access to the system through the [MAVLink Shell](../debug/mavlink_shell.md) and the [System Console](../debug/system_console.md).
|
||
|
||
这里将说明它们的主要区别,以及如何使用。
|
||
|
||
<a id="console_vs_shell"></a>
|
||
|
||
## 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](https://github.com/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.
|
||
:::
|
||
|
||
<a href="../debug/system_console.md">系统控制台(System Console)</a>在调试系统无法启动时十分必要,它会在飞控板上电后输出启动日志。
|
||
Since MAVLink provides more flexibility, currently only the [MAVLink Shell](../debug/mavlink_shell.md) is used.
|
||
|
||
The [System Console](../debug/system_console.md) is essential when the system does not boot (it displays the system boot log when power-cycling the board).
|
||
The [MAVLink Shell](../debug/mavlink_shell.md) is much easier to setup, and so is more generally recommended for most debugging.
|
||
|
||
<a id="using_the_console"></a>
|
||
|
||
## 使用控制台/Shell
|
||
|
||
The MAVLink shell/console and the [System Console](../debug/system_console.md) 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](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629410) 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](../modules/modules_main.md) (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`
|
||
:::
|