square / square/pylink

USB JLink selection by Serial Number

Open
#151 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

beginner bug good first issue
Dominant language
Python
Stars
430
Forks
151
Avg merge
5d 3h
Merged PRs (30d)
1

Description

Hello,

I'm porting to PyLink an old Python script that used the JLINKARM.dll directly. Sometimes J-Link selection by serial number is important, the script should report an error and quit if the specific J-Link it should use does not seem to be connected. I thought that could be done at JLink object creation time, but that is not happening. The serial_no argument passed to JLink.__init__() seems to be discarded, if a J-Link with a different serial number is connected to the PC it will be used with no warning whatsoever.

Environment

Windows 10 Pro Version 21H2, Python 2.7.18, JLink 7.20a and PyLink 0.14.3

Steps to reproduce

1. import pylink
2. dbg = pylink.jlink.JLink(serial_no=600115433)
3. dbg.num_connected_emulators()
Output: 1
4. dbg.connected_emulators()
Output: [JLinkConnectInfo(J-Link PLUS <Serial No. 600115434>, Conn. USB)]
5. dbg.open()
6. dbg.serial_number
Output: 600115434

Right now it looks like the only method to actually select a J-Link by serial number is passing the serial_no parameter to the JLink.open() function. For example, if at step 5 something like the following is used:

5*. dbg.open(serial_no=600115433)

an error will be reported and my script will be able to exit with an error code as expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at JLink.init and compare how its serial_no argument is handled with JLink.open(serial_no=...). Reproduce the mismatch using the connected-emulator and open steps from the issue; done means requesting an unavailable serial number does not silently select a different J-Link and the relevant behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.