Renode 常规命令和实例命令

Renode 有两种类型的命令,一种是常规命令,另一种是通过 C# 实例导出的命令。常规命令使用 help 命令查看帮助,实例导出命令直接输入实例名称就可以查看帮助,关键得知道有哪些实例被导出了。

如果在 Renode 窗口输入无法识别的命令,那么 Renode 会输出 ​​No such command or device: xxx​​​。言外之意就是 Renode 支持两种输入,一是​​command​​​;二是​​device​​​。这里所说的常规命令对应 ​​command​​​,实例命令对应 ​​device​​。

zoomdy at 163 dot com

常规命令

在 Renode Monitor 窗口输入 ​​help​​ 就可以获取常规命令列表。

(monitor) help
Available commands:
Name | Description
================================================================================
allowPrivates : allow private fields and properties manipulation.
analyzers : shows available analyzers for peripheral.
commandFromHistory: executes command from history.
createPlatform : creates a platform.
execute : executes a command or the content of a variable.
help : prints this help message or info about specified command.
history : prints command history.
include : loads a monitor script, python code or a plugin class.
log : logs messages.
logFile : sets the output file for logger.
logLevel : sets logging level for backends.
mach : list and manipulate machines available in the environment.
macro : sets a macro.
numbersMode : sets the way numbers are displayed.
path : allows modification of internal 'PATH' variable.
pause : pauses the emulation.
peripherals : prints list of registered and named peripherals.
python : executes the provided python command.
quit : quits the emulator.
require : verifies the existence of a variable.
runMacro : executes a command or the content of a macro.
set : sets a variable.
showAnalyzer : opens a peripheral backend analyzer.
start : starts the emulation.
string : treat given arguments as a single string.
using : expose a prefix to avoid typing full object names.
verboseMode : controls the verbosity of the Monitor.
version : shows version information.
watch : executes a command periodically, showing output in monitor

​help​​​ 后跟随命令名称,就可以查看命令的使用说明。例如要查看 ​​include​​​ 命令的使用说明,在 monitor 窗口输入 ​​help include​​ 。

(monitor) help include
include [ i ]
loads a monitor script, python code or a plugin class.
To load a script you have to provide an existing file name.
Supported file formats:
*.cs - plugin file
*.py - python script
other - monitor script

常规命令在 Monitor.InitCommands 中初始化。命令定义在 renode/src/Infrastructure/src/Emulator/Extensions/UserInterface/Commands 目录下。

C# 实例导出的命令

有部分命令是使用 C# 实例的方式导出的。包括以下命令:

  • machine
  • connector
  • emulation
  • plugins
  • EmulationManager
  • host

还有就是定义在 machine 内的所有外设,创建 machine 后输入 ​​peripherals​​ 就可以看到所有外设,创建 machine 时会自动创建 sysbus 总线外设,因此即使没有添加任何外设,也会有一个 sysbus 外设。其他外设是挂在 sysbus 下的。

输入实例命令名,不带任何参数,就可以查看实例命令的帮助。查看 sysbus 下的外设的帮助,在外设名前加入 ​​sysbus.​​​ ,例如查看 uart1 的帮助,输入 ​​sysbus.uart1​​。

注意:machine 命令只有在创建了 machine 后(执行 mach create 命令后)才有效。

实例命令在 Monitor.InitCommands 中导出,外设实例命令则是在创建外设时导出的。

Bind(Machine.MachineKeyword, () => Machine); // MachineKeyword = "machine"
BindStatic("connector", () => emulationManager.CurrentEmulation.Connector);
BindStatic("emulation", () => Emulation);
BindStatic("plugins", () => TypeManager.Instance.PluginManager);
BindStatic("EmulationManager", () => emulationManager);