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.

The binary libraries use the HID_API library code and partially also its new libusb/hidapi version to access the USB HID interface on all supported OS platforms.

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 NXP LIBUSBSIO installation package available at www.nxp.com:

python -m pip install dist/libusbsio-2.2.1-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 ================================

History

v2.2.1 - June 2026

  • Add Set/GetReadTimeout methods to control low-level HID read timeout when invoking device commands.
  • Default read timeout increased from 500ms to 2000ms.

v2.2.0 - October 2025

  • Add OpenBySerial and OpenByPath more robust calls, immune to index reordering upon re-enumeration.
  • Enumerated devices list remains valid after device close; GetNumPorts re-enumeration is no longer needed
  • Multiple LIBUSBSIO objects may be open and used simultaneously, one for each connected device.

v2.1.13 - October 2024

  • Fix HID_API Windows enumeration to avoid accidental duplicate device enumeration.

v2.1.12 - January 2023

  • Fix HID_API Windows to enable both debugger interface and USBSIO device to be open simultaneously.

v2.1.11 - February 2022

  • Source code of the library made available under BSD-3-Clause license.
  • macOS now use the libusb/hidapi version to use a new format of HID device path.

v2.1.10 - February 2022

  • Add GetDeviceInfo method to retrieve hid_api low-level information of the SIO port

v2.1.8 - November 2021

  • Add binaries for linux_armv7l and linux_aarch64

v2.1.5 - August 2021

  • Add binaries and support for arm64 macOS

v2.1.4 - July 2021

  • Extend by low-level HID_API access, fix read buffer length when reading data.
  • Refactor "PIDVID" variables, arguments and tuples to a correctly ordered "VIDPID"
  • Fix example code.

v2.1.0 - April 2021

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

Copyright NXP 2021-2026

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

libusbsio-2.2.1.tar.gz (264.6 kB view details)

Uploaded Source

Built Distribution

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

libusbsio-2.2.1-py3-none-any.whl (269.8 kB view details)

Uploaded Python 3

File details

Details for the file libusbsio-2.2.1.tar.gz.

File metadata

  • Download URL: libusbsio-2.2.1.tar.gz
  • Upload date:
  • Size: 264.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for libusbsio-2.2.1.tar.gz
Algorithm Hash digest
SHA256 65c7180d7f7717670d8c3c320f1a3f45d5c73bb13c6576790fc1a7818e380254
MD5 61c59b35856285a752fe72a102b761d8
BLAKE2b-256 2317cd0a683bb6a6edd42bd5d7e12317506d44aea00660a3ee464c241f4f557d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libusbsio-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 269.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for libusbsio-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7374a0b5754adb2ab9701e33e0a30ab64819d192bee972fd1f5a0ce3fc54380c
MD5 7db8725adc3293e455a53af938cdc8a2
BLAKE2b-256 fab9e9f702c2f7809337793d25c6e31f105aa6f1a5732ca97ba9961e1f630e1b

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