# Common Operations

## Running in Development

```bash
bun run tauri dev
```

This command does the following in parallel:

- <span style="white-space: pre-wrap;">Starts the Vite/SvelteKit dev server on </span>`<span class="editor-theme-code">http://localhost:1420</span>`
- Compiles the Rust backend (first run takes several minutes)
- Opens the Tauri application window

<span style="white-space: pre-wrap;">The frontend supports hot module replacement — changes to </span>`<span class="editor-theme-code">.svelte</span>`<span style="white-space: pre-wrap;"> and </span>`<span class="editor-theme-code">.ts</span>`<span style="white-space: pre-wrap;"> files appear immediately without restarting. Rust changes require a recompile, which Tauri handles automatically but takes longer.</span>

<p class="callout info">**First build warning:**<span style="white-space: pre-wrap;"> the initial </span>`<span class="editor-theme-code">cargo build</span>`<span style="white-space: pre-wrap;"> downloads and compiles all Rust dependencies including GStreamer bindings. This can take 5–15 minutes depending on your machine. Subsequent builds are fast due to incremental compilation.</span></p>

### Building for Production

<p class="callout danger">One of Tauri's dependencies, libc (the C standard library), is forward compatible but not backward compatible</p>

The demo laptop has an old verison of linux so you need to use docker to build the app if you want to use it in it.  
The first time you build you have to build docker first:

```bash
sudo docker build -t tauri-ubuntu2204 .
```

For building the app in linux the subsequent times for the demo laptop use the command:

```bash
sudo docker run --rm \
    -v $(pwd):/app \
    -v tauri-cargo-cache:/root/.cargo/registry \
    tauri-ubuntu2204
```

<p class="callout info">You don't have to docker build every time, just the first time and if you change anything in the dockerfile</p>

## Testing Without Rover Hardware

You do not need a physical rover to develop or test the UI. The backend includes a full simulator.

#### Video Feeds

**Fake camera**

`<span class="editor-theme-code">fake_camera_gstreamer/</span>`<span style="white-space: pre-wrap;"> — a GStreamer-based test source that sends H.264 RTP streams on the expected UDP ports (4500, 4501, 4502). It can be run from by running the following command from </span>`<span class="editor-theme-code">erc-software-basestation/fake_camera_gstreamer/</span>`

```bash
cargo run --bin fake_camera_gstreamer
```

**Stream from Webcam**

To test the video feed with your webcam open a terminal and use the following command.

Linux

```bash
gst-launch-1.0 v4l2src ! videoconvert ! x264enc tune=zerolatency bitrate=800 speed-preset=ultrafast ! rtph264pay ! udpsink host=127.0.0.1 port=4500
```

Windows

```bash
gst-launch-1.0 ksvideosrc ! videoconvert ! x264enc tune=zerolatency bitrate=800 speed-preset=ultrafast ! rtph264pay ! udpsink host=127.0.0.1 port=4500
```

#### Dummy data streams (rover telemetry)

<span style="white-space: pre-wrap;">Once the app is running, go to </span>`<span class="editor-theme-code">/settings</span>`<span style="white-space: pre-wrap;"> and use the simulator controls:</span>

- **Start dummy general stream**<span style="white-space: pre-wrap;"> — starts the full multi-stream simulator sending fake IMU, GPS, arm, drive, and sensor data to the app over UDP. Use this to test all telemetry UI at once.</span>
- **Start dummy IMU stream**<span style="white-space: pre-wrap;"> — starts an IMU-only stream with no jitter or packet loss. Use this for isolated IMU component testing.</span>
- **Stop dummy general/IMU stream**<span style="white-space: pre-wrap;"> — stops whichever simulator is running.</span>

The simulator runs inside the Rust backend so it works regardless of whether a rover is connected.

## Connecting to the Rover

<p class="callout danger">**TODO**</p>

The base station listens for incoming UDP packets on the address set on lib.rs, must set static address in laptop settings