Package: pykitcommander
pykitcommanderpykitcommander manages interaction with Microchip development kits based on PKOB nano on-board debuggerOverviewpykitcommander is available:install using pip from pypi:https://pypi.org/project/pykitcommanderbrowse source code on github:https://github.com/microchip-pic-avr-tools/pykitcommanderread API documentation on github:https://microchip-pic-avr-tools.github.io/pykitcommanderBackgroundIn many situations interaction with peripheral hardware components on a development kit is done via a "bridge" application running on the MCU on that kit.  To achieve this, the bridge firmware must be programmed onto that MCU, and then communications over a given channel and protocol can logically link the host computer to the peripheral components.pykitcommander manages some aspects of this interaction by:Containing a registry of application hex files for various applications on various kitsProgramming the application onto the kitProviding a most-probable serial-port connection string for that kitProviding an indication of what protocol format is in use on the applicationSupporting common protocol framing formats being usedUsagepykitcommander is intended to be used as a library.
Its primary consumers are:pytrustplatform (www.pypi.org/project/pytrustplatform)iotprovision (www.pypi.org/project/iotprovision)Supported kits are:AVR-IoT WG and WAPIC-IoT WG and WAAVR-IoT Cellular MiniSAM-IoT WGSAM-IoT Wx V2CryptoAuth Trust Platform Development KitSimple exampleThis example shows how pykitcommander can be used to read the serial number from an ECC608 device.  This device is connected to the MCU on the board (either PIC or AVR depending on the variant).  The MCU is connected to the host computer via a virtual serial port provided by the on-board debugger.This example uses the 'setup_kit("iotprovision")' helper function to achieve this very simply.frompykitcommander.kitprotocolsimportsetup_kit# Request iotprovision protocol to be set up on a connected kitinfo=setup_kit("iotprovision")# Create a serial connection to communicate with the firmware# Note: SerialCDC class wraps pyserial Serial classfrompyedbglib.serialport.serialcdcimportSerialCDCwithSerialCDC(info['port'],info['protocol_baud'],timeout=10,stopbits=2)asserial_connection:# The firmware driver wraps this serial connection which enables a simple command-response transaction# This is defined in pykitcommanderfrompykitcommander.firmwareinterfaceimportProvisioningFirmwareDriverfirmware_driver=ProvisioningFirmwareDriver(serial_connection)# Read out firmware versionversion=firmware_driver.firmware_command("MC+VERSION=FIRMWARE")# Send firmware command to turn LED onfirmware_driver.firmware_command("MC+SETLED",["conn","on"])# Send firmware command to read the ECC serial numberecc_serial_number=firmware_driver.firmware_command("MC+ECC+SERIAL")print("ECC serial number read out: '{}'".format(ecc_serial_number))# Send firmware command to turn LED offfirmware_driver.firmware_command("MC+SETLED",["conn","off"])DIY exampleThis example shows how pykitcommander can be used to read the serial number from an ECC608 device.  In this case, the firmware you use is your own, but complies to the same protocol as the standard provisioning firmware. The MCU is connected to the host computer via a virtual serial port provided by the on-board debugger.  In this example the serial port and baud rate are also specified explicitly.# Program firmware onto the kitfrompykitcommander.kitmanagerimportKitProgrammerprogrammer=KitProgrammer()programmer.program_application("my_firmware.hex")# Create a serial connection to communicate with the firmware# Note: SerialCDC class wraps pyserial Serial classfrompyedbglib.serialport.serialcdcimportSerialCDCwithSerialCDC("COM3",115200,timeout=10,stopbits=2)asserial_connection:# The firmware driver wraps this serial connection which enables a simple command-response transaction# This is defined in pykitcommanderfrompykitcommander.firmwareinterfaceimportProvisioningFirmwareDriverfirmware_driver=ProvisioningFirmwareDriver(serial_connection)# Read out firmware versionversion=firmware_driver.firmware_command("MC+VERSION=FIRMWARE")# Send firmware command to turn LED onfirmware_driver.firmware_command("MC+SETLED",["conn","on"])# Send firmware command to read the ECC serial numberecc_serial_number=firmware_driver.firmware_command("MC+ECC+SERIAL")print("ECC serial number read out: '{}'".format(ecc_serial_number))# Send firmware command to turn LED offfirmware_driver.firmware_command("MC+SETLED",["conn","off"])LoggingThis package uses the Python logging module for publishing log messages to library users.
A basic configuration can be used (see example below), but for best results a more thorough configuration is
recommended in order to control the verbosity of output from dependencies in the stack which also use logging.# pykitcommander uses the Python logging moduleimportlogginglogging.basicConfig(format="%(levelname)s:%(message)s",level=logging.WARNING)Notes for Linux® systemsThis package uses pyedbglib and other libraries for USB transport and some udev rules are required. For details see the pyedbglib package:https://pypi.org/project/pyedbglibChangelog[2.8] - December 2023ChangedDSG-6666 Updated AVR-IoT provisioning firmware, AVR-IoT Cellular Mini provisioning firmware, AVR-IoT Cellular Mini AWS demo and PIC-IoT Azure demo.AddedDSG-5883 Added support for SAM-IoT WxFixedDSG-6133 PEP-0440 compliance for pykitcommander[2.7] - October 2022ChangedDSG-5451 Added metadata tag for Python 3.10DSG-5549 Removed metadata tag for Python 3.6DSG-5361 Updated firmware (v1.1.7) for AVR-IoT Cellular Mini provisioningDSG-5624 Updated pyedbglib dependency requirement for improved serial port detectionFixedDSG-5017 Fixed error in example code[2.6] - June 2022AddedDSG-4393 Added link to github readme to github docsDSG-4445 Added support for CryptoAuth Trust Platform Development Kit (DM320118) provisioning firmwareDSG-4496 Added support for AVR-IoT Cellular Mini (EV70N78A) provisioning firmwareDSG-4604 Add SAM-IOT demo firmware for Azure and Google[2.3] - December 2021AddedDSG-3304 Sphinx documentationDSG-2152 New kit protocols (v2)DSG-4086 Publication to GitHib + pypi[1.0.5.8] - December 2020First public release to PyPi