# raspberryy/emulated_usb_printer architecture

> Architecture diagram of the GitHub repository raspberryy/emulated_usb_printer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raspberryy/emulated_usb_printer
- Repository: https://github.com/raspberryy/emulated_usb_printer

## Overview

This is a Raspberry Pi USB printer-gadget emulator: a host recognizes the Pi as a configured printer and sends print data, which the program captures as raw job files and can optionally convert with GhostPDL. Its command-line interface also reports or changes printer status. The README describes further downstream uses for captured reports, but those are possibilities rather than implemented product stages in the sampled source. The main source excerpt is partial, so uncertain internal wiring is omitted.

Main entry points: [`printer.c`](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c) (Capture Loop), [`printer_minimal.c`](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer_minimal.c) (Minimal Capture Variant), [`README.md`](https://github.com/raspberryy/emulated_usb_printer/blob/main/README.md) (Printer Identity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["USB Printer Device"]
  node_gadget["Printer Gadget Driver"]
  node_identity["Printer Identity<br/>[README.md]"]
end

subgraph group_capture["Job Capture"]
  node_capture_loop["Capture Loop<br/>[printer.c]"]
  node_job_files[("Raw Job Files<br/>[printer.c]")]
  node_minimal_capture["Minimal Capture Variant<br/>[printer_minimal.c]"]
end

subgraph group_control["Status and Conversion"]
  node_cli["Command-Line Interface<br/>[printer.c]"]
  node_status["Status Control<br/>[printer.c]"]
  node_converter["GhostPDL Conversion<br/>[printer.c]"]
end

node_host(("Print Host"))
node_gpdl["GhostPDL"]

node_identity -.->|"configures"| node_gadget
node_host -->|"sends print data"| node_gadget
node_gadget -->|"provides data"| node_capture_loop
node_cli -->|"dispatches read"| node_capture_loop
node_capture_loop -->|"checks status"| node_status
node_capture_loop -->|"writes jobs"| node_job_files
node_capture_loop -.->|"requests conversion"| node_converter
node_converter -.->|"runs converter"| node_gpdl
node_cli -->|"dispatches status"| node_status
node_status -->|"reads or sets status"| node_gadget
node_minimal_capture -->|"reads print data"| node_gadget
node_minimal_capture -->|"writes jobs"| node_job_files

click node_identity "https://github.com/raspberryy/emulated_usb_printer/blob/main/README.md"
click node_cli "https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c"
click node_capture_loop "https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c"
click node_job_files "https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c"
click node_status "https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c"
click node_converter "https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c"
click node_minimal_capture "https://github.com/raspberryy/emulated_usb_printer/blob/main/printer_minimal.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_gadget,node_identity toneBlue
class node_capture_loop,node_job_files,node_minimal_capture toneAmber
class node_cli,node_status,node_converter toneMint
class node_host,node_gpdl toneIndigo
```

## Components

### USB Printer Device

- **Printer Gadget Driver**
- [Printer Identity](https://github.com/raspberryy/emulated_usb_printer/blob/main/README.md): `README.md`

### Job Capture

- [Capture Loop](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c): `printer.c`
- [Raw Job Files](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c): `printer.c`
- [Minimal Capture Variant](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer_minimal.c): `printer_minimal.c`

### Status and Conversion

- [Command-Line Interface](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c): `printer.c`
- [Status Control](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c): `printer.c`
- [GhostPDL Conversion](https://github.com/raspberryy/emulated_usb_printer/blob/main/printer.c): `printer.c`

### Other components

- **Print Host**
- **GhostPDL**

## Connections

- Printer Identity → Printer Gadget Driver: configures
- Print Host → Printer Gadget Driver: sends print data
- Printer Gadget Driver → Capture Loop: provides data
- Command-Line Interface → Capture Loop: dispatches read
- Capture Loop → Status Control: checks status
- Capture Loop → Raw Job Files: writes jobs
- Capture Loop → GhostPDL Conversion: requests conversion
- GhostPDL Conversion → GhostPDL: runs converter
- Command-Line Interface → Status Control: dispatches status
- Status Control → Printer Gadget Driver: reads or sets status
- Minimal Capture Variant → Printer Gadget Driver: reads print data
- Minimal Capture Variant → Raw Job Files: writes jobs
