Skip to main content

Python wrapper around NXP LIBUSBSIO library

Project description

Python wrapper for NXP libusbsio binary library

The NXP libusbsio is a binary library for Win/Linux/MacOS systems used to exercise SPI, I2C bus and GPIO pins over USBSIO interface of NXP LPCLink2 and MCUlink Pro devices.

This Python component provides a wrapper object which encapsulates the binary library and exposes its API to Python applications.

Author: michal.hanak@nxp.com (https://www.nxp.com)

Dependencies

There are no dependencies to any external modules needed to use the LIBUSBSIO module.

Installation

pypi.org

Use pip to download and install the package

python -m pip install libusbsio

Local

Use the following pip command to install the libusbsio module from the local installation package:

python -m pip install dist/libusbsio-2.1.0-py3-none-any.whl

Running example code

Running the example code is easy. You do not even need to install the package, the example code will locate the module in the local directory (in ../libusbsio).

Go to examples directory and see the demo scripts there. Examine the script and the way how it creates the LIBUSBSIO object.

Without any constructor parameters, the USBSIO library is automatically located. There are also options to load the library from a given path.

from libusbsio import *
sio = LIBUSBSIO()

Use the loglevel parameter to specify logging verbosity:

import logging
from libusbsio import *

logging.basicConfig()
sio = LIBUSBSIO(loglevel=logging.INFO)

Running test code

The test code is located in the test directory and it is ready to be used with the unittest or pytest. Note that most of the tests assume that the target MCU application runs the siotest1 application test code which answers on SPI and I2C buses using a simple command/response protocol. The source code of the siotest application for different target boards is available as an optional part of the NXP MCUXpresso SDK package.

Run one of the following commands in the base 'python' directory. Note that some long duration tests and known-issues tests are skipped by default. See more in test/test_base.py main test file.

python -m unittest
.............s.......s...s...sssss.........s.
----------------------------------------------------------------------
Ran 45 tests in 11.034s

OK (skipped=9)

or:

pyttest

===================================== test session starts ======================================
platform win32 -- Python 3.8.7, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: d:\gitwork\libusbsio\python
collected 45 items

test\test_00_lib.py ..........                                                            [ 22%]
test\test_10_spi.py ...s....                                                              [ 40%]
test\test_20_i2c.py ...s...s...s...ssss                                                   [ 82%]
test\test_30_gpio.py ......s.                                                             [100%]

================================ 36 passed, 9 skipped in 11.38s ================================

Build installable package

The build.py script invokes the setup.py internally to build source and wheel installable packages. It also makes sure to copy up-to-date binaries from the parent's libusbsio repository into the python module.

Follow these steps to build the installable packages:

python build.py

The packages will be generated in the dist directory.

History

v2.1.0 - April 2021

  • The initial Python libusbsio library wrapper release supporting USBSIO library v2.1

Copyright NXP 2021

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

libusbsio-2.1.0-py3-none-any.whl (199.5 kB view details)

Uploaded Python 3

File details

Details for the file libusbsio-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: libusbsio-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 199.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.7

File hashes

Hashes for libusbsio-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eee08e0d3aba80175b83e1cc3f14cb9dcd230b668ed68f8efc7f6385e827cc1c
MD5 634843a842f19dd66bfad41e565b8ed7
BLAKE2b-256 ab54b0e12763b337ead33de2a296588de99b7e4cf15dc9221be82c7f1332b7ed

See more details on using hashes here.

Supported by

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