pynrfjprog: error -7 INVALID_SESSION

Hi there,

I intend to use pynrfjprog in development replacing another, older library. However, any call to the API which involves the nrfjprog DLL returns:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pynrfjprog import LowLevel
>>> api = LowLevel.API("NRF52")
>>> api.version()
(10, 24, 2)
>>> api.dll_version()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python310\lib\site-packages\pynrfjprog\LowLevel.py", line 186, in dll_version
raise APIError(result, error_data=self.get_errors())
pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -7 INVALID_SESSION.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This is on Win10. Python version and API version are in the snippet. Have you got any idea?

Thanks,

Norbert

Parents
  • Hello,

    You can find the documentation here:
    https://docs.nordicsemi.com/bundle/ug_pynrfjprog/page/UG/pynrfjprog/pynrfjprog_lpage.html 

    Moving forward we recommend using nrfutil instead as stated in the above link.

    In terms of what is the problem here, ensure you have installed nrfjprog, by for instance typing nrfjprog --version in a command line window.

    Comparing with the documentation you may be missing api.open() first.

    Kenneth

  • Okay, thanks. Indeed, the 'with' statement used in the examples seems to implicitly do the open(). Python magic. Seems to be due to the way the __enter__() function is defined. I can now open a connection to the device.

    Concerning nRF Util, is there a Python wrapper comparable to pynrfjprog? pynrfjprog is pretty neat in seamlessly integrating device access into Python.

  • Norbert said:
    Concerning nRF Util, is there a Python wrapper comparable to pynrfjprog?

    Sorry no, so likely you would need to call nrfutil as a subprocess or similar.

    Kenneth

Reply
  • Norbert said:
    Concerning nRF Util, is there a Python wrapper comparable to pynrfjprog?

    Sorry no, so likely you would need to call nrfutil as a subprocess or similar.

    Kenneth

Children
No Data