# fohhn/fohhn-net-udp-to-serial architecture

> Architecture diagram of the GitHub repository fohhn/fohhn-net-udp-to-serial, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fohhn/fohhn-net-udp-to-serial
- Repository: https://github.com/fohhn/fohhn-net-udp-to-serial

## Overview

This utility is a Linux UDP server that forwards Fohhn-Net messages between a network client and a serial device. Its principal workflow starts with command-line configuration, initializes the serial port and UDP listener, then selects between incoming UDP requests and serial replies. FDCP buffer logic filters requests and collects replies. The graph reflects calls visible in the sampled source and capabilities documented in the README; no unsampled runtime subsystem is assumed.

Main entry points: [`main.c`](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/main.c) (CLI and event loop), [`serial.c`](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/serial.c) (Serial port), [`udp.c`](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/udp.c) (UDP listener), [`fdcp_forward.c`](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/fdcp_forward.c) (FDCP buffers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Forwarding runtime"]
  node_cli["CLI and event loop<br/>[main.c]"]
end

subgraph group_transport["Transport adapters"]
  node_udp_transport["UDP listener<br/>[udp.c]"]
  node_serial_transport["Serial port<br/>[serial.c]"]
end

subgraph group_protocol["FDCP framing"]
  node_fdcp["FDCP buffers<br/>[fdcp_forward.c]"]
end

node_operator(("Operator"))
node_udp_client(("UDP client"))
node_serial_device(("Serial device"))

node_operator -->|"configures"| node_cli
node_cli -->|"clears buffers"| node_fdcp
node_cli -->|"initializes port"| node_serial_transport
node_cli -->|"starts listener"| node_udp_transport
node_cli -->|"polls socket"| node_udp_transport
node_cli -->|"polls port"| node_serial_transport
node_udp_transport -->|"receives datagrams"| node_udp_client
node_serial_transport -->|"reads and writes"| node_serial_device
node_cli -->|"receives request"| node_udp_transport
node_cli -->|"filters request"| node_fdcp
node_cli -->|"writes request"| node_serial_transport
node_cli -->|"reads reply"| node_serial_transport
node_cli -->|"frames reply"| node_fdcp
node_cli -->|"sends reply"| node_udp_client

click node_cli "https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/main.c"
click node_udp_transport "https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/udp.c"
click node_serial_transport "https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/serial.c"
click node_fdcp "https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/fdcp_forward.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_udp_client toneBlue
class node_udp_transport,node_serial_transport toneAmber
class node_fdcp toneMint
class node_operator,node_serial_device toneIndigo
```

## Components

### Forwarding runtime

- [CLI and event loop](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/main.c): `main.c`

### Transport adapters

- [UDP listener](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/udp.c): `udp.c`
- [Serial port](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/serial.c): `serial.c`

### FDCP framing

- [FDCP buffers](https://github.com/fohhn/fohhn-net-udp-to-serial/blob/master/fdcp_forward.c): `fdcp_forward.c`

### Other components

- **Operator**
- **UDP client**
- **Serial device**

## Connections

- Operator → CLI and event loop: configures (evidence: `main.c`)
- CLI and event loop → FDCP buffers: clears buffers (evidence: `main.c`)
- CLI and event loop → Serial port: initializes port (evidence: `main.c`)
- CLI and event loop → UDP listener: starts listener (evidence: `main.c`)
- CLI and event loop → UDP listener: polls socket (evidence: `main.c`)
- CLI and event loop → Serial port: polls port (evidence: `main.c`)
- UDP listener → UDP client: receives datagrams (evidence: `udp.c`)
- Serial port → Serial device: reads and writes (evidence: `serial.c`)
- CLI and event loop → UDP listener: receives request (evidence: `main.c`)
- CLI and event loop → FDCP buffers: filters request (evidence: `main.c`)
- CLI and event loop → Serial port: writes request (evidence: `main.c`)
- CLI and event loop → Serial port: reads reply (evidence: `main.c`)
- CLI and event loop → FDCP buffers: frames reply (evidence: `main.c`)
- CLI and event loop → UDP client: sends reply (evidence: `main.c`)
