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

FANUC FOCAS Ethernet protocol codec (DETWS_ENABLE_FOCAS) - zero-heap request builders + response parsers for FANUC CNCs over TCP 8193 (the machine-tool data protocol). More...

#include "ServerConfig.h"

Go to the source code of this file.

Detailed Description

FANUC FOCAS Ethernet protocol codec (DETWS_ENABLE_FOCAS) - zero-heap request builders + response parsers for FANUC CNCs over TCP 8193 (the machine-tool data protocol).

FOCAS ("FANUC Open CNC API Specification") is normally a proprietary PC library (fwlib32); this is a pure codec for its Ethernet wire protocol. Every multi-octet field is BIG-endian. A frame is a 10-octet envelope + a payload:

envelope (10)
A0 A0 A0 A0 frame magic
version (2) = 1
frame type (2) 0x0101 open req / 0x0102 open resp
0x2101 command (VAR) req / 0x2102 command resp
0x0201 close req / 0x0202 close resp
length (2) octets of payload that follow
payload (length) type-specific (see below)

The session is: open (payload = FRAME_DST 0x0002) -> one or more commands -> close. A command request payload is a 6-octet selector + five signed 32-bit arguments + optional extra data:

c1 c2 c3 three u16: the FOCAS function selector (e.g. 1/1/0x18 = SysInfo)
v1 v2 v3 v4 v5 five i32: the function's integer arguments
extra... function-specific trailing bytes (none for the reads below)

A command response payload echoes the 6-octet selector, then a 6-octet status (a signed-short FOCAS return code in its first two octets, 0 = EW_OK), then a u16 data length, then the data.

Frame layout, selector encoding, the open/close handshake, the SysInfo (ODBSYS) and alarm (>L) response layouts, and the 8-octet value encoding (data / base^exp) were reverse- engineered by and cross-checked against diohpix/pyfanuc. Function selectors are the verbatim set documented there. Pure codec, host-tested - the caller owns the TCP connection (det_client_*) and drives the open -> command -> close sequence.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file focas.h.