-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connect("nrf52") raises "ValueError: Invalid index." #174
Comments
That looks fine to me. There's no particular reason we check against the length of the list AFAIK. A patch is more than welcome if you want to author a change! |
I'll try to submit a patch some time soon. Still slightly new to git(hub) as well as Python so I will need to figure out how to do that properly first. This seems like a good, relatively simple issue to start with and learn though. Please bare with me. Should the return value of Should I be updating the unit tests, change log, and list of contributors as well when submitting a patch? I also found found a related issue (#54). once the patch is done I think this could be closed as well. |
Yes, please update the unit tests. I will update the |
The reason it might be considered a bug is because if you were to use num_supported_devices to list all the supported devices for instance, you are currently missing out about 300 devices at the end of the list. To see where to stop we could again check if the return value of _dll.JLINKARM_DEVICE_GetInfo() is unequal to 0 for the given index. example solution: (untested, might need an extra "index -= 1" at the end if we want to return max index instead of the number of devices.) def num_supported_devices(self):
"""comment...
"""
index = int(self._dll.JLINKARM_DEVICE_GetInfo(-1, 0))
while (self._dll.JLINKARM_DEVICE_GetInfo(index, 0) == 0):
index += 1
return index current implementation for reference: def num_supported_devices(self):
"""comment...
"""
return int(self._dll.JLINKARM_DEVICE_GetInfo(-1, 0)) |
Ah okay. If |
I am trying it connect to an nRF52 device, this can normally be done without specifying the specific chip version in Jlink.
When using pylink it error's out because the index of the device when using
get_device_index("nrf52")
is 9351 whilenum_supported_devices()
returns 9211.When
connect("nrf52")
gets called the index gets checked in thesupported_device(index)
function (jlink.py line 672)When I remove the
or index >= self.num_supported_devices()
part of that check the device programs as expected. At that point I can iterate throughsupported_device(index)
as far up as index 9542. After witch_dll.JLINKARM_DEVICE_GetInfo(index, info)
starts returning non zero (returned value: 9211).From what I gather this might actually be an issue with the DLL. But unless there is a specific reason the
num_supported_devices()
check is done, I think a valid work around would be to just validate the result of the_dll.JLINKARM_DEVICE_GetInfo(index, info)
call instead of checking the index againstnum_supported_devices()
.OS: win10
DLL version: 7.88b
pylink version: 1.1.0
To reproduce:
Expected result:
success
Actual behavior:
ValueError: Invalid index.
Suggested workaround: (jlink.py line 659)
The text was updated successfully, but these errors were encountered: