Basic SDK for Binho Pulsar
Project description
PulsarSDK: Python SDK for Binho Pulsar USB Host Adapter
PulsarSDK is a Python package for interacting with the Binho Pulsar USB host adapter. The Pulsar adapter provides simplified control of embedded systems, supporting I2C, SPI, UART, and GPIO communication protocols.
Prerequisites
Ensure your system meets the following requirements before installing the PulsarSDK:
- Python 3.8 or higher
- Windows, macOS, or Linux
- Binho Pulsar USB host adapter with up-to-date firmware
Installation From PyPi
For the most recent update of the binhopulsar Python package on PyPi, follow these steps:
-
Open your terminal or command prompt.
-
Use pip to install the PulsarSDK:
pip install binhopulsar
Now, the PulsarSDK is installed and ready to be used in your Python projects. You can import and use it as shown in the usage example.
Installation From the Git Repository
Remember to activate your virtual environment (if you're using one) before running the installation command.
To install the PulsarSDK from your local file system, follow these steps:
-
Download the PulsarSDK package.
-
Extract the downloaded package to a folder on your local file system.
-
Open a terminal or command prompt and navigate to the folder containing the extracted PulsarSDK.
-
Install the SDK using pip with the local file path:
pip install .
Note: Make sure to include the period (.) at the end, indicating the current directory.
Now, the PulsarSDK is installed and ready to be used in your Python projects. You can import and use it as shown in the usage example.
API Overview
The Pulsar host adapter shares its API with the Binho Supernova adapter. If you're familiar with the SupernovaSDK, transitioning to the PulsarSDK will be straightforward, as the same commands and interfaces are used for the supported protocols.
Examples Repository
To see some examples of how to use this Python package, please refer to the examples repository. This repository hosts different Jupyter notebooks for all the protocol and interface APIs provided by the PulsarSDK.
Support
For help, please visit our Customer Support Portal or reach us at techsupport@binho.io.
Changelog
v1.2.0
✨ New Features
-
Persistent Voltage Configuration:
- Voltage settings for I2C, SPI, UART, and GPIO can now be optionally saved across power cycles, ensuring a seamless and predictable startup configuration.
# Set and optionally store the operating voltage. def setI2cSpiUartGpioVoltage(self, id: int, voltage_mV : c_uint16, save: bool = False) # Measure and use the external voltage. Optionally, store the voltage value. def useExternalI2cSpiUartGpioVoltage(self, id: int, save: bool = False)
🧹 Cleanups
- Unified I2C Pull-Up Resistor Values:
- Harmonized the list of supported pull-up resistor values between Pulsar and Supernova platforms.
- The firmware now validates selected resistor values, returning an
INVALID PARAMETERerror for unsupported configurations.
v1.1.0
🆕 TL;DR Highlights
- 🚀 Added
i2cControllerScanBus()to scan I2C bus (includes 10-bit addresses) - 📦 Renamed package to
binhopulsarfor PEP625 compliance - ⚙️ New
getDeviceInfo()API for consolidated device metadata - 🔌 Improved USB disconnect handling and device enumeration output
🔧 Improvements
- Enhanced Validation: Update commands validator to enforce maximum transfer length per protocol
✨ New Features
-
I2C Controller:
- Support for 10-bit addressing: Introduced support for 10-bit addressing transfers indicated with a flag in the write and read commands.
# Write to a 10-bit address target i2cControllerWrite(id=1, busId=I2C_BUS_A, targetAddress=0x308, registerAddress=[0x00,0x00], data=[0x00,0x01,0x02], is10BitTargetAddress=True) # Read to a 10-bit address target i2cControllerRead(id=2, busId=I2C_BUS_A, targetAddress=0x308, requestDataLength=3, registerAddress=[0x00,0x00], is10BitTargetAddress=True)
- Bus Scanning Support: Introduced a new method to scan the selected I2C bus and retrieve a list of connected target addresses, including 10-bit addresses.
def i2cControllerScanBus(self, id: int, busId: I2cBus, include10BitAddresses: bool = False)
-
Device info:
- New
getDeviceInfo()Method: Introduced a new method to retrieve all the device information, including the manufacturer name, product name, serial number, firmware version, hardware version and supported interfaces, such as I2C, SPI, GPIO, etc. This method is an all-in-one solution aimed at replace the methodgetUsbStringwith the different sub-command values. However, the methodgetUsbStringis still available as part of the API.
# Method signature def getDeviceInfo(self, id: int) # Response structure {'id': 6, 'command': 'SYS GET DEVICE INFO', 'result': 'SUCCESS', 'manufacturer': 'Binho LLC', 'product_name': 'Pulsar', 'serial_number': '5F4BCE79166A34559DF3081DF5A8769DA', 'hardware_version': 'B', 'firmware_version': '4.1.0', 'capabilities': {'supported_groups': ['I2C', 'SPI', 'UART', 'GPIO']}}
- New
🧹 Refactors & Cleanups
-
Package Renaming for PEP625 Compliance: Updated package name from
BinhoPulsartobinhopulsar, and renamed submodulePulsartopulsarto be compliant with PEP625.# Up to v1.0.0 pip install BinhoPulsar # From version v1.1.0 pip install binhopulsar
# Up to v1.0.0 import BinhoPulsar from BinhoPulsar.Pulsar import Pulsar from BinhoPulsar.commands.i2c.definitions import I2cPullUpResistorsValue # From v1.1.0 import binhopulsar from binhopulsar.pulsar import Pulsar from binhopulsar.commands.i2c.definitions import I2cPullUpResistorsValue
-
UsbDisconnectionErrorException Removal: This exception was removed and it is no longer thrown when the Pulsar device is unexpectedly disconnected. As in previous versions, only the system message is asynchronously returned through the registered callback to notify this event. Additionally, clients of the API must check the result returned by the API methods which returns an error if there is no communication established between the host and the device. -
Command response result: The result strings
"BUS_NOT_INITIALIZED"and"BUS_ALREADY_INITIALIZED"were renamed as"INTERFACE_NOT_INITIALIZED"and"INTERFACE_ALREADY_INITIALIZED". These strings are returned as the value of the keyresult.# Up to v1.0.0 {'id': 13, 'command': 'I2C CONTROLLER INIT', 'result': 'BUS_ALREADY_INITIALIZED', 'i2c_bus': 'I2C_BUS_A'} # From v1.1.0 {'id': 13, 'command': 'I2C CONTROLLER INIT', 'result': 'INTERFACE_ALREADY_INITIALIZED', 'i2c_bus': 'I2C_BUS_A'}
-
Device Enumeration Output Overhaul:
- Modified the structure and content of the dictionaries returned by the static method
getConnectedPulsarDevicesList(). - Added the hardware and firmware version.
- Removed unused fields.
# Up to v1.0.0 {'path': '\\\\?\\HID#VID_1FC9&PID_82FD#7&8ada5c5&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}', 'vendor_id': '0x1fc9', 'product_id': '0x82fd', 'serial_number': '12B24708C123895DB326EDA7E1FBA6D', 'release_number': 256, 'manufacturer_string': 'Binho LLC', 'product_string': 'Binho Pulsar', 'usage_page': 65280, 'usage': 1, 'interface_number': 0} # From v1.1.0 {'path': '\\\\?\\HID#VID_1FC9&PID_82FD#6&9e2d326&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}', 'vendor_id': '0x1fc9', 'product_id': '0x82fd', 'serial_number': '12B24708C123895DB326EDA7E1FBA6DA', 'manufacturer_string': 'Binho LLC', 'product_string': 'Binho Pulsar', 'hardware_version': 'B', 'firmware_version': '4.1.0'}
- Modified the structure and content of the dictionaries returned by the static method
v1.0.0
Improvements
- Enhanced Validation:
- Comprehensive ID validation added across all SDK methods.
- Preliminary 10-bit I2C Addressing Support:
- API update to include a flag in transfer methods to indicate a 10-bit target static address.
- GPIO Initial Value Setting:
- API expanded to configure the initial value when setting a GPIO as a digital output. Feature not supported yet by firmware.
- Communication Enhancements:
-
A new USB Transfer protocol was implemented to make communication between devices and host more efficient.
-
The
openmethod has been updated:- Removed the optional parameters vid and pid.
- The new USB Transfer Protocol now manages the connection internally, automatically identifying and opening the first Pulsar device based on these values.
This change simplifies device connection setup by offloading the responsibility of specifying vid and pid to the underlying protocol.
-
Refactors
Several refactors were carried out as part of the implementation of v1.0.0 to unify and standardize both the API and the dictionary responses across protocols.
- Responses dictionary standardization:
- All the keys are written in
snake_casestyle. - All the Python dictionaries returned by the API are based on a common structures containing the following
key-valuepairs:'id': integer number representing the response id.command: string name of the command.result: string indicating the result of the command request.payload_length: all those responses that return a variable length value, include this key to indicate the length of the returned variable length data.payload: this key identifies the variable length data.
- All the keys are written in
{'id':<response_id>, 'command':<command_name_string>, 'result': <result_string>, 'payload_length': <int>, 'payload': <list>}
See some examples below:
{'id': 1, 'command': 'SYS GET USB STRING', 'result': 'SUCCESS', 'payload_length': 12, 'payload': 'MN-Binho LLC'}
{'id': 6, 'command': 'SYS SET I2C SPI UART GPIO VOLTAGE', 'result': 'SUCCESS'}
{'id': 12, 'command': 'I2C CONTROLLER WRITE', 'result': 'SUCCESS', 'i2c_bus': 'I2C_BUS_A', 'payload_length': 128}
The key 'command' now identifies the command name instead of the integer number, and the key 'name' was removed.
-
Integration of protocol roles in the API methods naming: As part of the standardization process, the API methods expose the role to which the method relates to.
- UART: Simplified nomenclature by removing "Controller" from command and parameter names, since there is no controller or target roles.
- I2C: Standardized methods naming with "Controller", except for
i2cSetPullUpResistors, as it is independent of the device role.
-
Functional Consolidation:
- I2C: Unified I2C methods:
i2cWriteNonStopmerged withi2cControllerWrite(triggered by theisNonStopflag)i2cReadFromintegrated intoi2cControllerRead(invoked based on register address length)
- Voltage setting: Rename methods for clarification.
setI2cSpiUartBusVoltageassetI2cSpiUartGpioVoltageuseExternalSourceForI2cSpiUartBusVoltageasuseExternalI2cSpiUartGpioVoltage
- I2C: Unified I2C methods:
-
API Standardization:
- For the most part, all protocols are based on a set of methods to initialize and configure the device, as well as to issue transfers. For instance:
i2cControllerInit,i2cControllerSetParameters,i2cControllerWrite,i2cControllerReadspiControllerInit,spiControllerSetParameters,spiControllerTransferuartInit,uartSetParameters,uartSend
- In a near future, new methods such as
deinitandgetParametersmight be implemented too. - I2C frequencies configuration:
- In I2C, now the frequency is set through the methods
i2cControllerInitandi2cControllerSetParameters. - These changes are in line with the already implementation of the methods
uartSetParametersandspiControllerSetParametersto set the UART baudrate and SPI clock frequency respectively.
- In I2C, now the frequency is set through the methods
- For the most part, all protocols are based on a set of methods to initialize and configure the device, as well as to issue transfers. For instance:
New Features
-
I2C Bus Selector: Added
busId: I2cBusparameter to all I2C-related commands. This parameter specifies the bus used for communication. The possible options are:- I2cBus.I2C_BUS_A: Corresponds to the Qwiic port.
- I2cBus.I2C_BUS_B: Corresponds to the breakout board pins.
This update provides flexibility for interacting with devices on different I2C interfaces.
-
I2C Controller Initialization Command: Added a new method,
i2cControllerInit(id: int, busId: I2cBus, frequency: int, pullUpResistorsValue: I2cPullUpResistorsValue), for initializing the I2C controller with enhanced configuration capabilities. Possible result codes include:SUCCESSINVALID_PARAMETERFEATURE_NOT_SUPPORTED_BY_HARDWAREBUS_ALREADY_INITIALIZEDBUS_NOT_SUPPORTED
-
Voltage setting:
- Now the method
setI2cSpiUartGpioVoltageaccept the value0mV as a valid voltage value. This allows the user to turn off the power supply and as a result the downstream devices.
- Now the method
-
UsbDisconnectionError exception: A new exception was implemented which is raised when the USB Host device is unexpectedly disconnected. Deeper logic added was also added to return an error if a method is invoked after the disconnection and before a reconnection.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file binhopulsar-1.2.0.tar.gz.
File metadata
- Download URL: binhopulsar-1.2.0.tar.gz
- Upload date:
- Size: 73.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48824627b089c04ebf9b6fab01339d88fd79bc4ab95754b53f5dbb21c5360c57
|
|
| MD5 |
97efe431724c22b61e94a7c9fce2f780
|
|
| BLAKE2b-256 |
fa2199036d1fb8e9de9971a700794e30b8903b678eb9f3b44dea23f69122a032
|
File details
Details for the file binhopulsar-1.2.0-py3-none-any.whl.
File metadata
- Download URL: binhopulsar-1.2.0-py3-none-any.whl
- Upload date:
- Size: 82.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3852aada0eac4c65e06a2d68ede042de067494239c6f5853d67dea7c5ba71e74
|
|
| MD5 |
d3549a3570c518577c7b0f7116212a9d
|
|
| BLAKE2b-256 |
a17df19410dea256b27b416ea210a8ccb09fc9f003750dd563e0452604eb81db
|