Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 7b961cc

Browse files
committed
driver: nanokvm network driver
1 parent 5300757 commit 7b961cc

10 files changed

Lines changed: 1266 additions & 0 deletions

File tree

docs/source/reference/package-apis/drivers/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Drivers that handle media streams:
5959

6060
* **[UStreamer](ustreamer.md)** (`jumpstarter-driver-ustreamer`) - Video
6161
streaming functionality
62+
* **[NanoKVM](nanokvm.md)** (`jumpstarter-driver-nanokvm`) - NanoKVM remote KVM control
6263

6364
### Debug and Programming Drivers
6465

@@ -94,6 +95,7 @@ flashers.md
9495
http.md
9596
http-power.md
9697
iscsi.md
98+
nanokvm.md
9799
network.md
98100
opendal.md
99101
power.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../packages/jumpstarter-driver-nanokvm/README.md
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__/
2+
.coverage
3+
coverage.xml
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# NanoKVM Driver
2+
3+
`jumpstarter-driver-nanokvm` provides comprehensive support for [NanoKVM](https://github.com/sipeed/NanoKVM) devices, enabling remote KVM (Keyboard, Video, Mouse) control over the network.
4+
5+
## Features
6+
7+
- **Video Streaming**: Access live video feed from the connected device
8+
- **Snapshot Capture**: Take screenshots of the video stream
9+
- **Keyboard Control**: Send text and keystrokes via HID emulation
10+
- **Mouse Control**: Full mouse support via WebSocket
11+
- Absolute positioning (0-65535 coordinate system)
12+
- Relative movement
13+
- Left/right/middle button clicks
14+
- Mouse wheel scrolling
15+
- **Device Management**: Get device info, reboot the NanoKVM
16+
- **Composite Driver**: Access all functionality through a unified interface
17+
18+
## Installation
19+
20+
```{code-block} console
21+
:substitutions:
22+
$ pip3 install --extra-index-url {{index_url}} jumpstarter-driver-nanokvm
23+
```
24+
25+
## Configuration
26+
27+
### Basic Configuration
28+
29+
```yaml
30+
export:
31+
nanokvm:
32+
type: jumpstarter_driver_nanokvm.driver.NanoKVM
33+
config:
34+
host: "nanokvm.local" # Hostname or IP address
35+
username: "admin" # Default NanoKVM web interface username
36+
password: "admin" # Default NanoKVM web interface password
37+
```
38+
39+
### Advanced Configuration
40+
41+
```yaml
42+
export:
43+
nanokvm:
44+
type: jumpstarter_driver_nanokvm.driver.NanoKVM
45+
config:
46+
host: "192.168.1.100"
47+
username: "admin"
48+
password: "your-password"
49+
# Optional: SSH access for serial console (future feature)
50+
enable_serial: false
51+
ssh_username: "root"
52+
ssh_password: "root"
53+
ssh_port: 22
54+
```
55+
56+
### Config Parameters
57+
58+
| Parameter | Description | Type | Required | Default |
59+
| -------------- | ------------------------------------------ | ----- | -------- | ------- |
60+
| host | NanoKVM hostname or IP address | str | yes | |
61+
| username | Web interface username | str | no | "admin" |
62+
| password | Web interface password | str | no | "admin" |
63+
| enable_serial | Enable serial console access via SSH | bool | no | false |
64+
| ssh_username | SSH username for serial console | str | no | "root" |
65+
| ssh_password | SSH password for serial console | str | no | "root" |
66+
| ssh_port | SSH port for serial console | int | no | 22 |
67+
68+
## Architecture
69+
70+
The NanoKVM driver is a composite driver that provides three main interfaces:
71+
72+
1. **video**: Video streaming and snapshot capture
73+
2. **hid**: Keyboard and mouse HID control
74+
3. **serial**: Serial console access (optional, future feature)
75+
76+
## API Reference
77+
78+
### NanoKVMClient
79+
80+
```{eval-rst}
81+
.. autoclass:: jumpstarter_driver_nanokvm.client.NanoKVMClient()
82+
:members: get_info, reboot
83+
```
84+
85+
### NanoKVMVideoClient
86+
87+
```{eval-rst}
88+
.. autoclass:: jumpstarter_driver_nanokvm.client.NanoKVMVideoClient()
89+
:members: snapshot
90+
```
91+
92+
### NanoKVMHIDClient
93+
94+
```{eval-rst}
95+
.. autoclass:: jumpstarter_driver_nanokvm.client.NanoKVMHIDClient()
96+
:members: paste_text, press_key, reset_hid, mouse_move_abs, mouse_move_rel, mouse_click, mouse_scroll
97+
```
98+
99+
## CLI Usage
100+
101+
The NanoKVM driver provides CLI commands accessible through the `jmp shell` command:
102+
103+
### Main Commands
104+
105+
```bash
106+
# Get device information
107+
j nanokvm info
108+
109+
# Reboot the NanoKVM device (with confirmation)
110+
j nanokvm reboot
111+
```
112+
113+
### Video Commands
114+
115+
```bash
116+
# Take a snapshot (saves to snapshot.jpg by default)
117+
j nanokvm video snapshot
118+
119+
# Take a snapshot with custom filename
120+
j nanokvm video snapshot my_screenshot.jpg
121+
```
122+
123+
### HID Commands
124+
125+
#### Keyboard Commands
126+
127+
```bash
128+
# Paste text via keyboard HID
129+
j nanokvm hid paste "Hello, World!"
130+
131+
# Send commands with newline (use $'...' syntax in bash for escape sequences)
132+
j nanokvm hid paste $'root\n'
133+
134+
# Or use double backslash
135+
j nanokvm hid paste "root\\n"
136+
137+
# Send multiple lines
138+
j nanokvm hid paste $'ls -la\ndate\n'
139+
140+
# Press a single key
141+
j nanokvm hid press "a"
142+
143+
# Press special keys
144+
j nanokvm hid press $'\n' # Enter
145+
j nanokvm hid press $'\t' # Tab
146+
147+
# Reset HID subsystem if it's not responding
148+
j nanokvm hid reset
149+
```
150+
151+
#### Mouse Commands
152+
153+
```bash
154+
# Move mouse to absolute coordinates (0-65535, scaled to screen)
155+
j nanokvm hid mouse move 32768 32768 # Center of screen
156+
157+
# Move mouse relatively (-127 to 127)
158+
j nanokvm hid mouse move-rel 50 50 # Move right and down
159+
160+
# Click at current position (default: left button)
161+
j nanokvm hid mouse click
162+
163+
# Click with specific button
164+
j nanokvm hid mouse click --button right
165+
166+
# Click at specific coordinates
167+
j nanokvm hid mouse click --x 32768 --y 32768 --button left
168+
169+
# Scroll (default: down 5 units)
170+
j nanokvm hid mouse scroll
171+
172+
# Scroll up
173+
j nanokvm hid mouse scroll --dy 5
174+
175+
# Scroll down
176+
j nanokvm hid mouse scroll --dy -5
177+
```
178+
179+
### Example Session
180+
181+
```bash
182+
# Connect to the exporter
183+
jmp shell -l my=device
184+
185+
# Inside the shell, use the commands
186+
j nanokvm info
187+
j nanokvm video snapshot my_screen.jpg
188+
j nanokvm hid paste "echo 'Hello from NanoKVM'\n"
189+
```
190+
191+
## Usage Examples
192+
193+
### Basic Setup
194+
195+
```python
196+
image = nanokvm.video.snapshot()
197+
image.save("snapshot.jpg")
198+
print(f"Snapshot size: {image.size}")
199+
```
200+
201+
### Keyboard Control
202+
203+
```python
204+
# Paste text to the connected device
205+
nanokvm.hid.paste_text("Hello from Jumpstarter!\n")
206+
207+
# Send commands
208+
nanokvm.hid.paste_text("ls -la\n")
209+
210+
# Press individual keys
211+
nanokvm.hid.press_key("a")
212+
nanokvm.hid.press_key("\n") # Enter
213+
nanokvm.hid.press_key("\t") # Tab
214+
```
215+
216+
### Mouse Control
217+
218+
```python
219+
# Move mouse to center of screen
220+
nanokvm.hid.mouse_move_abs(32768, 32768)
221+
222+
# Click left button
223+
nanokvm.hid.mouse_click("left")
224+
225+
# Click at specific coordinates
226+
nanokvm.hid.mouse_click("left", x=32768, y=16384)
227+
228+
# Move mouse relatively
229+
nanokvm.hid.mouse_move_rel(50, 50) # Move right and down
230+
231+
# Scroll up
232+
nanokvm.hid.mouse_scroll(0, 5)
233+
234+
# Scroll down
235+
nanokvm.hid.mouse_scroll(0, -5)
236+
```
237+
238+
### Device Management
239+
240+
```python
241+
# Get device info
242+
info = nanokvm.get_info()
243+
print(f"Device: {info['mdns']}")
244+
print(f"IPs: {info['ips']}")
245+
print(f"Application version: {info['application']}")
246+
247+
# Reset HID
248+
nanokvm.hid.reset_hid()
249+
```
250+
251+
252+
## Character Support for paste_text()
253+
254+
The `paste_text()` method supports a limited character set due to HID keyboard constraints:
255+
256+
- Alphanumeric: `A-Z`, `a-z`, `0-9`
257+
- Punctuation: `` `~!@#$%^&*()-_=+[]{}\|;:'",.<>/? ``
258+
- Whitespace: Tab (`\t`), Newline (`\n`), Space
259+
- Not supported: Extended Unicode, emoji, special control characters
260+
261+
262+
## Related Documentation
263+
264+
- [NanoKVM GitHub](https://github.com/sipeed/NanoKVM)
265+
- [python-nanokvm Library](https://github.com/puddly/python-nanokvm)
266+
- [Jumpstarter Documentation](https://jumpstarter.dev)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: jumpstarter.dev/v1alpha1
2+
kind: ExporterConfig
3+
metadata:
4+
namespace: default
5+
name: demo
6+
endpoint: grpc.jumpstarter.192.168.0.203.nip.io:8082
7+
token: "<token>"
8+
export:
9+
nanokvm:
10+
type: jumpstarter_driver_nanokvm.driver.NanoKVM
11+
config:
12+
host: "192.168.1.110" # or IP address like "192.168.1.100"
13+
username: "admin"
14+
password: "admin"
15+
# Optional: Enable serial console access via SSH
16+
# enable_serial: true
17+
# ssh_username: "root"
18+
# ssh_password: "root"
19+
# ssh_port: 22
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""NanoKVM driver for Jumpstarter
2+
3+
This package provides support for NanoKVM devices, including:
4+
- Video streaming and snapshot capture
5+
- Keyboard and mouse HID control
6+
- Serial console access (optional)
7+
"""
8+
9+
from .driver import NanoKVM, NanoKVMHID, NanoKVMVideo
10+
11+
__all__ = ["NanoKVM", "NanoKVMVideo", "NanoKVMHID"]
12+
13+

0 commit comments

Comments
 (0)