I'm using nrf_sniffer_for_bluetooth_le_4.0.0 on Ubuntu 20.04.3 and running `./nrf_sniffer_ble.py --extcap-interfaces` fails on my system. Which also means the nRF52840 dongle is not coming up in Wireshark's list of interfaces.
bash> python3 --version 23:47:43
Python 3.8.10
bash> lsb_release -a 23:49:34
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
bash> ./nrf_sniffer_ble.py --extcap-interfaces 23:49:39
extcap {version=4.0.0}{display=nRF Sniffer for Bluetooth LE}{help=https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE}
Traceback (most recent call last):
File "/home/madis/.local/lib/python3.8/site-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
OSError: [Errno 16] Device or resource busy: '/dev/ttyUSB2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/madis/.config/wireshark/extcap/SnifferAPI/Packet.py", line 74, in __init__
self.uart = UART.Uart(portnum, baudrate)
File "/home/madis/.config/wireshark/extcap/SnifferAPI/UART.py", line 117, in __init__
self.ser = serial.Serial(
File "/home/madis/.local/lib/python3.8/site-packages/serial/serialutil.py", line 240, in __init__
self.open()
File "/home/madis/.local/lib/python3.8/site-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyUSB2: [Errno 16] Device or resource busy: '/dev/ttyUSB2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./nrf_sniffer_ble.py", line 772, in <module>
extcap_interfaces()
File "./nrf_sniffer_ble.py", line 160, in extcap_interfaces
for interface_port in get_interfaces():
File "./nrf_sniffer_ble.py", line 150, in get_interfaces
devices = UART.find_sniffer()
File "/home/madis/.config/wireshark/extcap/SnifferAPI/UART.py", line 62, in find_sniffer
reader = Packet.PacketReader(portnum=port, baudrate=rate)
File "/home/madis/.config/wireshark/extcap/SnifferAPI/Packet.py", line 77, in __init__
self.uart = UART.Uart()
File "/home/madis/.config/wireshark/extcap/SnifferAPI/UART.py", line 115, in __init__
Filelock.lock(portnum)
File "/home/madis/.config/wireshark/extcap/SnifferAPI/Filelock.py", line 36, in lock
tty = os.path.basename(port)
File "/usr/lib/python3.8/posixpath.py", line 142, in basename
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Calling os.path.basename(None) results in an unhandled exception before find_sniffer() in UART.py gets to the correct device. Here's a patch that fixes the problem:
diff --git a/SnifferAPI/Filelock.py b/SnifferAPI/Filelock.py
index e923d24..b29f61f 100644
--- a/SnifferAPI/Filelock.py
+++ b/SnifferAPI/Filelock.py
@@ -33,6 +33,8 @@ def lockpid(lockfile):
def lock(port):
if platform != 'linux':
return
+ if port is None:
+ return
tty = os.path.basename(port)
lockfile = f'/var/lock/LCK..{tty}'
Would be nice if this behaviour was fixed in the next version.