Python wrapper around XDIMAX SUB-20 library
Project description
pysub20 is a LGPL licensed, simple pure Python binding for sub20 library: a software that allows PCs to work with a SUB-20 device. SUB-20 is a versatile and efficient bridge device providing simple interconnect between PC (USB host) and different HW devices and systems via popular interfaces such as I2C, SPI, MDIO, RS232, RS485, SMBus, ModBus, IR and others. You could find more information about the SUB-20 device on the official site: http://www.xdimax.com/sub20/sub20.html
The main goal of the project is that: to make the use of the SUB-20 library more convenient and pythonic. It’s possible to use SUB-20 dll/so directly but it’s a bit inconvenient, because every time you have to wrap the C library functions with Python c_type signatures.
Requirements
You MUST have a sub20 library installed in your system. To proceed with the installation take a look at the SUB-20 documentation: http://www.xdimax.com/sub20/sub20.html.
Usage
Low-level API: The low-level API is the raw Python functions converted from the SUB-20 C library functions. You can use them ‘as is’ with regard to the SUB-20 and Python c_types documentation.
>>> from sub20.ctypeslib.libsub import SIGNATURES, sub_version >>> from sub20.ctypeslib.utils import load_ctypes_library >>> libname = "sub20.dll" if sys.platform == "win32" else "libsub.so" >>> libsub = load_ctypes_library(libname, SIGNATURES) >>> sub_errno = c_int.in_dll(libsub, "sub_errno") ... your code with SUB-20 functions >>> libsub.sub_open(None) >>> libsub.close()
High-level API: A high level API tries to hide routine operations under the hood and make the SUB-20 library more pythonic and simple. The core of the high-level API is SUBDevice class. You don’t have to load libraries explicitly because it’s happening during the class instantiation.
>>> from sub20 import SUBDevice >>> subdev = sub20.SUBDevice() >>> subdev.open()
Then you can use the implemented functions in your code. To properly use them it’s strongly recommended to read the SUB-20 documentation first: http://www.xdimax.com/sub20/doc/sub20-man.pdf
NB: If you don’t have a sub20 library in your system and you try to create a SUBDevice instance then you’ll get an ImportError exception.
List of implemented functions:
sub_get_serial_number, sub_get_product_id, sub_get_version, sub_get_version_dict, sub_reset, sub_eep_read, sub_eep_write, sub_i2c_freq, sub_i2c_config, sub_i2c_start, sub_i2c_stop, sub_i2c_scan, sub_i2c_read, sub_i2c_write, sub_i2c_transfer, sub_gpio_config, sub_gpio_read, sub_gpio_write, sub_gpiob_config, sub_gpiob_read, sub_gpiob_write, sub_rs_set_config, sub_rs_get_config, sub_rs_timing, sub_rs_xfer, sub_fifo_config, sub_fifo_read, strerror
Examples
Under construction
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysub20-0.0.2.tar.gz
.
File metadata
- Download URL: pysub20-0.0.2.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5268c0f485b93b5dd1aea9cda0252497cbe66b273140d27280ae6997edba358c |
|
MD5 | a53c4c2f81311ab7de27a86dcc6dadb1 |
|
BLAKE2b-256 | 294a16a237d7ca52476577a8774e8b4f8dd0a09f6b02037f233efb571b1bf17c |
File details
Details for the file pysub20-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pysub20-0.0.2-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e346da4e4857693ed9c1eefd63b4d9473927631b99bc83b012146c87602faa7 |
|
MD5 | 170d6a6328262fd30b7344eb68eb1fde |
|
BLAKE2b-256 | df5664bc3c30c7c9c103bf8f89085a58c0cfc22d2dcdd653a99e164888fdd2db |