Skip to content

nLabs-nScope/nlabapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nlabapi

Crates.io License Documentation

Cargo Test

Low-level software interface for nLab devices. Libraries for Python and Rust are available. The recommended easy way to access data straight from the nLab is the python interface, provided by the nlabapi python package.

Python Usage

  1. Install the nlabapi python package

On an existing python installation, use pip to install the nlabapi package

$ pip install nlabapi
  1. Test Import and Usage of nlabapi Entering the above one-liner python program using python -c should print a list of all connected nLabs.
$ python -c "import nlabapi; nlabapi.LabBench.list_all_nlabs()"
Link to nLab v2 [ available: true ]
  1. Write your own scripts, or use the examples
$ python examples/list_all_nlabs.py
List of all detected nScopes:
Link to nLab v2 [ available: true ]

Building from Source

The nLab API can be built and run from source to enable users and developers to quickly iterate on nLab source code. To establish a development environment, follow the steps below.

Prerequisites

  1. Rust Toolchain (https://rustup.rs)

After installing the development dependencies, check to make sure you have a working environment by running version commands for each of the required tools.

$ rustup --version

The above commands should print a version successfully.

Note - macOS specifics

On macOS the project is configured to build a universal binary, including both x86 and Apple Silicon binaries in one. To enable that, we must add both rust target toolchains as follows:

rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin

Note - Linux specifics

On linux distributions, we need the system library headers for libusb and libudev. To install these on an Ubuntu distribtion, the following command should work.

sudo apt-get install libusb-1.0-0-dev libudev-dev

On other distributions, developers should look to their package managers for these development headers.

Clone and Install Development Dependencies

$ git clone https://github.com/nLabs-nScope/nlabapi.git
$ cd nlabapi

Build and Run

$ cargo build
$ cargo run --example list_all_nscopes

Python Development

This project also supports a python interface to the nLab. To set up an environment for python development, follow the steps below.

Prerequisites

  1. All steps above
  2. A Python 3.9 or newer installation

Create a virtual environment and activate it

$ python3 -m venv venv
$ source venv/bin/activate

Install python dependencies

$ pip install maturin

Build and install the nlabapi package for developement

$ maturin develop
$ python examples/list_all_nlabs.py 

About

A Rust library for nScope

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages