April 2026. On an isolated test subnet, a software daemon emulating a FANUC Series 31i CNC controller was listening on port 8193. The engineering experiment was straightforward: establish communication between FANUC’s official client library and an emulated controller without relying on proprietary vendor runtime DLLs. The server emitted an initialization response matching the wire-level binary specification. The client library received the packet, analyzed its structure, and abruptly severed the socket. The log output retained a single diagnostic code: -16, denoting EW_PROTOCOL.
This rejection conveys the primary foundational lesson of FOCAS: it is not merely a raw network wire protocol, but a tightly coupled client library suite distributed by the CNC builder. The library enforces proprietary client-side handshake validations; simply imitating packet headers on the wire is rarely sufficient. Later that afternoon, a second architectural approach was deployed: bypassing the vendor library entirely and conversing directly across raw TCP sockets. That path exposed the internal mechanics of the protocol.
FOCAS is the proprietary API suite utilized to access CNC and PMC memory registers across FANUC machine tool controllers. In engineering documentation, it is cataloged as FOCAS1 and FOCAS2. It connects via Ethernet or high-speed HSSB (High Speed Serial Bus), instantiates a session handle, and executes read and write transactions through that handle. It is not an open semantic standard like MTConnect; its runtime libraries and specifications are distributed exclusively under commercial builder terms.[1][2][3]

FOCAS at a Glance
| Developer | FANUC Corporation [1][2] |
|---|---|
| Type | Native API library (FOCAS1/FOCAS2) and underlying binary TCP wire protocol [2][3] |
| Transport | Ethernet (TCP; default port 8193) and HSSB (High Speed Serial Bus optical interface) [1][2] |
| Client Binaries | FWLIB32.DLL paired with series-specific runtime DLLs; Linux deployments utilize libfwlib32-linux-*.so [2][3] |
| Connection Call | cnc_allclibhndl3(ip, port, timeout, &handle); all operational transactions route through this handle [3] |
| Data Scope | CNC operating status, axis coordinates, active program titles, alarms, tooling tables, macro variables, PMC registers, and file transfers [2] |
| Data Direction | Bidirectional read and write; write authorization is governed by CNC options, controller model, and software policy [2] |
| Supported Series | Series 30i/31i/32i-B, 0i-F, 0i-D, 16i/18i/21i, 15i, Power Mate i-D/H, and 150-B [1] |
| Documentation | Proprietary; access to libraries and specification manuals requires authorized vendor distribution [2] |
What FOCAS Is, and What It Is Not
Confusing FOCAS with MTConnect leads to costly architectural missteps on the shop floor. MTConnect is an open, read-only semantic dictionary designed for multi-brand telemetry; FOCAS is a vendor-specific, deep-register API providing bidirectional control for FANUC machinery. One normalizes diverse equipment into a common sentence; the other unlocks the internal organs of a FANUC controller. They are complementary rather than competing technologies. Furthermore, FANUC’s commercial MT-LINK i suite delivers monitoring over Ethernet and OPC UA; this represents an enterprise application product rather than an alternative wire protocol.[1][2][6]
FOCAS is also not a single monolithic dynamic link library. FWLIB32.DLL operates as the core routing facade; depending on the target controller generation, it must dynamically load series-specific satellite libraries such as FWLIB30i.DLL, FWLIB0iD.DLL, FWLIB0i.DLL, FWLIB16W.DLL, or FWLIBNCG.DLL. Identical client source code running against different controller generations will demand distinct combinations of satellite DLLs. Deploying FOCAS without cataloging controller firmware and hardware generations guarantees runtime failure.[2][3]
Licensing and distribution parameters impose strict boundaries. The runtime libraries are not open source; they are distributed under builder agreements. Because public, verified price lists do not exist, integration budgets must allocate dedicated lines for software licensing and technical enablement directly through official machine tool channels.[2]
Two Physical Transports, One Connection Handle
FOCAS supports two physical communication media: Ethernet and HSSB. Ethernet operates across standard TCP/IP networking, with TCP port 8193 serving as the universal default across modern installations. HSSB utilizes high-speed fiber-optic bus interface cards installed directly into the CNC backplane. In FANUC’s official function matrices, specific capabilities are demarcated with O (Ethernet & HSSB), E (Ethernet only), H (HSSB only), or X (unsupported). Not all functions run across both transports.[1][2]
The programmatic lifecycle relies on an explicit session handle. A client application invokes cnc_allclibhndl3, providing the IP address, port number, and timeout threshold in seconds; upon success, the library returns an unsigned short handle identifier. All subsequent telemetry calls pass this integer handle. When transactions conclude, the client frees resources via cnc_freelibhndl. Re-establishing handles for every polling cycle introduces catastrophic latency; conversely, reusing stale handles across dropped network sockets generates silent, unhandled exceptions.[3]
Wire-Level Mechanics: Packet Frame Architecture
The underlying wire-level frame structure of FOCAS over TCP has been rigorously documented by independent open implementations (notably pyfanuc) and verified through industrial packet captures. This analysis reflects empirical reverse engineering and functional code rather than official vendor publications.[4][5]
Every network frame begins with a fixed 10-byte binary header: a 4-byte synchronization magic sequence A0 A0 A0 A0, followed by big-endian unsigned 16-bit fields for protocol version, frame type, and payload length. Recognized frame types govern the complete lifecycle:
Binary Header (10 bytes):
[A0 A0 A0 A0] [version:u16] [ftype:u16] [payload_len:u16]
0x0101 / 0x0102 Session Open Request / Response
0x0201 / 0x0202 Session Close Request / Response
0x2101 / 0x2102 Data Transaction Request / Response
0x2103 Observed Rejection / Protocol NAK
Within a data transaction frame (0x2101), the payload encapsulates discrete 28-byte sub-packets. Each sub-packet comprises a 2-byte length descriptor (typically 0x001C), three 2-byte command identifiers (c1, c2, c3), and five 32-bit parameters. Successful responses echo the command codes along with incoming data buffers; error conditions return a truncated 14-byte payload. This sub-packet architecture allows integrators to bundle multiple queries—status, active program, feed rate, spindle RPM, and active alarms—into a single TCP transmission, significantly reducing network overhead.[4]
| Command Tuple (c1/c2/c3) | Extracted Register Data | Operational Implementation |
|---|---|---|
| 0x01 / 0x01 / 0x18 | System Info (CNC type, MT type, series, axes count) | Asset auditing and dynamic library binding |
| 0x01 / 0x01 / 0x19 | Operating Status (mode, run, e-stop, alarm flags) | Real-time OEE state engines |
| 0x01 / 0x01 / 0x1A | Alarm Information (axis, spindle, macro, system) | Predictive maintenance and incident logs |
| 0x01 / 0x01 / 0x1C · 0x20 | Active Program Number and Executing Part Program Title | Job dispatching and recipe verification |
| 0x01 / 0x01 / 0x24 · 0x25 | Actual Feed Rate and Measured Spindle Speed | Cutting dynamics and tool wear monitoring |
| 0x01 / 0x01 / 0x26 | Axis Position (absolute, machine, relative coordinates) | Digital twin spatial trajectory tracking |
| 0x01 / 0x01 / 0x61 | Override Signals (feed override, spindle override, rapid) | Operator intervention logging and compliance |
| 0x01 / 0x01 / 0x22 | Modal Aux Data (active Tool, M, S, H, and D codes) | Active tool inspection and subprogram tracking |
| 0x02 / 0x01 / 0x8001 | PMC Window Read (R, G, F, Y, X registers) | Low-level electrical and PLC coil telemetry |
This operational command suite reveals why FOCAS is regarded as the ultimate diagnostic window for FANUC controls: across a single network connection, it exposes everything from physical spindle load to low-level ladder logic coils, well beyond what open schemas surface.
First Turn: It Is a Library Ecosystem, Not a Standalone Protocol
The primary error when planning FOCAS integrations is regarding it as a plain socket protocol. At the developer layer, engineers interact with structured C function calls: cnc_statinfo, cnc_absolute, cnc_rdprgnum, cnc_exeprgname, cnc_rdopnlsgnl, cnc_rdmacro, and pmc_rdpmcrng. At the lower tier, these calls are marshaled through Windows DLLs into TCP streams tailored to specific CNC hardware generations.[1][2]
A software implementation operating flawlessly on a Series 30i-B may fail on a Series 0i-F. FANUC’s function matrices detail which calls are supported across which controller family; entries marked X indicate complete lack of firmware support. When field engineers report that “FOCAS is down,” the issue is almost universally a missing satellite DLL or an invocation of an unsupported function call on that specific CNC model.[1]
Second Turn: Write Authorization and Physical Safety
The most capable capability of FOCAS is simultaneously its greatest operational liability: remote write authorization. FOCAS can write machine parameters, coordinate work offsets, tool wear matrices, macro variables, and PLC memory bits. While invaluable for automated tool wear feedback, this represents an acute physical hazard. A corrupted tool length offset or miscalculated datum shift can plunge a cutting tool into a chuck fixture at maximum rapid traverse, wrecking expensive equipment and endangering operators.[2]
This technical publication does not provide recipes for unvalidated write execution. We define strict architectural boundaries: client applications with write privileges must reside on an isolated VLAN, mandate multifactor authentication, log all transactions to audit trails, and incorporate pre-execution dry-run validations on digital simulators. FANUC’s cybersecurity advisories reinforce that remote write access must be treated with rigorous industrial scrutiny.[7]
| Operational Operation | FOCAS Capability | Mandatory Security Governance |
|---|---|---|
| Reading telemetry, alarms, coordinates, and status | Yes | Read-only client instances; standard VLAN isolation. |
| Writing parameters and tool wear offsets | Yes | Automated range-checking, audit logging, and manual operator validation. |
| Writing custom macro variables and PMC ladder bits | Yes | Restricted to certified maintenance sessions; full register rollback plans mandatory. |
| Part program transfer and G-code file uploads | Yes | Cryptographic file hashing, revision approval workflows, and staging directories. |
Third Turn: The DLL Barrier and Two Integration Paths
Returning to our opening software experiment: FANUC’s official client library rejected the emulated controller’s response with error -16 EW_PROTOCOL. Deep packet inspection indicates that the vendor library establishes dual sockets per session and utilizes proprietary handshake tokens during initialization, cross-checking responses against internal firmware signatures. Knowing the packet layout alone does not permit effortless emulation.
This establishes two distinct engineering pathways for FOCAS integration: utilizing the official vendor DLLs, or implementing a custom wire-level socket client (such as pyfanuc). Clean-room TCP implementations provide platform independence across Linux, ARM, and container environments, but operate entirely without vendor certification and may exhibit compatibility anomalies across older controller generations.[4][5]
The practical integration conclusion is clear: choosing your client execution model is more consequential than configuring socket addresses. The vendor library represents the certified, fully supported path; custom TCP sockets minimize platform dependencies but transfer reverse-engineering maintenance risks entirely to your software team. Mixing both methodologies on the same production line invites dual maintenance overhead.
Behavioral divergences on simulation software like NCGuide further underscore this reality. In bench testing, specific calls like CMD_READ_OPNLSGNL (0x61) returned error E6, CMD_READ_MACRO (0x15) triggered 0x2103 rejections, and CMD_READ_PMC (0x02) provoked unexpected socket drops, while active T-codes were reliably extracted at byte offset 24 within CMD_READ_MODAL_AUX (0x22) payloads. Integrators must validate behavior against physical controller iron.
FOCAS vs. MTConnect: Strategic Trade-Offs
| Functional Scope | FANUC FOCAS | MTConnect Standard |
|---|---|---|
| Deep CNC/PMC/Macro Register Depth | Exhaustive | Limited to Schema |
| Writing Parameters, Offsets, and Programs | Supported | Excluded by Design |
| Multi-Brand Normalized Dictionary | No (FANUC Only) | Universal |
| Open Specification and Community Tools | Proprietary | Fully Open Source |
| Primary Operational Domain | OEM cells, maintenance, deep CNC analytics | MES, OEE dashboards, enterprise reporting |
Optimal enterprise architectures frequently harmonize both technologies: deploying FOCAS at the machine edge for FANUC-specific diagnostics and controlled parameter updates, while surfacing normalized operational metrics plant-wide via an MTConnect adapter. Segregating control-tier writers from telemetry-tier readers remains the golden rule of industrial reliability.[8]
Seven Rules for Production Implementation
- Verify Hardware Ethernet Capabilities: FOCAS is not enabled by default on all machines; confirm the presence of Ethernet hardware options and supported CNC system software versions.
- Restrict Network Ports via Firewalls: Restrict TCP port 8193 strictly to authorized data collection gateways; isolate machine subnets from office LANs.
- Map the Satellite DLL Dependencies: Match controller series precisely against
FWLIB32satellite DLL requirements; guarantee 32-bit versus 64-bit runtime consistency. - Govern Connection Handle Lifecycles: Maintain persistent handles during polling routines; release handles cleanly upon exit; implement explicit reconnection logic when sockets fault.
- Enforce Timeout and Back-Off Policies: Avoid saturating controller backplanes with high-frequency queries; incorporate exponential back-off upon receiving communication errors.
- Physically Isolate Write-Capable Systems: Systems authorized to execute parameter updates must operate under dedicated credentials on segmented physical networks.
- Log and Monitor Protocol Diagnostics: Capture all return codes (including
EW_PROTOCOLandEW_SOCKET); expose silent retry loops to operational monitoring.
Conclusion: True Operational Control Means Knowing When Not to Write
The true value of FOCAS is not measured by the hundreds of functions exposed in its API manuals, but by the disciplined judgment governing their application. The exact same handle that reads an axis position can overwrite a workpiece offset. Establishing that boundary is not a software problem, but an institutional governance responsibility.
Does your data collection pipeline connecting to FANUC equipment operate purely in read-only telemetry mode? And if remote write authority is active, are your operational rollback plans and safety interlocks formally verified?
This article forms part of our CNC Control Protocols series. To understand open shop-floor telemetry, examine our MTConnect Guide; for hardware-level serial transmission, explore our RS-232 Dossier; for embedded bus physics, read our I2C, SPI & UART Analysis.
Verified Sources and Technical References
- Ladder99 fanuc-driver • Comprehensive FOCAS Function Matrix (Support codes O/E/H/X and controller generations) • github.com/Ladder99/fanuc-driver
- Ladder99 fanuc-driver • Windows Environment Setup, Port 8193 Architecture, and FOCAS DLL Dependencies • installation-windows.md
- strangesast/fwlib • FANUC FOCAS Header Definitions and
fwlib32.hReference (cnc_allclibhndl3) • github.com/strangesast/fwlib - pyfanuc • Empirical FOCAS Wire Protocol Specification: Frame Headers, Commands, and Packet Captures • pyfanuc/protocol.txt
- pyfanuc • Clean-Room Python Socket Implementation for the FANUC FOCAS Protocol • github.com/diohpix/pyfanuc
- FANUC America • MT-LINK i Production Telemetry via Ethernet and OPC UA • fanucamerica.com
- FANUC Corporation • Industrial Cybersecurity Product Advisories and Updates • fanuc.co.jp/en/product/vulnerability
- MTConnect Institute • Reference C++ Agent Repository and Architectural Specification • github.com/mtconnect/cppagent