• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

examples/04-Apr-2025-678539

include/04-Apr-2025-7745

lib/04-Apr-2025-858648

CMakeLists.txtD04-Apr-2025991 3222

README.mdD04-Apr-20254.8 KiB12084

README.md

1# Renode API
2
3## Server
4
5The server's implementation can be found in this repository in `src/Renode/Network/ExternalControl/ExternalControlServer.cs`.
6
7Besides building Renode from source, the server can be also dynamically compiled into Renode from the Monitor with `i @ExternalControlServer.cs` assuming the current directory contains the source file.
8
9From the Monitor, the server can be started with:
10```
11emulation CreateExternalControlServer "<NAME>" <PORT>
12```
13
14## Client
15
16The client's header, library and examples can be found under `tools/external_control_client` and all further paths starting with `./` will be relative to this directory.
17
18### Header
19
20The Renode API header file is `./include/renode_api.h`.
21
22### Library
23
24The Renode API library sources can be found in the `./lib` directory.
25
26The currently implemented functions from the header file are:
27* `renode_connect`
28* `renode_disconnect`
29* `renode_run_for`
30* `renode_get_current_time`
31* `renode_error_free`
32
33The library itself can be built with CMake using the `./lib/CMakeLists.txt`.
34`librenode_api.a` can be built in the `build` directory from the Renode repository's root directory with:
35```bash
36renode$ mkdir build && cmake -S tools/external_control_client/lib -B build && cmake --build build
37```
38
39### Building
40
41Besides building a library and linking a client to the library, a client can be built with CMake using `./CMakeLists.txt`.
42CMake variables can be used to set:
43* application name (`APP_NAME`)
44* path to the directory containing sources (`APP_SOURCES_DIR`)
45* compile flags (optional `APP_COMPILE_FLAGS`; the default is `-Wall;-Wextra;-Werror`)
46
47For example, `example_client` application with sources in `~/example_client/src` directory can be built in the `build` directory from the Renode repository's root directory with:
48```bash
49renode$ mkdir build && cmake -DAPP_NAME=example_client -DAPP_SOURCES_DIR=~/example_client/src -S tools/external_control_client -B build && cmake --build build
50```
51
52### `run_for` example
53
54The example application using Renode API can be found in `examples/run_for`.
55
56It can be built in the `build` directory from the Renode repository's root directory with:
57```bash
58renode$ mkdir build && cmake -DAPP_NAME=run_for -DAPP_SOURCES_DIR=tools/external_control_client/examples/run_for -S tools/external_control_client -B build && cmake --build build
59```
60
61After starting the server in Renode, the `run_for` application can be used to progress emulation time multiple times with an ability to run it again and connect to the same server.
62
63Following every executed set it will ask whether to continue with the current configuration, defaults to `No`.
64This prompt also has an option (`c` for change) to provide a new time value, using the same format as the CLI argument, with an optional new number of times to run, defaults to 1.
65
66The usage is:
67```
68Usage:
69  ./test_run_for <PORT> <VALUE_WITH_UNIT> [<REPEAT>]
70  where:
71  * <VALUE_WITH_UNIT> is an integer with a time unit, e.g.: '100ms'
72  * accepted time units are 's', 'ms' and 'us' (for microseconds)
73  * <REPEAT> is an optional number of times (default: 1) to run
74  * the simulation for
75```
76
77### `adc` example
78
79The example application using Renode API can be found in `examples/adc`.
80
81It can be built in the `build` directory from the Renode repository's root directory with:
82```bash
83renode$ mkdir build && cmake -DAPP_NAME=adc -DAPP_SOURCES_DIR=tools/external_control_client/examples/adc -S tools/external_control_client -B build && cmake --build build
84```
85
86After starting the server in Renode, the `adc` application can be used multiple times to set ADC channel 0 value.
87
88The usage is:
89```
90Usage:
91  ./adc <PORT> <MACHINE_NAME> <ADC_NAME> <VALUE_WITH_UNIT>
92  where:
93  * <VALUE_WITH_UNIT> is an unsigned integer with a voltage unit, e.g.: '100mV'
94  * accepted voltage units are 'V', 'mV' and 'uV' (for microvolts)
95```
96
97### `gpio` example
98
99The example application using Renode API can be found in `examples/gpio`.
100
101It can be built in the `build` directory from the Renode repository's root directory with:
102```bash
103renode$ mkdir build && cmake -DAPP_NAME=gpio -DAPP_SOURCES_DIR=tools/external_control_client/examples/gpio -S tools/external_control_client -B build && cmake --build build
104```
105
106
107After starting the server in Renode, the `gpio` application can be used in three different modes.
108
109In the first mode, it returns the current state of a pin. This happens when only the required arguments are provided.
110
111In the second mode, the application can be used to set the state of a pin. This happens when the last argument is either `true` or `false`.
112
113Finally, the application can show GPIO state changes as the simulation is running by subscribing to GPIO state change events. This happens when the last argument is set to `event`.
114
115The usage is:
116```
117Usage:
118  ./gpio <PORT> <MACHINE_NAME> <GPIO_NAME> <NUMBER> [true|false|event]
119```
120