DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
dnc.h File Reference

CNC RS-232 DNC (Distributed Numerical Control) drip-feed codec (DETWS_ENABLE_DNC). More...

#include "ServerConfig.h"

Go to the source code of this file.

Detailed Description

CNC RS-232 DNC (Distributed Numerical Control) drip-feed codec (DETWS_ENABLE_DNC).

DNC is the classic way a program is streamed to a machine-tool controller: a G-code program (RS-274 / ISO 6983) is punched as blocks (one line each), framed with a % rewind-stop at the start and end, and drip-fed over an RS-232 link with XON/XOFF software flow control so the sender pauses when the controller's small input buffer fills. This codec is the transport-agnostic framing + tape-code layer only - the same bytes ride RS-232, a raw TCP socket, or a WebSocket; the app owns the wire.

Two tape codes are supported (the historical split every DNC package still carries):

  • ISO (::DNC_CODE_ISO): ISO 7-bit / ASCII, End-of-Block = LF, program marker = %. Optional even parity in bit 7 (the ISO tape convention, RS-358).
  • EIA (::DNC_CODE_EIA): the EIA RS-244 punched-tape code - a distinct, odd-parity 8-track encoding (parity in channel 5). End-of-Block = 0x80 (channel 8, used only for EOB), the rewind-stop is EIA End-of-Record 0x0B (the % equivalent), and there are no lowercase letters. The full character table is odd-parity-verified.

Three pieces, all pure and zero-heap:

  1. character translation (::dnc_iso_to_eia / ::dnc_eia_to_iso) + ISO even-parity helper;
  2. XON/XOFF flow state (::DncFlow) the send pump consults before each write;
  3. a streaming block encoder (::dnc_encode_block + the %/leader framing) and a byte-at-a-time block decoder (::DncDecoder) that reassembles wire bytes back into ASCII G-code lines and reports the % program start/end.
Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file dnc.h.