Giter VIP home page Giter VIP logo

pykitinfo's Introduction

MCHP

pykitinfo - Python Kit Information

pykitinfo provides information about connected Microchip development kits and tools

pykitinfo will scan the USB subsystem for connected Microchip development kits, and provide information such as kit name, mounted device, serial port identifier, and extension information.

Install using pip from pypi.org:

pip install pykitinfo

Browse source code on github

Read API documentation on github

pykitinfo currently supports:

  • all PKOB nano (nEDBG), mEDBG and EDBG kits
  • Atmel-ICE, Power Debugger, JTAGICE3
  • PICkit3, PKOB
  • PICkit4, Snap, PKOB4, PICkit5
  • MCP2221A

Usage

pykitinfo can be used as a library or as a CLI

CLI usage

When installed using pip, pykitinfo CLI is located in the Python scripts folder.

CLI example - simple list of connected kits

pykitinfo

Displays a simple list of kits in the form: Kit SERIAL-NUMBER: 'KIT-NAME' (DEVICE-NAME) on SERIAL-PORT

For example:

pykitinfo
Looking for Microchip kits...
Compatible kits detected: 8
Kit MCHP3349011800000000: 'AVR-IoT WA' (ATmega4808) on COM21
Kit MCHP3280021800000000: 'AVR128DA48 Curiosity Nano' (AVR128DA48) on COM17
Kit ATML2241020200000000: 'SAM L21 Xplained Pro' (ATSAML21J18A) on COM34
Kit J41800000000: 'Atmel-ICE CMSIS-DAP' () on N/A
Kit J50200000000: 'Power Debugger CMSIS-DAP' () on N/A
Kit ATML2323040200000000: 'mEDBG' (ATmega328P) on COM26
Kit BUR180115004: 'Explorer 16/32 PICkit on Board' () on N/A
Kit 020063002RYN000091: 'Curiosity Nano Explorer' (N/A) on COM74

CLI example - simple list of connected kits with specific serial number

pykitinfo -s <serialnumber ending>

Displays a simple list of kits in the form: Kit SERIAL-NUMBER: 'KIT-NAME' (DEVICE-NAME) on SERIAL-PORT

For example:

pykitinfo -s 29
Looking for Microchip kits...
Compatible kits detected: 1
Kit MCHP3352011800000029: 'PIC-IoT WA' (PIC24FJ128GA705) on COM22

CLI example - brief lookup of serial port of connected kit

pykitinfo -b

Displays ONLY the serial port name of a connected kit. This can be useful for command chaining.

For example:

pykitinfo -b -s 123456
COM12

CLI example - long form list of connected kits

pykitinfo -l

Displays a JSON formatted list of dictionaries.

For example:

pykitinfo -l
Looking for Microchip kits...
Compatible kits detected: 2
[
  {
    "debugger": {
      "device": "ATmega4808",
      "kitname": "AVR-IoT WA",
      "product": "nEDBG CMSIS-DAP",
      "protocol": "edbg",
      "serial_number": "MCHP3349011800000000",
      "serial_port": "COM21"
    },
    "usb": {
      "interface": "hid",
      "packet_size": 64,
      "product_id": 8565,
      "product_string": "nEDBG CMSIS-DAP",
      "serial_number": "MCHP3349011800000000",
      "vendor_id": 1003
    }
  },
  {
    "debugger": {
      "device": "AVR128DA48",
      "kitname": "AVR128DA48 Curiosity Nano",
      "product": "nEDBG CMSIS-DAP",
      "protocol": "edbg",
      "serial_number": "MCHP3280021800000000",
      "serial_port": "COM17"
    },
    "usb": {
      "interface": "hid",
      "packet_size": 64,
      "product_id": 8565,
      "product_string": "nEDBG CMSIS-DAP",
      "serial_number": "MCHP3280021800000000",
      "vendor_id": 1003
    }
  }
]

Library usage example

pykitinfo can be imported and used as a library.

# Example usage of pykitinfo as a library
import logging
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.ERROR)
from pykitinfo import pykitinfo
kits = pykitinfo.detect_all_kits()
for kit in kits:
    print("Found kit: '{}'".format(kit['debugger']['kitname']))

Notes for Linux® systems

This 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/pyedbglib

pykitinfo's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pykitinfo's Issues

DEPRECATION: pykitinfo 0.4.0.6 has a non-standard dependency specifier pyedbglib

(py310x64venv) PS>pip install pykitinfo --upgrade
Collecting pykitinfo
  Downloading pykitinfo-0.4.0.6-py3-none-any.whl (19 kB)
Requirement already satisfied: pyusb>=1.2.0 in c:\work\python\py310x64venv\lib\site-packages (from pykitinfo) (1.2.1)
Requirement already satisfied: PyYAML in c:\work\python\py310x64venv\lib\site-packages (from pykitinfo) (6.0)
Requirement already satisfied: appdirs in c:\work\python\py310x64venv\lib\site-packages (from pykitinfo) (1.4.4)
Requirement already satisfied: pyedbglib>=2.22.* in c:\work\python\py310x64venv\lib\site-packages (from pykitinfo) (2.23.0.14)
Collecting pydebuggerconfig>=3.5 (from pykitinfo)
  Downloading pydebuggerconfig-3.9.2.121-py3-none-any.whl (217 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 217.5/217.5 kB 6.7 MB/s eta 0:00:00
Collecting crcmod (from pydebuggerconfig>=3.5->pykitinfo)
  Downloading crcmod-1.7.tar.gz (89 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.7/89.7 kB ? eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: packaging in c:\work\python\py310x64venv\lib\site-packages (from pydebuggerconfig>=3.5->pykitinfo) (23.0)
Requirement already satisfied: IntelHex in c:\work\python\py310x64venv\lib\site-packages (from pydebuggerconfig>=3.5->pykitinfo) (2.3.0)
Collecting xmlschema (from pydebuggerconfig>=3.5->pykitinfo)
  Downloading xmlschema-2.5.0-py3-none-any.whl.metadata (8.3 kB)
Requirement already satisfied: pyserial>=3.5 in c:\work\python\py310x64venv\lib\site-packages (from pyedbglib>=2.22.*->pykitinfo) (3.5)
Requirement already satisfied: cython in c:\work\python\py310x64venv\lib\site-packages (from pyedbglib>=2.22.*->pykitinfo) (3.0.0)
Requirement already satisfied: hidapi in c:\work\python\py310x64venv\lib\site-packages (from pyedbglib>=2.22.*->pykitinfo) (0.14.0)
Requirement already satisfied: setuptools>=19.0 in c:\work\python\py310x64venv\lib\site-packages (from hidapi->pyedbglib>=2.22.*->pykitinfo) (65.5.0)
Collecting elementpath<5.0.0,>=4.1.5 (from xmlschema->pydebuggerconfig>=3.5->pykitinfo)
  Downloading elementpath-4.1.5-py3-none-any.whl.metadata (6.7 kB)
Downloading xmlschema-2.5.0-py3-none-any.whl (395 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 395.0/395.0 kB 25.7 MB/s eta 0:00:00
Downloading elementpath-4.1.5-py3-none-any.whl (216 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 216.4/216.4 kB ? eta 0:00:00
Building wheels for collected packages: crcmod
  Building wheel for crcmod (setup.py) ... done
  Created wheel for crcmod: filename=crcmod-1.7-cp310-cp310-win_amd64.whl size=25182 sha256=f7b562382e0704525b6aa9638df7b4375a65006fd026b1bf307cb8c99dc6ce6e
  Stored in directory: c:\users\xiaof\appdata\local\pip\cache\wheels\85\4c\07\72215c529bd59d67e3dac29711d7aba1b692f543c808ba9e86
Successfully built crcmod
DEPRECATION: pykitinfo 0.4.0.6 has a non-standard dependency specifier pyedbglib>=2.22.*. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pykitinfo or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: crcmod, elementpath, xmlschema, pydebuggerconfig, pykitinfo
Successfully installed crcmod-1.7 elementpath-4.1.5 pydebuggerconfig-3.9.2.121 pykitinfo-0.4.0.6 xmlschema-2.5.0

when verbose, print /dev/ files that are being attempted

Hello! this looks like a pretty simple but extremely useful helper for those of us trying to get started using pyedbg!

My trouble is that I'm struggling to figure out which device file I need to change permissions on in order to get pykitinfo to succeed. Would you consider adding a bit more info to the -v debug mode that informs the user which devices it's trying to access? I have a PIC Kit 4 attached, and I'm getting this output:

glen@celeron:~$ pykitinfo -v debug
Looking for Microchip kits...
pykitinfo.pykitinfo - DEBUG - Looking for xEDBG kits
pykitinfo.pykitinfo - DEBUG - Looking for PKoB/PICkit 3 kits
pykitinfo.gen4_detect - DEBUG - Looking for Gen4 kits
pykitinfo.pykitinfo_cli - ERROR - Operation failed with ValueError: The device has no langid (permission issue, no string descriptors supported or device error)
pykitinfo.pykitinfo_cli - DEBUG - The device has no langid (permission issue, no string descriptors supported or device error)
Traceback (most recent call last):
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/pykitinfo_cli.py", line 131, in main
    return pykitinfo.pykitinfo(arguments)
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/pykitinfo.py", line 38, in pykitinfo
    kit_list = detect_all_kits()
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/pykitinfo.py", line 65, in detect_all_kits
    kit_list += detect_gen4_tools()
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/gen4_detect.py", line 116, in detect_gen4_tools
    tools = list_gen4_libusb_tools()
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/gen4_detect.py", line 72, in list_gen4_libusb_tools
    serial_number = device.serial_number
  File "/home/glen/.local/lib/python3.10/site-packages/usb/core.py", line 864, in serial_number
    self._serial_number = util.get_string(self, self.iSerialNumber)
  File "/home/glen/.local/lib/python3.10/site-packages/usb/util.py", line 313, in get_string
    raise ValueError("The device has no langid"
ValueError: The device has no langid (permission issue, no string descriptors supported or device error)

Thank you!
Glen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.