Migrating to PyCosmicSDK
PyCosmicSDK replaces the older Python packages for the Supernova and the Pulsar. It includes compatibility layers that keep the old method names, argument order and return values, so for most scripts the move is a firmware update plus a changed import line.
| If the script uses | Replace the import with |
|---|---|
BinhoSupernova (binhosupernova) | pycosmicsdk.legacy.supernovasdk |
SupernovaController | pycosmicsdk.legacy.supernovacontroller |
BinhoPulsar (binhopulsar) | pycosmicsdk.legacy.pulsarsdk |
Each compatibility layer was run side by side with the package it replaces, on the same adapter, before PyCosmicSDK 0.1.1, the first release that included them.
Step 1: Make Sure the Adapter Runs Firmware 4.x
Section titled “Step 1: Make Sure the Adapter Runs Firmware 4.x”PyCosmicSDK only talks to firmware 4.x. Changing the import is not enough if the adapter runs firmware 3.x, or if the scripts use SupernovaController, which only supports firmware 3.x.
| Package in use today | Firmware it works with |
|---|---|
SupernovaController 2.1.0 | 3.x only |
BinhoSupernova 3.2.0 / 4.2.0 | 3.x / 4.x |
BinhoPulsar 0.3.0 / 1.2.0 | 3.x / 4.x |
Check the firmware without opening the adapter:
from pycosmicsdk import list_devices
for found in list_devices(): print(found.model.name, found.serial_number, "firmware", found.fw_version)4.6.1or any other 4.x version: go to Step 2. Update to the latest firmware anyway.3.x.x: update the firmware first, following Updating Firmware.bootloader: the adapter is waiting in its bootloader instead of running firmware. Finish the firmware update, following Updating Firmware.
Step 2: Install PyCosmicSDK
Section titled “Step 2: Install PyCosmicSDK”pip install pycosmicsdkSee PyCosmicSDK for the supported Python versions and platforms.
Step 3: Change the Import
Section titled “Step 3: Change the Import”The rest of the script stays the same.
BinhoSupernova
# beforefrom binhosupernova.supernova import Supernovafrom binhosupernova import getConnectedSupernovaDevicesList
# afterfrom pycosmicsdk.legacy.supernovasdk import Supernova, getConnectedSupernovaDevicesListEnums and constants that used to come from binhosupernova.commands.<protocol>.definitions are now imported directly from pycosmicsdk.legacy.supernovasdk:
# beforefrom binhosupernova.commands.i2c.definitions import I2cPullUpResistorsValue
# afterfrom pycosmicsdk.legacy.supernovasdk import I2cPullUpResistorsValueSupernovaController
# beforefrom supernovacontroller.sequential import SupernovaDevice
# afterfrom pycosmicsdk.legacy.supernovacontroller.sequential import SupernovaDeviceBinhoPulsar
# beforefrom binhopulsar.pulsar import Pulsarfrom binhopulsar import getConnectedPulsarDevicesList
# afterfrom pycosmicsdk.legacy.pulsarsdk import Pulsar, getConnectedPulsarDevicesListThe compatibility layers print a DeprecationWarning when imported, as a reminder that they are a migration path. If the test runner treats warnings as errors, run Python with -W ignore::DeprecationWarning.
What Is Different
Section titled “What Is Different”A small number of calls behave differently, and each one says so instead of failing silently:
- SupernovaController, I3C:
get_i3c_connector_status(),ccc_getacccr(),ccc_unicast_endxfer()andccc_broadcast_endxfed()return a failure explaining that the call is not available, and nothing is sent to the device. Connector plug and unplug arrive asI3cConnectorEventNotificationevents on the native API. GETACCCR and ENDXFER can still be sent through thepycosmicsdk.legacy.supernovasdklayer (i3cGETACCCR,i3cDirectENDXFER,i3cBroadcastENDXFER) orAsyncI3cCcc.transfer(). - SupernovaController, analog measurement:
measure_analog_signal()returns a failure explaining that it is not available. The same measurement is available from the native API asAsyncDevice.get_analog_measurements(). - SupernovaController, I3C rates: the few rates firmware 4.x does not have (for example 3.75 MHz) run at the nearest slower rate, with a warning that names both.
- SupernovaController, SETGRPA:
ccc_unicast_setgrpa()now needs the group address to assign:ccc_unicast_setgrpa(0x08, group_address=0x0C). - All three: entering the chip’s ISP mode (
enterIspMode) is not available.
The migration guide in the PyCosmicSDK documentation lists every difference per package, and maps the old calls to the native API. Errors in the native API are described in the errors reference.
Next Step: The Native API
Section titled “Next Step: The Native API”The compatibility layers are meant to get existing scripts running. New code should use the native API, which is typed, covers both adapters with the same calls, and adds large transfers, target mode and asyncio. See PyCosmicSDK for an introduction and PyCosmicSDK Examples for runnable scripts.
If a script behaves differently after migrating, contact us with the script and the output of the list_devices() example above.

