# UDP Output

The UDP Output sends actuator positions over a UDP network connection. It provides the same level of configurability as the Serial Output but transmits data over the network instead of a serial port. This output is designed for custom or DIY motion controllers that accept UDP packets, or for sending motion data to another PC or application over the network.

---

## When to Use This

Use the UDP Output when:

- Your motion controller accepts data over a network connection (not serial).
- You want to send motion data to a controller on a different machine.
- You're building a custom integration that reads position data from UDP packets.
- Your controller is not directly supported by one of the dedicated outputs (M4S UDP, YawVR).

---

## Setup Steps

1. Ensure your controller/destination device is on the same network as your PC.
2. In DR Sim Manager, go to the **Outputs** tab and click the **+** tab.
3. Select **UDP Output** from the list.
4. Enter the **IP address** and **port** of your destination device.
5. Set the **axis count** and **position bits** to match your controller's protocol.
6. Choose the **output type** (Binary, Decimal, or Hexadecimal).
7. For each axis, set the **prefix**, **suffix**, and **invert** options as needed.
8. Optionally set **startup** and **shutdown strings**.

---

## Settings

### Network Settings

- **IP Address** — The destination IP address of your controller or receiving application.
- **Port** — The destination UDP port number.

### Output Settings

- **Axis Count** — Number of axes to transmit (default: 1).
- **Position Bits** — Resolution of each position value in bits (default: 8). Higher values give finer positioning.
- **Output Type** — Data format for position values:
  - **Binary** — Raw binary encoding.
  - **Decimal** — ASCII decimal numbers.
  - **Hexadecimal** — ASCII hex numbers.
- **Output Rate** — How frequently position updates are sent, in milliseconds (default: 2 ms).

### Startup / Shutdown Strings

- **Startup String** — A byte string sent once when the output connects. Useful for initializing your controller.
- **Shutdown String** — A byte string sent once when the output disconnects. Useful for parking or disabling motors.

Both strings support the same special notation as the Serial Output:

- **Hex bytes** — `0xFF` notation for raw byte values.
- **ASCII codes** — `<13>` notation for specific ASCII characters.
- **Plain text** — Any other characters are sent as-is.

---

## Axis Mapping

For each axis, you can configure:

- **Device** — The sim component to read from.
- **Actuator** — Which actuator output to send.
- **Prefix** — Bytes to prepend before the position value.
- **Suffix** — Bytes to append after the position value.
- **Invert** — Reverse the direction of this axis.

The packet structure is identical to the [Serial Output](serial-output.md) — each axis consists of **Prefix + Position Value + Suffix**, and all axes are combined into a single UDP packet.

---

## Firewall Notes

DR Sim Manager sends **outgoing** UDP packets. Most firewalls allow outgoing UDP by default, but if your controller is not receiving data:

1. Check **Windows Firewall** — Add an exception for DR Sim Manager or allow outbound traffic on the configured port.
2. Check your **router/switch** — Ensure UDP traffic is not being blocked between the PC and the controller.
3. If the controller is on the **same machine** (localhost), use IP address `127.0.0.1`.

---

## Troubleshooting

### Controller not receiving data

1. **Check IP address and port** — Verify they match the controller's listening address and port.
2. **Check firewall** — Ensure outbound UDP is allowed on the configured port.
3. **Check network connectivity** — Use `ping` to verify the destination is reachable.
4. **Check output type** — Ensure Binary/Decimal/Hexadecimal matches what the controller expects.

### Position values seem wrong

- Verify **Position Bits** matches the controller's expected resolution.
- Check prefix/suffix configuration — unexpected bytes in the packet can cause parsing errors on the receiving end.
- DR Sim Manager sends binary values in **big-endian** (most significant byte first) format.

### Data is being sent but controller doesn't respond

- Use a network packet capture tool (such as Wireshark) to verify the packets are arriving at the destination with the correct content.
- Verify the controller is actively listening on the configured port.
