> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plato.ae/llms.txt
> Use this file to discover all available pages before exploring further.

# PC Printer Driver

> Current Windows print bridge for Plato POS.

# PC Printer Driver

The PC printer driver is a local Windows service for Plato POS printing. It accepts print jobs over HTTP, stores them in Redis-backed BullMQ queues, and writes ESC/POS bytes to network thermal printers over TCP.

It is not an operating-system printer driver. It is a small local bridge between Plato's browser POS and raw ESC/POS printers.

## What It Does

* Receives print jobs from Plato Console through `POST /print`.
* Converts incoming base64 ESC/POS raster chunks into queued printer jobs.
* Keeps a separate queue per printer address.
* Processes one job at a time per printer.
* Sends raw ESC/POS bytes to TCP printers.
* Supports printer status checks, cash drawer kick, beep commands, queue inspection, HTTPS proxying, and PeerJS mesh signaling.

## Runtime Shape

```txt theme={null}
Plato POS browser
  |
  | POST /print
  v
PC printer HTTP server
  |
  | build print chunks
  v
PrinterStores
  |
  | one BullMQ queue per ip:port
  v
PrinterStore worker
  |
  | TCP socket
  v
ESC/POS thermal printer
```

## Main Files

| File                                            | Role                                                                           |
| ----------------------------------------------- | ------------------------------------------------------------------------------ |
| `drivers/pc-printer/src/index.ts`               | Express app, CORS, startup, HTTPS, mesh server, shutdown handlers.             |
| `drivers/pc-printer/src/routes.ts`              | HTTP endpoints for print, status, beep, cash drawer, health, and queue state.  |
| `drivers/pc-printer/src/printer-stores.ts`      | Per-printer queue, worker, socket lifecycle, status probing, retry recovery.   |
| `drivers/pc-printer/src/printer.ts`             | Low-level TCP writes, write timeout, printer init command, local IP discovery. |
| `drivers/pc-printer/src/lib/config.ts`          | `config.json` defaults, parsing, and sanitization.                             |
| `drivers/pc-printer/src/lib/redis.ts`           | Embedded or external Redis runtime.                                            |
| `drivers/pc-printer/src/lib/receipt-encoder.ts` | ESC/POS chunk wrapping, cut, beep, and cash drawer commands.                   |
| `drivers/pc-printer/src/scripts/*`              | Caddy HTTPS setup and release helpers.                                         |

## Network Ports

| Port              | Default        | Used For                           |
| ----------------- | -------------- | ---------------------------------- |
| `server.port`     | `8080`         | Main HTTP API.                     |
| `caddy.httpsPort` | `443`          | HTTPS reverse proxy when enabled.  |
| `redis.port`      | `6379`         | Embedded or external Redis.        |
| Printer port      | Usually `9100` | Raw TCP connection to the printer. |

## Capabilities

* Network printers that accept ESC/POS over TCP.
* Raster print jobs generated by Plato Console.
* Deferred print jobs through `runAt`.
* Persistent retry queues.
* Cash drawer pulse through ESC/POS.
* Repeated beep sequence.
* HTTPS through Caddy on Windows.
* PeerJS mesh signaling on `/mesh`.
