Skip to main content

Communications library and utilities for Twinleaf I/O (TIO) devices

Project description

Twinleaf Python (using the Rust backend)

This library is under active development; interfaces are subject to change.

We welcome users to test and provide feedback.

These tools only works with devices employing Twinleaf I/O Generation 2, generally devices shipped starting in 2025. For earlier devices please use the tio-python package

This package implements a communications protocol to work with Twinleaf sensors using Twinleaf I/O (TIO) as the communications layer. Data from the sensors is received via PUB messages and sensor parameters may be changed using REQ/REP messages. This python package uses the twinleaf-rust backend to provide higher performance data handling.

Installation

Common platforms are support installation from PyPI using:

`pip install twinleaf`

Programming

Examples of basic usage can be found in the examples directory.

A console script itl is installed to provide an interactive tool for configuring devices as well.

Programming

The twinleaf module performs metaprogramming to construct an object that has methods that match the RPC calls available on the device. To interact with a Twinleaf CSB current supply, for example:

import twinleaf
csb = twinleaf.Device('serial://COM1')
csb.settings.coil.x.current(0.25) # mA

To receive data streams from a sensor such as the Twinleaf VMR vector magnetometer, use the named streams:

import twinleaf
vmr = twinleaf.Device('serial://COM1')
print(vmr.samples.vector(10))

To find possible tio ports to use run tio-proxy --enum. Windows will often output some COMx port such as serial://COM3, while Mac OS will output some cu.XXXXX or tty.XXXXX name such as serial:///dev/cu.usbserialXXXXXX or serial:///dev/tty.usbmodemXXXXXX.

If tio-proxy --enum does not work try looking at serial ports in the respective OS device manager for active serial ports.

Migration from tio-python

Whereas tio-python mixed data stream and rpc methods, this package separates two two under distinct namespaces samples.* and settings.*.

Specifying a time duration for the number of samples is not yet supported; only a number of samples can be requested.

Prerequisites

Python >= 3.10 is required.

Windows issues

Windows users who can't run python might need to add python to their path.

Windows users who run into an error installing packages may need to enable long paths.

Windows console scripts are installed in an odd folder which may be added to your path:

C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts

Development

Ensure the rust compiler is installed. Use pip install -e . to build the package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twinleaf-0.2.2.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twinleaf-0.2.2-cp314-cp314-macosx_11_0_arm64.whl (539.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

Details for the file twinleaf-0.2.2.tar.gz.

File metadata

  • Download URL: twinleaf-0.2.2.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for twinleaf-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8df297fd1bc0af465250946553fa00f688dd70cd49eb3adc47217ece4c0134a0
MD5 793bbcd7ab46e99e16d29a898c9fc918
BLAKE2b-256 3c819c7ec64dd1b61bf24528c877643264eea5f4d02f5acc15ffcc14693f36b1

See more details on using hashes here.

File details

Details for the file twinleaf-0.2.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for twinleaf-0.2.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5793c6a4d3caa9f81bcc765a369588a68322f96528329b68e7f2a6debb5d11e
MD5 336951a511b53306e60f2adc29ef681c
BLAKE2b-256 025c94a659a2993f0499042b6d0d9a36aee823df0117cde56875e52a1470be00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page