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.
- Install the
nlabapi
python package
On an existing python installation, use pip
to install the nlabapi package
$ pip install nlabapi
- Test Import and Usage of
nlabapi
Entering the above one-liner python program usingpython -c
should print a list of all connected nLabs.
$ python -c "import nlabapi; nlabapi.LabBench.list_all_nlabs()"
Link to nLab v2 [ available: true ]
- 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 ]
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.
- 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
andlibudev
. To install these on an Ubuntu distribtion, the following command should work.sudo apt-get install libusb-1.0-0-dev libudev-devOn other distributions, developers should look to their package managers for these development headers.
$ git clone https://github.com/nLabs-nScope/nlabapi.git
$ cd nlabapi
$ cargo build
$ cargo run --example list_all_nscopes
This project also supports a python interface to the nLab. To set up an environment for python development, follow the steps below.
- All steps above
- A Python 3.9 or newer installation
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install maturin
$ maturin develop
$ python examples/list_all_nlabs.py