This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bluetooth NUS shell transport: Error on execution of 'bt_nus_shell.py' test script

Hi,

I followed the instructions to test Bluetooth NUS shell transport sample from nRF Connect SDK v1.5.0-rc1.

After installation of the dependent script packages using 'pip' (in nRF Connect SDK v1.5.0-rc1 BASH), the execution of
test script 'bt_nus_shell.py' throws following error:

-----------------------------------------------------------------
Sanjiv Navghare@DESKTOP-3BD5AV1 MINGW64 /c/Sanju/swpath/ncs/v1.5.0-rc1/nrf/scripts/shell ((v1.5.0-rc1))
$ python bt_nus_shell.py --name BT_NUS_shell --com COM5 --family NRF52833 --snr 685782019
Traceback (most recent call last):
File "bt_nus_shell.py", line 17, in <module>
from nordicsemi.dfu.dfu_transport_ble import DFUAdapter
File "C:\Users\Sanju\AppData\Roaming\Python\Python38\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 43, in <module>
import Queue
ModuleNotFoundError: No module named 'Queue'
-----------------------------------------------------------------

So clearly the 'dfu_transport_ble.py' doesn't seem to be compatible with Python v3.


FYI, the nRF Connect SDK v1.5.0-rc1 BASH uses 'Python v3.8.2' and 'pip3 v21.0.1' and following are the versions of the installed dependent packages/scripts:
- pc-ble-driver-py-0.15.0
- nrfutil-5.0.0

Before going for test, the aforementioned script dependencies were installed with nRF Connect (v1.5.0-rc1) BASH as follows:
$ pip install --user -r scripts/shell/requirements.txt

The 'requirements.txt' did have restriction for 'nrfutil' version (i.e. nrfutil>=6.0.0) but as its installation resulted in the following error, and as described in "fixing-conflicting-dependencies" (pip.pypa.io), had to remove the version specifier for 'nrfutil', in 'requirements.txt' file, to let pip automatically find and install a version of 'nrfutil': 

--------------------------------------------------------------------------------------------------------------
ERROR: Cannot install -r scripts/shell/requirements.txt (line 2) because these package versions have conflicting dependencies.

The conflict is caused by:
nrfutil 6.1.0 depends on antlib>=1.1b0
nrfutil 6.0.1 depends on antlib>=1.1b0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit pip.pypa.io/.../
--------------------------------------------------------------------------------------------------------------

Please advice how to go about testing Bluetooth NUS Shell Transport with nRF Connect (v1.5.0-rc1) BASH (on Windows 10 system.)

Regards,

Sanju

  • Hi Sanjiv, 
    I would suggest to focus on install in nrfutil , either v6.0 or v6.1 

    Could you try to uninstall nrfutil using pip and then run the install -r requirement again ? 
    After you have nrfutil running you shouldn't have any problem with the dfu library. dfu_transport_ble.py should be able to run with Python 3. 
    I just tested here and can run the shell with no problem. 

  • I did uninstall nrfutil from 'nRF Connect SDK v1.5.0-rc1' BASH (Windows 10) and then tried to install nrfutil v6.1.0/ v6.0.1.again. But in either case, the installation fails with the following error:

    -------------------------------------------------------------------------------------------
    Collecting antlib>=1.1b0
    Using cached antlib-1.1b0.post0-py2.py3-none-any.whl (283 kB)
    WARNING: Discarding files.pythonhosted.org/.../antlib-1.1b0.post0-py2.py3-none-any.whl (from pypi.org/.../). Requested antlib>=1.1b0 from files.pythonhosted.org/.../antlib-1.1b0.post0-py2.py3-none-any.whl has inconsistent version: filename has '1.1b0.post0', but metadata has '1.1b0'
    ERROR: Could not find a version that satisfies the requirement antlib>=1.1b0 (from nrfutil)
    ERROR: No matching distribution found for antlib>=1.1b0
    -------------------------------------------------------------------------------------------

    FYI, I used 'nRF Connect SDK v1.5.0-rc1' BASH (on Windows10.) The said BASH uses "Python 3.8.2" and "pip 21.0.1"
    For details, please refer the screenshots, of nrfutil v6.1.0 and v6.0.1 installation, attached herewith.


    Please advise how to resolve the said issue!

    .nrfutil v6.1.0 installationnrfutil v6.0.1 installation

  • Hi Sanjiv, 
    I would suggest to try testing with python 3.7 as well. 

    Could you do "pip list" so that it would list all the version of the plugins ? 
    I have this when I list my plugins: 

    You can try to uninstall and install antlib again. I don't have that "warning discarding " as showed in your log,

    I would suggest to try install without the cache, after you uninstall, you use this: 

    pip install antlib --no-cache-dir

    So the cache will not be used. 

    I found this report: https://www.thisisant.com/forum/viewthread/7487

    It seems that there is a solution is to modify nrfutil itself: https://github.com/NordicSemiconductor/pc-nrfutil/commit/2351e1fe1f19d9493fc0d909055dbbf09886ae05#diff-39d3e58d66746dba5501c9661d4cb657a19ee74dfcafec9f15e5d587f513f56c

    But since I don't have any issue, I assume the issue is already fixed. 

  • The issue had been resolved!
    Here's the sequence of steps that finally ended up in resolution of the issue:


    Though the antlib installation failed even with the usage of --no-chache-dir, it succeeded when installed with reference to the URL of the antlib project's wheel:

    $ pip install --user https://files.pythonhosted.org/packages/b1/99/641f7f134b136fe33933012decf6694500f92adc118bb4bf83be04b36b48/antlib-1.1b0.post0-py2.py3-none-any.whl

    This enabled further installation of nrfutil v6.1.0 and pc-ble-driver-py v0.15.0.
    I tested BT NUS Shell with nRF52833-DK as a perperipheral device but the script then threw following error (seems the script doesn't support nRF52833):

    $ python bt_nus_shell.py --name BT_NUS_shell --com COM5 --family NRF52833 --snr 000685782019
    Traceback (most recent call last):
      File "C:\Users\Sanjiv\AppData\Roaming\Python\Python38\site-packages\pc_ble_driver_py\ble_driver.py", line 2907, in call_cmd
        return subprocess.check_output(argstr, stderr=subprocess.STDOUT, shell=True)
      File "subprocess.py", line 411, in check_output
      File "subprocess.py", line 512, in run
    subprocess.CalledProcessError: Command 'nrfjprog --snr 685782019 --memrd 327680 --w 8 --n 24 --family nrf52' returned non-zero exit status 40.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "bt_nus_shell.py", line 222, in <module>
        flash_connectivity(args.com[0], args.snr[0])
      File "bt_nus_shell.py", line 173, in flash_connectivity
        if flasher.fw_check():
      File "C:\Users\Sanjiv\AppData\Roaming\Python\Python38\site-packages\pc_ble_driver_py\ble_driver.py", line 2860, in fw_check
        fw_struct = Flasher.parse_fw_struct(self.read_fw_struct())
      File "C:\Users\Sanjiv\AppData\Roaming\Python\Python38\site-packages\pc_ble_driver_py\ble_driver.py", line 2883, in read_fw_struct
        data = self.call_cmd(args)
      File "C:\SANJIV\swpath\ncs\v1.5.0-rc1\toolchain\opt\bin\Lib\site-packages\wrapt\wrappers.py", line 605, in __call__
        return self._self_wrapper(self.__wrapped__, self._self_instance,
      File "C:\SANJIV\swpath\ncs\v1.5.0-rc1\toolchain\opt\bin\Lib\site-packages\wrapt\decorators.py", line 445, in _synchronized
        return wrapped(*args, **kwargs)
      File "C:\Users\Sanjiv\AppData\Roaming\Python\Python38\site-packages\pc_ble_driver_py\ble_driver.py", line 2912, in call_cmd
        raise RuntimeError(f"{e.__str__()}\n{e.output}")
    RuntimeError: Command 'nrfjprog --snr 685782019 --memrd 327680 --w 8 --n 24 --family nrf52' returned non-zero exit status 40.
    b'ERROR: There is no debugger connected to the PC with the given serial number.\r\n'

    As the script execution failed, I tried to manually program the nRF52833-DK using nrfjprog as follows:
    $ nrfjprog --snr 685782019 --program connectivity_4.1.2_1m_with_s132_5.1.0.hex --family nrf52

    After manual flashing of the device, I retried testing BT NUS Shell with nRF52833-DK peripheral as follows:

    $ python bt_nus_shell.py --name BT_NUS_shell --com COM5 --family NRF52833 --snr 000685782019
    Board already flashed with connectivity firmware.
    Socket created
    Socket bind complete
    Socket now listening
    

    I could then successfully test BT NUS Shell

  • Hi Sanjiv, 
    I'm glad that it worked for you now. And thanks for sharing the solution. 

Related