{"id":19640019,"url":"https://github.com/openthread/pyspinel","last_synced_at":"2025-04-28T11:31:01.398Z","repository":{"id":39648599,"uuid":"89260517","full_name":"openthread/pyspinel","owner":"openthread","description":"Python CLI to configure and manage OpenThread NCPs","archived":true,"fork":false,"pushed_at":"2023-09-21T19:00:53.000Z","size":284,"stargazers_count":50,"open_issues_count":0,"forks_count":54,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-04-04T12:13:15.318Z","etag":null,"topics":["hacktoberfest"],"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/openthread.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-24T16:02:46.000Z","updated_at":"2024-11-25T21:15:19.000Z","dependencies_parsed_at":"2023-01-21T08:04:34.811Z","dependency_job_id":null,"html_url":"https://github.com/openthread/pyspinel","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openthread%2Fpyspinel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openthread%2Fpyspinel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openthread%2Fpyspinel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openthread%2Fpyspinel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openthread","download_url":"https://codeload.github.com/openthread/pyspinel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304760,"owners_count":21567932,"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":["hacktoberfest"],"created_at":"2024-11-11T14:04:19.500Z","updated_at":"2025-04-28T11:30:57.949Z","avatar_url":"https://github.com/openthread.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spinel CLI Reference\n\nThe Spinel CLI exposes the OpenThread configuration and management APIs running on an NCP build via a command line interface. Spinel CLI is primarily targeted for driving the automated continuous integration tests, and is suitable for manual experimentation with controlling OpenThread NCP instances. For a production grade host driver, see [wpantund]: https://github.com/openthread/wpantund.\n\nUse the CLI to play with NCP builds of OpenThread on a Linux or Mac OS platform, including starting a basic tunnel interface to allow IPv6 applications to run on the HOST and use the Thread network.\n\nThe power of this tool is three fold:\n\n1. As a path to add testing of the NCP in simulation to continuous integration\n2. As a path to automated testing of testbeds running NCP firmware on hardware\n3. As a simple debugging tool for NCP builds of OpenThread\n\n## System Requirements\n\n| OS     | Minimum Version  |\n| ------ | ---------------- |\n| Ubuntu | 14.04 Trusty     |\n| Mac OS | 10.11 El Capitan |\n\n| Language | Minimum Version |\n| -------- | --------------- |\n| Python   | 3.6.8           |\n\n### Package installation\n\nInstall dependencies:\n\n```\n$ sudo apt install python3-pip\n$ pip3 install --user pyserial ipaddress\n```\n\nInstall Pyspinel:\n\n```\n# From pyspinel root\n$ sudo python3 setup.py install\n```\n\n## Usage\n\n### NAME\n\n    spinel-cli.py - shell tool for controlling OpenThread NCP instances\n\n### SYNOPSIS\n\n    spinel-cli.py [-hupsnqv]\n\n### DESCRIPTION\n\n```\n    -h, --help\n    \tShow this help message and exit\n\n    -u \u003cUART\u003e, --uart=\u003cUART\u003e\n       \tOpen a serial connection to the OpenThread NCP device\n\twhere \u003cUART\u003e is a device path such as \"/dev/ttyUSB0\".\n\n    -b \u003cBAUDRATE\u003e, --baudrate=\u003cBAUDRATE\u003e\n        Specify a serial connection baudrate. By default set to 115200.\n\n    --rtscts\n        Enable the serial connection hardware flow control. By default disabled.\n\n    -p \u003cPIPE\u003e, --pipe=\u003cPIPE\u003e\n        Open a piped process connection to the OpenThread NCP device\n        where \u003cPIPE\u003e is the command to start an emulator, such as\n        \"ot-ncp-ftd\".  Spinel-cli will communicate with the child process\n        via stdin/stdout.\n\n    -s \u003cSOCKET\u003e, --socket=\u003cSOCKET\u003e\n        Open a socket connection to the OpenThread NCP device\n        where \u003cSOCKET\u003e is the port to open.\n\tThis is useful for SPI configurations when used in conjunction\n\twith a spinel spi-driver daemon.\n\tNote: \u003cSOCKET\u003e will eventually map to hostname:port tuple.\n\n    -n NODEID, --nodeid=NODEID\n        The unique nodeid for the HOST and NCP instance.\n\n    -q, --quiet\n        Minimize debug and log output.\n\n    -v, --verbose\n        Maximize debug and log output.\n\n    -d \u003cDEBUG_LEVEL\u003e, --debug=\u003cDEBUG_LEVEL\u003e\n        Specify the debug level.\n\n    --vendor-path\n        Provide a custom location of the vendor package. If not specified, the\n        default location will be used (the vendor package shipped with the\n        pyspinel installation).\n        Note: The vendor package location can also be specified with\n        SPINEL_VENDOR_PATH environment variable.\n```\n\n## Quick start\n\nThe spinel-cli tool provides an intuitive command line interface, including all the standard OpenThread CLI commands, plus full history accessible by pressing the up/down keys, or searchable via ^R. There are a few commands that spinel-cli provides as well that aren't part of the standard set documented in the command reference section.\n\nFirst, clone and build a simulated OpenThread NCP, as described in [How to build OpenThread](https://openthread.io/guides/build#how_to_build_openthread) on openthread.io. After cloning bootstrapping, build the `simulation` example:\n\n```\n$ make -f \u003cpath-to-openthread\u003e/examples/Makefile-simulation\n```\n\nThen run the Pyspinel CLI, using the path to your simulated build:\n\n```\n$ cd \u003cpath-to-pyspinel\u003e\n$ spinel-cli.py -p \u003cpath-to-openthread\u003e/output/x86_64-unknown-linux-gnu/bin/ot-ncp-ftd -n 1\nOpening pipe to ../../examples/apps/ncp/ot-ncp-ftd 1\nspinel-cli \u003e version\nOPENTHREAD/20180926-01310-g9fdcef20; SIMULATION; Feb 11 2020 14:09:56\nDone\nspinel-cli \u003e panid 1234\nDone\nspinel-cli \u003e ifconfig up\nDone\nspinel-cli \u003e thread start\nDone\nspinel-cli \u003e state\nleader\nDone\nspinel-cli \u003e\n```\n\n## Running the NCP tests\n\nThe OpenThread automated test suite can be run against any of the following node types by passing the NODE_TYPE environment variable:\n\n| NODE_TYPE | Description |\n| --- | --- |\n| sim (default) | Runs against ot-cli posix emulator |\n| ncp-sim | Runs against ot-ncp posix emulator with spinel-cli |\n| soc | Runs against CLI firmware on a device connected via /dev/ttyUSB\u003cnodeid\u003e |\n\n### Manual run of NCP thread-cert test\n\n```\n# From top-level of openthread tree\n$ NODE_TYPE=ncp-sim ./script/test clean build\n$ NODE_TYPE=ncp-sim ./script/test cert tests/scripts/thread-cert/Cert_5_1_02_ChildAddressTimeout.py\n```\n\n### Run entire NCP thread-cert suite\n\n```\n# From top-level of openthread tree\n$ NODE_TYPE=ncp-sim ./script/test cert_suite tests/scripts/thread-cert/Cert_*\n```\n\n## Command reference\n\n### OpenThread CLI commands\n\nThe primary intent of spinel-cli is to support the exact syntax and output of the OpenThread CLI command set in order to seamlessly reapply the thread-cert automated test suite against NCP targets.\n\nSee [cli module][1] for more information on these commands.\n\n[1]: https://github.com/openthread/openthread/blob/main/src/cli/README.md\n\n### Diagnostics CLI commands\n\nThe Diagnostics module is enabled only when building OpenThread with the --enable-diag configure option.\n\nSee [diag module][2] for more information on these commands.\n\n[2]: https://github.com/openthread/openthread/blob/main/src/core/diags/README.md\n\n### NCP CLI commands\n\nThese commands extend beyond the core OpenThread CLI, and are specific to the spinel-cli tool for the purposes of debugging, access to NCP-specific Spinel parameters, and support of advanced configurations.\n\n- [help](#help)\n- [?](#help)\n- [v](#v)\n- [exit](#exit)\n- [quit](#quit)\n- [q](#quit)\n- [clear](#clear)\n- [history](#history)\n- [h](#history)\n- [debug](#debug)\n- [debug-term](#debug-term)\n- [ncp-tun](#ncp-tun)\n- [ncp-ml64](#ncp-ml64)\n- [ncp-ll64](#ncp-ll64)\n\n#### help\n\nDisplay help all top-level commands supported by spinel-cli.\n\n```bash\nspinel-cli \u003e help\n\nAvailable commands (type help \u003cname\u003e for more information):\n============================================================\nbufferinfo         extaddr       mode              releaserouterid\nchannel            extpanid      ncp-filter        reset\nchild              h             ncp-ll64          rloc16\nchildmax           help          ncp-ml64          route\nchildtimeout       history       ncp-raw           router\nclear              ifconfig      ncp-tun           routerdowngradethreshold\ncommissioner       ipaddr        netdataregister   routerselectionjitter\ncontextreusedelay  joiner        networkidtimeout  routerupgradethreshold\ncounters           keysequence   networkname       scan\ndebug              leaderdata    panid             state\ndebug-mem          leaderweight  parent            thread\ndiag               mac           ping              txpower\ndiscover           macfilter     prefix            v\neidcache           networkkey    q                 vendor\nexit               mfg           quit              version\n```\n\n#### help \\\u003ccommand\\\u003e\n\nDisplay detailed help on a specific command.\n\n```bash\nspinel-cli \u003e help version\n\nversion\n\n    Print the build version information.\n\n    \u003e version\n    OPENTHREAD/20180926-01310-g9fdcef20; SIMULATION; Feb 11 2020 14:09:56\n    Done\n```\n\n#### v\n\nDisplay version of spinel-cli tool.\n\n```bash\nspinel-cli \u003e v\nspinel-cli ver. 0.1.0\nCopyright (c) 2016 The OpenThread Authors.\n```\n\n#### exit\n\nExit spinel-cli. CTRL+C may also be used.\n\n#### quit\n\nExit spinel-cli. CTRL+C may also be used.\n\n### clear\n\nClear screen.\n\n#### history\n\nDisplay history of most recent commands run.\n\n```bash\nspinel-cli \u003e history\nping fd00::1\nquit\nhelp\nhistory\n```\n\n#### debug\n\nGet whether debug verbose output is enabled.\n\n```bash\nspinel-cli \u003e debug\nDEBUG_ENABLE = 0\n```\n\n#### debug \\\u003cenabled\\\u003e\n\nSet whether debug verbose output is enabled.\n\nspinel-cli \u003e debug DEBUG_ENABLE = 0\n\n```bash\nspinel-cli \u003e debug 1\nDEBUG_ENABLE = 1\nspinel-cli \u003e version\nPROP_VALUE_GET [tid=1]: NCP_VERSION\nPROP_VALUE_IS [tid=1]: NCP_VERSION = 4f:50:45:4e:54:48:52:45:41:44:2f:32:30:31:38:30:39:32:36:2d:30:31:34:30:36:2d:67:63:33:30:33:64:30:66:63:3b:20:53:49:4d:55:4c:41:54:49:4f:4e:3b:20:4d:61:72:20:20:32:20:32:30:32:30:20:31:32:3a:31:37:3a:34:33\nOPENTHREAD/20180926-01406-gc303d0fc; SIMULATION; Mar  2 2020 12:17:43\nDone\n```\n\n#### debug-term\n\nGet whether debug terminal title bar is enabled.\n\n#### debug-term \\\u003cenabled\\\u003e\n\nSet whether debug terminal title bar is enabled.\n\n#### ncp-tun\n\nControl sideband tunnel interface.\n\n#### ncp-tun up\n\nBring up Thread TUN interface.\n\n```bash\nspinel-cli \u003e ncp-tun up\nDone\n```\n\n#### ncp-tun down\n\nBring down Thread TUN interface.\n\n```bash\nspinel-cli \u003e ncp-tun down\nDone\n```\n\n#### ncp-tun add \\\u003cipaddr\\\u003e\n\nAdd an IPv6 address to the Thread TUN interface.\n\n```bash\nspinel-cli \u003e ncp-tun add 2001::dead:beef:cafe\nDone\n```\n\n#### ncp-tun del \\\u003cipaddr\\\u003e\n\nDelete an IPv6 address from the Thread TUN interface.\n\n```bash\nspinel-cli \u003e ncp-tun del 2001::dead:beef:cafe\nDone\n```\n\n#### ncp-tun ping \\\u003cipaddr\\\u003e \\[size\\] \\[count\\] \\[interval\\]\n\nSend an ICMPv6 Echo Request via a posix host system call.\n\n```bash\nspinel-cli \u003e ncp-tun ping fdde:ad00:beef:0:558:f56b:d688:799\n16 bytes from fdde:ad00:beef:0:558:f56b:d688:799: icmp_seq=1 hlim=64 time=28ms\n```\n\n#### ncp-ml64\n\nReturn the Mesh Local 64-bit IPv6 address for the node.\n\n```\nspinel-cli \u003e ncp-ml64\nfdde:ad00:beef:0:558:f56b:d688:799\nDone\n```\n\n#### ncp-ll64\n\nReturn the Link Local 64-bit IPv6 address for the node.\n\n## Vendor package\n\nExtension of the Spinel CLI with custom properties and commands. This plugin-like extension adds vendor-specific commands and properties to pyspinel in a way that does not impact the implementation of core pyspinel functionalities.\n\nThe vendor package contains the following modules:\n\n| MODULE | DESCRIPTION                                        |\n| ------ | -------------------------------------------------- |\n| vendor | Module that provides a specific vendor commands.   |\n| const  | Module with constants for vendor spinel extension. |\n| codec  | Module that provides a vendor property handlers.   |\n\nEach module comes with an example that shows how to add specific vendor codecs and constants.\n\nBy default, pyspinel will use the vendor package shipped with pyspinel installation. You can provide a custom vendor package location with --vendor-path option or SPINEL_VENDOR_PATH environment variable.\n\n### Vendor commands\n\nThe vendor package adds several vendor-specific pyspinel commands. Use the help command to list them all.\n\n```bash\nspinel-cli \u003e vendor help\nAvailable vendor commands:\n==============================================\nhelp\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenthread%2Fpyspinel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenthread%2Fpyspinel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenthread%2Fpyspinel/lists"}