I'm trying to get the nrf sniffer set up on a macOS machine. I'm following the steps in the documentation, and I get an error in step 3b:
./nrf_sniffer_ble.sh --extcap-interfaces
extcap {version=3.1.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 "./nrf_sniffer_ble.py", line 619, in <module>
extcap_interfaces()
File "./nrf_sniffer_ble.py", line 134, in extcap_interfaces
for interface_port in get_interfaces():
File "./nrf_sniffer_ble.py", line 125, in get_interfaces
devices = UART.find_sniffer(write_data=False) # Try non-intrusive search, set argument to True for intrusive search
File "~/.config/wireshark/extcap/SnifferAPI/UART.py", line 59, in find_sniffer
reader = Packet.PacketReader(portnum=port, baudrate=rate)
File "~/.config/wireshark/extcap/SnifferAPI/Packet.py", line 72, in __init__
self.uart = UART.Uart(portnum, baudrate)
File "~/.config/wireshark/extcap/SnifferAPI/UART.py", line 106, in __init__
self.ser = serial.Serial(
File "~/Library/Python/3.8/lib/python/site-packages/serial/serialutil.py", line 244, in __init__
self.open()
File "~/Library/Python/3.8/lib/python/site-packages/serial/serialposix.py", line 332, in open
self._reconfigure_port(force_update=True)
File "~/Library/Python/3.8/lib/python/site-packages/serial/serialposix.py", line 517, in _reconfigure_port
termios.tcsetattr(
termios.error: (22, 'Invalid argument')
Turns out the find_sniffer method in the UART module is not properly treating serial errors/exceptions on POSIX systems. I've been able to fix the issue by changing line 72 in UART.py from
except (serial.SerialException, ValueError):
to
except (serial.SerialException if os.name == "nt" else termios.error, ValueError):
and adding this import to the top of UART.py
import os
if os.name == "posix":
import termios
At least the script does not crash due to some ports not being able to be opened.