Skip to content

Commit 15e0164

Browse files
committed
Update README
1 parent 07cda33 commit 15e0164

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed

README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,143 @@ You can also run ad-hoc Python inside the managed environment:
3333
pixi run python -c "from arena_interface import ArenaInterface; print(ArenaInterface)"
3434
```
3535

36+
If you prefer an interactive shell with the package already available, use:
37+
38+
```sh
39+
pixi shell
40+
python
41+
# or, if you already have IPython available in that environment:
42+
# ipython
43+
```
44+
45+
## Interactive Python / IPython examples
46+
47+
The most convenient way to drive the arena interactively is through the
48+
`ArenaInterface` class.
49+
50+
### Ethernet example
51+
52+
```python
53+
from arena_interface import ArenaInterface
54+
55+
ai = ArenaInterface(debug=True)
56+
ai.set_ethernet_mode("192.168.10.104")
57+
58+
ai.all_on()
59+
ai.all_off()
60+
ai.switch_grayscale(1)
61+
ai.set_refresh_rate(200)
62+
63+
stats = ai.get_perf_stats()
64+
len(stats), stats.hex()[:64]
65+
66+
ai.show_pattern_frame(pattern_id=10, frame_index=0, frame_rate=200)
67+
ai.update_pattern_frame(1)
68+
ai.update_pattern_frame(2)
69+
ai.all_off()
70+
ai.close()
71+
```
72+
73+
### Serial example
74+
75+
```python
76+
from arena_interface import ArenaInterface
77+
78+
with ArenaInterface() as ai:
79+
ai.set_serial_mode("/dev/ttyACM0")
80+
ai.all_on()
81+
ai.all_off()
82+
```
83+
84+
On Windows, use a COM port such as `COM3` instead of `/dev/ttyACM0`.
85+
86+
### Notes on the interactive API
87+
88+
- `set_ethernet_mode("192.168.10.104")` selects Ethernet transport.
89+
- `set_serial_mode("/dev/ttyACM0")` or `set_serial_mode("COM3")` selects serial transport.
90+
- `show_pattern_frame(pattern_id, frame_index, frame_rate=200)` starts
91+
`SHOW_PATTERN_FRAME` mode and displays the initial frame.
92+
- `update_pattern_frame(frame_index)` updates the currently shown pattern frame.
93+
- `get_perf_stats()` returns the raw binary perf payload from the controller.
94+
- `reset_perf_stats()` clears firmware-side perf counters.
95+
- `play_pattern(...)` and `play_pattern_analog_closed_loop(...)` are available
96+
for the older play-pattern flows.
97+
98+
## Command-line usage
99+
100+
There are two convenient ways to use the CLI:
101+
102+
1. Use the predefined Pixi tasks for the common operations.
103+
2. Run the module entry point directly with `pixi run python -m arena_interface ...`.
104+
105+
Inside `pixi shell`, the installed console script is also available directly as
106+
`arena-interface`.
107+
108+
### Discover the CLI
109+
110+
```sh
111+
pixi run help
112+
pixi run python -m arena_interface --help
113+
pixi run python -m arena_interface --ethernet 192.168.10.104 --help
114+
```
115+
116+
Click converts Python command names such as `all_on` into CLI commands such as
117+
`all-on`. The main commands are:
118+
119+
- `all-on`
120+
- `all-off`
121+
- `set-refresh-rate`
122+
- `display-reset`
123+
- `switch-grayscale`
124+
- `reset-perf-stats`
125+
- `get-perf-stats`
126+
- `bench`
127+
128+
### Ethernet command-line examples
129+
130+
```sh
131+
pixi run python -m arena_interface --ethernet 192.168.10.104 all-on
132+
pixi run python -m arena_interface --ethernet 192.168.10.104 all-off
133+
pixi run python -m arena_interface --ethernet 192.168.10.104 set-refresh-rate 200
134+
pixi run python -m arena_interface --ethernet 192.168.10.104 switch-grayscale 1
135+
pixi run python -m arena_interface --ethernet 192.168.10.104 get-perf-stats
136+
pixi run python -m arena_interface --ethernet 192.168.10.104 reset-perf-stats
137+
```
138+
139+
### Serial command-line examples
140+
141+
```sh
142+
pixi run python -m arena_interface --serial /dev/ttyACM0 all-on
143+
pixi run python -m arena_interface --serial /dev/ttyACM0 all-off
144+
```
145+
146+
Windows PowerShell example:
147+
148+
```powershell
149+
pixi run python -m arena_interface --serial COM3 all-on
150+
pixi run python -m arena_interface --serial COM3 all-off
151+
```
152+
153+
### Environment-variable based usage
154+
155+
If you set the transport once, the short Pixi tasks become easier to use:
156+
157+
```sh
158+
export ARENA_ETH_IP=192.168.10.104
159+
pixi run all-on
160+
pixi run all-off
161+
pixi run bench
162+
```
163+
164+
PowerShell equivalent:
165+
166+
```powershell
167+
$env:ARENA_ETH_IP = "192.168.10.104"
168+
pixi run all-on
169+
pixi run all-off
170+
pixi run bench
171+
```
172+
36173
## Quick smoke tests
37174

38175
Before running longer benchmarks, use the `all-on` and `all-off` tasks to make
@@ -111,6 +248,7 @@ Examples:
111248
pixi run bench -- --json-out host_only.jsonl
112249
pixi run bench-full -- --json-out host_plus_stream.jsonl
113250
pixi run bench-full -- --stream-rate 250 --stream-seconds 8 --json-out stream_250hz.jsonl
251+
pixi run python -m arena_interface --ethernet 192.168.10.104 bench --cmd-iters 500 --spf-rate 250
114252
```
115253

116254
## Benchmark progress, timeouts, and failure reporting
@@ -169,6 +307,37 @@ A practical workflow is:
169307
2. Capture QS logs on representative runs or anomalous runs.
170308
3. Use the QS logs to explain why two host-visible results differ.
171309

310+
## Cross-platform notes
311+
312+
The project configuration targets Linux, macOS, and Windows through Pixi, and
313+
the basic host functionality is designed to work across those operating
314+
systems.
315+
316+
What is portable:
317+
318+
- serial control through `pyserial`
319+
- Ethernet control through standard Python sockets
320+
- the Click-based CLI
321+
- the JSON benchmark output
322+
- the `all-on`, `all-off`, and `bench` workflows
323+
324+
What is Linux-specific or Linux-enhanced:
325+
326+
- `TCP_QUICKACK` support
327+
- route and interface metadata captured from `ip route get`
328+
- extra NIC details captured from `/sys/class/net/...`
329+
330+
So the short answer is: yes, the code is intended to work on Linux, macOS, and
331+
Windows, but the Linux runs expose the most low-level socket tuning and network
332+
metadata.
333+
334+
For cross-OS comparisons, the safest approach is:
335+
336+
1. Treat `TCP_NODELAY` as the portable latency knob.
337+
2. Treat `TCP_QUICKACK` as Linux-specific and compare it separately.
338+
3. Use the same benchmark JSON schema everywhere.
339+
4. Use QS logs when you need to explain firmware-side differences.
340+
172341
## Socket latency tuning
173342

174343
The host code exposes both `TCP_NODELAY` and `TCP_QUICKACK` as explicit options.

0 commit comments

Comments
 (0)