Connecting fanuc-driver to NCGuide simulator (standard install, no NCGuide-Pro / NCGuide_COMM license) #123
sencelik
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR
fanuc-driver can be made to work against the standard NCGuide simulator on the same Windows host as the driver, using
cnc_allclibhndl2(node=9)andfwlibNCG64.dllinstead ofcnc_allclibhndl3over TCP. This bypasses the EW_MMCSYS error that standard NCGuide returns for any FOCAS-over-Ethernet connection attempt. 22 of 28 commonly-used FOCAS calls work on a vanilla NCGuide install.I've also put together a small Python HTTP proxy that exposes the working FOCAS calls as JSON endpoints — that way VMs / remote hosts can poll a real NCGuide simulator without needing a licensed network bridge.
Background — why this needs documenting
The repo bundles
fwlibNCG.dllandfwlibNCG64.dll(the NCGuide-specific FOCAS plugins) but the docs, issues, and discussions don't mention NCGuide once. There's no example, no config snippet, no troubleshooting note. The natural assumption —ip: localhost, port: 8193inconfig.machines.yml— fails withEW_MMCSYS (-15)against a running NCGuide simulator, regardless of:Fwlib32.dll, this repo'sFwlib64.dll)SettingManager.exeis launchedSo I spent some time figuring out why, and what actually works.
Root cause
Standard NCGuide does not implement FOCAS2/Ethernet on TCP 8193. The port listens, completes the TCP 3-way handshake, but resets the connection as soon as it receives anything that looks like a FOCAS preamble. NCGuide-Pro / NCGuide_COMM are the licensed Fanuc products that add real network FOCAS — standard NCGuide only supports in-process IPC via shared memory + global mutexes + a named pipe (
\\.\pipe\CNCGUIDE1).The IPC objects Simbase exposes are all accessible at normal user privilege:
FanucFocas1ProcCommonVarMap(4 KB)Global\Fanuc300iLibMutex_0_0_{0,1,2},FanucPmcLibGeneralMutex_0_0,FanucPmcLibWindowMutex_0_0\\.\pipe\CNCGUIDE1fwlibNCG64.dllis the loader that knows how to use them. It exportscnc_allclibhndlandcnc_allclibhndl2— but notcnc_allclibhndl3(the TCP one). That alone tells you the design intent: NCGuide's FOCAS surface is HSSB-style local IPC only.What works
The
nodeargument is9against a default NCGuide install. I found this by brute-forcing-1..50while Simbase was running; only9returnedEW_OK, every other value returnedEW_NUMBER (-3). The semantics of "node 9" appear undocumented in any FOCAS reference I could find — best guess: Simbase registers itself at a hardcoded HSSB slot index. (If anyone from Fanuc / a longtime user knows the actual reason, I'd love to learn it.)FOCAS calls that work on standard NCGuide via this path
Tested against a default FS30i-B Plus install (
series=G317, version=19.0, mt_type=M):cnc_sysinfocnc_statinfocnc_exeprgnamecnc_rdprgnum,cnc_rdseqnumcnc_rdspeed,cnc_actf,cnc_actscnc_rdaxisnamecnc_alarm,cnc_alarm2cnc_modalcnc_rdparamcnc_rdmacrocnc_rdsvmeter,cnc_rdspmeterpmc_rdpmcrngcnc_absolute,cnc_machine,cnc_relativeEW_FORMAT (-2)— possibly struct packing / size argcnc_toolnumEW_NOOPT (-6)— option not in standard NCGuide licensecnc_rdcncidrc=1— option-gatedcnc_rdopmsgEW_FORMAT (-2)So out of 28 calls I tried, 22 work. More than enough for the data Ladder99's
FanucMachinestrategy collects.Reference implementation: HTTP proxy for VM clients
The catch with HSSB IPC is that it only works from a process running on the same Windows session as Simbase. To make a VM (or any remote tooling) consume the data, I put together a small
http.server-based proxy:It uses
safe_call(...)with a single persistent handle + auto-reconnect onEW_RESET (-8). ~250 lines of pure stdlib Python, no extra deps. Happy to clean it up and PR it asexamples/windows/ncguide-proxy/if maintainers would find it useful — let me know if there's a preferred shape (Docker, batch script, etc.).Suggestion for fanuc-driver
Two small, non-invasive things would help future users land on this path much faster:
Doc note under "installation-windows.md" — something like:
NCGuide example config that wires
FanucMachineto a local FOCAS handle obtained viacnc_allclibhndl2(node=9)rather thancnc_allclibhndl3over TCP — could be a new transport selector or just a documented config preset.I can put both of these together as a PR if there's interest.
What I'd love to know
node=9is hardcoded by NCGuide, derived from the controller variant ID, or something a future Fanuc release might change?Thanks for the great work on this driver — the bundled DLL set saved me a lot of time even though the docs didn't cover the simulator case.
Beta Was this translation helpful? Give feedback.
All reactions