{"id":20544846,"url":"https://github.com/gavanderhoorn/comet_rpc","last_synced_at":"2025-04-14T09:52:44.078Z","repository":{"id":65605669,"uuid":"592015564","full_name":"gavanderhoorn/comet_rpc","owner":"gavanderhoorn","description":"Low-level Python wrapper around the COMET RPC interface on Fanuc R-30iB(+) controllers (V8+)","archived":false,"fork":false,"pushed_at":"2023-06-15T07:14:14.000Z","size":176,"stargazers_count":16,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T23:11:30.503Z","etag":null,"topics":["fanuc","j767","json-rpc","python","rpc"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gavanderhoorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-22T17:07:00.000Z","updated_at":"2024-11-06T20:28:36.000Z","dependencies_parsed_at":"2023-02-16T18:45:56.851Z","dependency_job_id":null,"html_url":"https://github.com/gavanderhoorn/comet_rpc","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavanderhoorn%2Fcomet_rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavanderhoorn%2Fcomet_rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavanderhoorn%2Fcomet_rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavanderhoorn%2Fcomet_rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gavanderhoorn","download_url":"https://codeload.github.com/gavanderhoorn/comet_rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860037,"owners_count":21173339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fanuc","j767","json-rpc","python","rpc"],"created_at":"2024-11-16T01:49:04.149Z","updated_at":"2025-04-14T09:52:44.044Z","avatar_url":"https://github.com/gavanderhoorn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# comet_rpc\n\n[![license - apache 2.0](https://img.shields.io/:license-Apache%202.0-yellowgreen.svg)](https://opensource.org/licenses/Apache-2.0)\n[![CI](https://github.com/gavanderhoorn/comet_rpc/workflows/CI/badge.svg?branch=master)](https://github.com/gavanderhoorn/comet_rpc/actions?query=workflow%3ACI)\n[![Github Issues](https://img.shields.io/github/issues/gavanderhoorn/comet_rpc.svg)](https://github.com/gavanderhoorn/comet_rpc/issues)\n\n## Discussion\n\nIf you happen to find this useful, leave a quick note in the [Discussions section](https://github.com/gavanderhoorn/comet_rpc/discussions).\nIf something doesn't work, open an issue [on the tracker](https://github.com/gavanderhoorn/comet_rpc/issues).\n\n## Overview\n\nThis is a low-level Python wrapper around the JSON-RPC interface offered by the `COMET` extension of FANUC's web server on R-30iB and R-30iB+ controllers (ie: V8 and up, although older than V9 has a (very) limited interface).\n`COMET` is used by iRProgrammer and a couple of other web-based UIs offered by FANUC on their more recent controller series.\n\nSee [Requirements](#requirements) for some more information on required options.\n\n**NOTE**: this is only meant as an example of using `COMET`'s RPC interface.\nThere is no official documentation on this interface, and it's likely not intended to be used by anything other than FANUC's own products.\nUse with caution.\n\nProper integration of a FANUC controller with an external application or workcell should be done using either the PCDK, RMI (`R912`), OPC-UA, a fieldbus or similar technology.\nThe scripts and functionality provided here are only a convenience and are only intended to be used in academic and laboratory settings.\nThey allow incidental external access to a controller without needing to use any additional hardware.\nDo not use this on production systems or in contexts where any kind of determinism is required.\nThe author recommends using PCDK, RMI, OPC-UA and/or any of the supported fieldbuses in those cases.\n\n## TOC\n\n1. [Status](#status)\n1. [Requirements](#requirements)\n1. [Compatibility](#compatibility)\n1. [Installation](#installation)\n1. [Example usage](#example-usage)\n1. [Supported RPCs](#supported-rpcs)\n1. [Limitations / Known issues](#limitations--known-issues)\n1. [Performance](#performance)\n1. [Security](#security)\n1. [Related projects](#related-projects)\n1. [Bugs, feature requests, etc](#bugs-feature-requests-etc)\n1. [FAQ](#faq)\n1. [Disclaimer](#disclaimer)\n\n## Status\n\nThis package is a work-in-progress.\nAs there is no documentation on `COMET`, it's been implemented based on information learned from observing iRProgrammer and related web-based UIs.\n\nExpect frequent breakage and missing functionality.\n\nSee also the [FAQ](#faq).\n\n## Requirements\n\nRequirements are a little unclear at this moment, but it appears `COMET` is installed on all controllers with the base *Web Server* (`HTTP`) option and at least V8 of the system software (see notes about [Compatibility](#compatibility) below).\nInterestingly, even though `COMET` is primarily used by iRProgrammer, option `J767` does not appear to be a requirement for it to be installed.\n\nThe main other requirement is a functioning networking setup.\nMake sure you can ping the controller and the controller's website shows up when opening `http://robot_ip` in a browser.\nConfiguration of *HTTP Authentication* is not needed, as `COMET` RPCs do not appear to be affected by it (see [Security](#security) for some more discussion).\n\n## Compatibility\n\n### Controllers\n\nCompatibility has only been tested with R-30iB+ controllers running V9.30 and V9.40 of the system software.\nIt's possible R-30iB with V8.x supports the `COMET` RPC interface as well, but this has not been tested.\n\n### Operating Systems\n\nThe library has been written for Python version 3.\nNo specific OS dependencies are known, meaning all platforms with a Python 3 interpreter should be supported.\nOnly Windows 10, Ubuntu Bionic and Focal have been extensively tested however.\n\n## Installation\n\n### Controller\n\nAs the `COMET` RPC interface is part of the controller's web server, no installation nor setup on the FANUC side should be necessary.\n\n### Package\n\nIt's recommended to use a virtual Python 3 environment and install the package in it.\nThe author has primarily used Python 3.8, but other versions are expected to work, though they are not actively tested.\n\nFuture versions may be released to PyPi.\n\nExample (installs `comet_rpc` `0.2.4`; be sure to update the URL to download the desired version):\n\n```shell\npython3 -m venv $HOME/venv_comet_rpc\nsource $HOME/venv_comet_rpc/bin/activate\npip install -U pip\npip install -U wheel setuptools\npip install https://github.com/gavanderhoorn/comet_rpc/archive/0.2.4.tar.gz\n```\n\n## Example usage\n\nThe current version of this package does not come with any example scripts.\nThe subsection below is expected to be sufficient to clarify basic usage of the RPC interface.\n\n### Library\n\nThis resets the controller, sets the override to 100% and finally reads the `DO[1]` IO port and retrieves its comment:\n\n```python\nfrom comet_rpc import (\n    exec_kcl,\n    IoType,\n    iogetpn,\n    iovalrd,\n    vmip_writeva,\n)\n\n# IP address or hostname of the R-30iB(+) controller\nserver = \"...\"\n\nexec_kcl(server, \"reset\")\nvmip_writeva(server, \"*SYSTEM*\", \"$MCR.$GENOVERRIDE\", value=100)\ndout1_val = iovalrd(server, IoType.DigitalOut, index=1).value\ndout1_cmt = iogetpn(server, IoType.DigitalOut, index=1).value\n...\n```\n\nNote the lack of error detection and handling to keep the example brief.\n\n## Supported RPCs\n\nThe following table shows an overview of known RPCs, whether they are currently supported by `comet_rpc` (column `Supp.?`) and which version of `COMET` appears to support them (\"appears\", as this information is based on experiments, there is no public, authoritative source of truth available).\n\nThe last two columns of the table clarify the minimum version of system software that supports a particular RPC.\nAn entry in the `8.x` column implies an RPC is supported starting with version `8.x`.\nUse the value in the cell to determine the minor version number.\n\nFor RPCs with no information in those columns this information hasn't been determined yet.\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand\u003c/summary\u003e\n\u003cbr/\u003e\n\n| Name              | Description                       | Supp.? | 8.x      | 9.x      |\n|:------------------|:----------------------------------|:------:|:---------|:---------|\n| CHGOVRD           | Change override                   |   Y    |          | .40+     |\n| CKTRKPRG          | Check linetrack attributes        |   N    |          | .40+     |\n| CLLB_CODE_REQ     |                                   |   N    |          | .40+     |\n| CLLB_PAYLOAD_CONF |                                   |   N    |          | .40+     |\n| CPKCL             | Execute KCL command               |   Y    |          | .30+     |\n| DCS_CHECK_APPLY   |                                   |   N    |          | .40+     |\n| DCS_CHECK_CODE    |                                   |   N    |          | .40+     |\n| DCS_VRFY_REQ      |                                   |   N    |          | .40+     |\n| DPEWRITE_STR      | Retrieve error code description   |   Y    |          | .10+     |\n| DPREAD            | Read element from dictionary      |   Y    | .30+     |          |\n| ERPOST            | Post an error to the log          |   N    |          | .10+     |\n| EXEC_TXCMND       |                                   |   N    | .10+     |          |\n| GET_FORM          |                                   |   N    | .10+     |          |\n| GET_RAW_FILE      | Get raw byte contents of file     |   Y    |          | .10+     |\n| GETFOCUS          |                                   |   N    |          | .10+     |\n| GTFILIST          | Get list of files in directory    |   Y    |          | .40+     |\n| GTMCRLST          | Get list of macros                |   Y    |          | .10+     |\n| GTPIDLST          | Get list of posregs in TP program |   Y    |          | .40+     |\n| IOASGLOG          | Update IO configuration           |   Y    |          | .40+     |\n| IOCKSIM           | Check simulated status of IO port |   Y    | .30+     |          |\n| IODEFPN           | Set/update comment on IO port     |   Y    |          | .10+     |\n| IODRYRUN          | Treat all IO as-if simulated      |   N    |          | .40+     |\n| IOGETASG          | Retrieve IO configuration         |   Y    |          | .40+     |\n| IOGETHDB          | Retrieve the \"HW database\"        |   Y    |          | .40+     |\n| IOGETPN           | Retrieve comment on IO port       |   Y    |          | .10+     |\n| IOGTALL           | Read IO ports, batch-wise         |   Y    |          | .30+     |\n| IOSIM             | Set IO port to simulated          |   Y    | .30+     |          |\n| IOUNSIM           | Clear simulated state of IO port  |   Y    | .30+     |          |\n| IOVALRD           | Read IO port                      |   Y    | .30+     |          |\n| IOVALSET          | Write to IO port                  |   Y    | .30+     |          |\n| IOWETRUN          | Stop treating all IO as simulated |   N    |          | .40+     |\n| LOCAL_PAUSE       |                                   |   N    |          | .10+     |\n| LOCAL_START       |                                   |   Y    |          | .10+     |\n| MG_RECPOS         |                                   |   N    |          | .40+     |\n| MMCHGTYP          | Change the type of a program      |   N    |          | .10+     |\n| MMCREMN           | Create a TP program               |   N    |          | .10+     |\n| MMDELPOS          | Remove a position from a program  |   N    |          | .10+     |\n| MMDELPRG          | Delete a program                  |   N    |          | .10+     |\n| MMGETATR          | Read program attribute            |   N    |          | .10+     |\n| MMGETTYP          | Read 'program type' (TP, PC, etc) |   Y    |          | .10+     |\n| MMRENPRG          | Rename a program                  |   N    |          | .10+     |\n| MMSETATR          | Write program attribute           |   N    |          | .10+     |\n| MNCHGREP          | Convert position representation   |   N    |          | .10+     |\n| MNCPYPRG          | Copy a program                    |   N    |          | .10+     |\n| OSSNDPKT_EXT      |                                   |   N    |          | .10+     |\n| PASTELIN          | Duplicate/move lines in a TP prog |   Y    |          | .40+     |\n| PGABORT           | Abort all/a specific program(s)   |   Y    |          | .10+     |\n| PMCUPFN           |                                   |   N    |          | .10+     |\n| PMCUPRQ           |                                   |   N    |          | .10+     |\n| PMCVALRD          |                                   |   N    |          | .10+     |\n| PMON_CAN_PKT      |                                   |   N    | .10+     |          |\n| PMON_DISCONNECT   |                                   |   N    | .10+     |          |\n| PMON_GET_PKT      |                                   |   N    | .10+     |          |\n| PMON_START_MON    |                                   |   N    | .10+     |          |\n| PMON_STOP_MON     |                                   |   N    | .10+     |          |\n| PMON_VERIFY_PKT   |                                   |   N    | .30+     |          |\n| POSREGVALRD       | Read a position register          |   Y    |          | .10+     |\n| RECPOS            | Teach position (in program)       |   N    |          | .10+     |\n| REGVALRD          | Read a register (int/real)        |   Y    |          | .10+     |\n| REMARKLIN         | (Un)remark lines in a TP prog     |   Y    |          | .40/P43+ |\n| RPRINTF           | Print to the controllers conslog  |   Y    | .10+     |          |\n| RUN_TASK          | Start a program on the controller |   N    |          | .30+     |\n| SCDELETE          | Delete line from program          |   N    |          | .10+     |\n| SCEDIT            | Add/replace line to/in program    |   N    |          | .10+     |\n| SCGETPOS          | Get position from program         |   N    |          | .40+     |\n| SCSETPOS          | Update position in program        |   N    |          | .10+     |\n| SET_FORM          |                                   |   N    | .10+     |          |\n| SKIP_LINE         | Change active line in paused prog |   N    |          | .40+     |\n| TPEXTREQ          |                                   |   N    | .10+     |          |\n| TPLINK_DISCONNECT |                                   |   N    |          | .10+     |\n| TPLINK_NEW_URL    |                                   |   N    | .10+     |          |\n| TPMODE_CHG        |                                   |   N    |          | .40+     |\n| TPMULTI_TASKIDX   |                                   |   N    | .30+     |          |\n| TPXENSBV_KRL_EXT  |                                   |   N    |          | .10+     |\n| TPXENSBV_KRL_TEXT |                                   |   N    |          | .10+     |\n| TPXENSUB_EXT      |                                   |   N    |          | .10+     |\n| TPXFILSB_EXT      |                                   |   N    |          | .10+     |\n| TPXPRGSB_EXT      |                                   |   N    |          | .10+     |\n| TXCHGPRG          | Open (and make active) a TP prog  |   Y    |          | .10+     |\n| TXLSTPRG_FC       | List programs (specific types)    |   N    |          | .10+     |\n| TXML_CURANG       | Return current joint angles       |   Y    |          | .10+     |\n| TXML_CURPOS       | Return current TCP pose (XYZWPR)  |   Y    |          | .10+     |\n| TXSETLIN          | Open TP prog at specific line     |   Y    |          | .10+     |\n| VMIP_READVA       | Read a (system) variable          |   Y    |          | .10+     |\n| VMIP_WRITEVA      | Write to a (system) variable      |   Y    | .30+     |          |\n| XMLCOPY           | Copy an XML file to another       |   N    |          | .30+     |\n\n\u003c/details\u003e\n\nTotal supported RPCs: 32 of 85.\n\n### Observations\n\nSome observations based on the above table:\n\n1. IO R/W seems to be officialy supported from `V8.30`\n1. R/W of IO configuration requires at least `V9.40`\n1. writing to (system) variables requires at least `V8.30`, *but*\n1. reading (system) variables requires at least `V9.10`\n1. monitoring of (system) variables requires at least `V8.10`\n1. position and int/real register R/W requires at least `V9.10`\n1. CRUD of TP programs requires at least `V9.10`\n1. interaction with DCS requires at least `V9.40`\n1. starting a program (not via IO) requires at least `V9.30`\n\n## Limitations / Known issues\n\nThe following limitations and known issues exist:\n\n* `COMET` (and/or FANUC's web server) seems to return response documents with a `Content-type: text/html` header.\n  Because of this, `comet_rpc` just assumes it receives JSON, even if the `content-type` header states otherwise.\n* `COMET` sometimes returns malformed response documents.\n  `comet_rpc` tries to detect this and either fixes those responses before parsing and validation, or mimics iRProgrammer's behaviour (which is to ignore).\n  This makes some actual errors hard to detect.\n  A better way to deal with this is being investigated.\n* Only a subset of the RPCs exposed by `COMET` is supported by this library.\n  Future updates may add support for more RPCs.\n* No version checking is implemented (ie: `comet_rpc` will not prevent invoking an RPC on a V8 controller which requires V9)\n* Reading and writing (system) variables (`vmip_readva` and `vmip_writeva`) returns and takes `str` representations of those variables instead of more specific types as their values.\n  This is partly due to the way `COMET` expects and returns those values and partly due to limited insight into which types are used by FANUC for those values.\n  Future updates may improve on this.\n\n## Performance\n\nEven though this library should not be used when performance is a concern, some preliminary figures are presented in this section.\n\nSee the following table for an indication of expected RPC performance:\n\n| Platform | SW version | RPC         | avg ms/call |\n|:---------|-----------:|-------------|------------:|\n| RG       | V9.30P/26  | IOVALRD     |          ~8 |\n| RG       | V9.30P/26  | VMIP_READVA |         ~14 |\n| R-30iB+  | V9.30P/??  | IOVALRD     |         ~18 |\n\nNote: this is without connection reuse, as it's unclear whether `COMET` supports this for regular RPC invocations.\n\n## Security\n\n`COMET` does not appear to be affected by the settings configured under `Host Comm`, section *HTTP Authentication*.\n\nNo authentication challenges have been observed so far, although that does not mean they are not used.\n\nSome RPCs do appear to require a valid connection id argument, and starting up such a session will lock-out the physical teach pendant with a very clear message shown to operators (stating a \"remote pendant\" is in use).\n`comet_rpc` does not currently support any RPCs requiring a connection id, nor does it lock-out the physical pendant.\n\nUsers concerned about potential undesired and uncontrolled access to the web server and `COMET` could look into configuring the host blocklist part of the *FANUC Server Access Control* feature.\nIt's unclear at this point whether any fine-grained control is possible (ie: allow reads, deny all writes), but blocking unknown hosts from interacting with `COMET` would be a first step to making it harder to abuse the JSON-RPC interface.\n\nRefer to section 2.5 *FANUC SERVER ACCESS CONTROL (FSAC)* of the *FANUC Robot series - Ethernet Function - Operator's Manual* (document B-82974EN for the R-30iA, R-30iB and R-30iB+) for more information.\n\n## Related projects\n\nFor a similar library which doesn't use `COMET` (and is compatible with older controllers), see [gavanderhoorn/dominh](https://github.com/gavanderhoorn/dominh).\n\n## Bugs, feature requests, etc\n\nPlease use the [GitHub issue tracker](https://github.com/gavanderhoorn/comet_rpc/issues).\n\n## FAQ\n\n### What's the status of COMET?\n\nIt's likely only intended to be used by FANUC internally in their products.\nThere is no public documentation which mentions it, which implies it's not a public interface.\n\n### Should this be used in production?\n\nApart from the fact that `comet_rpc` is a work-in-progress at the moment, it makes use of a (most likely) private interface.\nThis means FANUC has no obligation to maintain compatibility and they are free to change `COMET` in any way they see necessary without regards for users of this Python library.\n\nBoth of these facts make use in production deployments problematic.\n\nSee also the *NOTE* in the [Overview](#overview) section, and [Status](#status).\n\n### This is far from production-ready code\n\nYes, I agree.\nSee also the *NOTE* in the *Overview* section.\n\n### Why did you not use Go/Rust/Java/Kotlin/Swift/anything but Python?\n\nTime and application requirements: target framework supported Python, so writing `comet_rpc` in Python made sense.\n\n### Should this not be async?\n\nPerhaps.\nAll implemented RPCs so far are executed in a blocking manner on the FANUC side though, with none of the streaming or event-based ones supported (`PMON_START_MON` et al.).\nFuture versions may change the default to `async` while offering a blocking version of the API for bw compatibility.\n\n### Does this use Karel?\n\nNo.\n`COMET` is an extension to / integrated with the embedded web server running on R-30iB(+) controllers and is a native binary.\nIt does not use Karel, nor is it run in the Karel VM.\n\n### Performance is not as good as it could be\n\nCompared to the PCDK: certainly, but if you need a more performant solution, ask FANUC for a PCDK license or use a fieldbus.\nIf you have ideas on how to improve performance, post an issue [on the tracker](https://github.com/gavanderhoorn/comet_rpc/issues).\n\n### Can I submit feature/enhancement requests?\n\nOf course!\nI can't guarantee I'll have time to work on them though.\n\n### Would you take pull requests which add new features?\n\nMost certainly.\nAs long as new features (or enhancements of existing functionality) pass CI and are reasonably implemented, they will be merged.\n\n### What's the relation to Dominh?\n\n[gavanderhoorn/dominh](https://github.com/gavanderhoorn/dominh) is/was an experiment to see whether an RPC library for FANUC controllers could be created with as few required options on the controller as possible.\nBecause of this, it uses methods which are perhaps not the most efficient (such as Karel programs, KCL and `.stm` pages), but at least work on as many controllers as possible.\n\n`comet_rpc` is different: it's a low-level library which directly interfaces with an RPC interface implemented by FANUC, used by some of their web based UIs for CRX robots, iRProgrammer and remote iPendants.\nThere is no use of Karel, nor KCL.\nThe only functionality supported is what is offered by `COMET` and known from looking at iRProgrammer.\n\nTechnically, Dominh and `comet_rpc` could be used at the same time.\n\nIt's also likely Dominh will optionally use `comet_rpc` in the future to make some operations more efficient.\n\n## Disclaimer\n\nThe author of this software is not affiliated with FANUC Corporation in any way.\nAll trademarks and registered trademarks are property of their respective owners, and company, product and service names mentioned in this readme or appearing in source code or other artefacts in this repository are used for identification purposes only.\nUse of these names does not imply endorsement by FANUC Corporation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavanderhoorn%2Fcomet_rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgavanderhoorn%2Fcomet_rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavanderhoorn%2Fcomet_rpc/lists"}