This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf_sniffer_ble.sh return OSError: [Errno 22] Invalid argument

Hello,

I follow the doc to install the nrf_sniffer_for_bluetooth_le_4.1.0

- Flashing the nRF52840 dongle with nRF Connect for Desktop 

Uploading image through SDFU: 97%

Uploading image through SDFU: 98%

Uploading image through SDFU: 100%

All dfu images have been written to the target device

Failed to write: Timeout while waiting for device xxx to be attached and enumerated

Is this error OK ?

Downloading nrf_sniffer_for_bluetooth_le_4.1.0

- Update all python softwares

and run 

nrf_sniffer_ble.sh --extcap-interfaces

It crash 

extcap {version=4.1.0}{display=nRF Sniffer for Bluetooth LE}{help=www.nordicsemi.com/.../nRF-Sniffer-for-Bluetooth-LE}

Traceback (most recent call last):

  File "./nrf_sniffer_ble.py", line 818, in <module>

    extcap_interfaces()

  File "./nrf_sniffer_ble.py", line 170, in extcap_interfaces

    for interface_port in get_interfaces():

  File "./nrf_sniffer_ble.py", line 160, in get_interfaces

    devices = UART.find_sniffer()

  File "nrf_sniffer_for_bluetooth_le_4.1.0/extcap/SnifferAPI/UART.py", line 68, in find_sniffer

    reader = Packet.PacketReader(portnum=port, baudrate=rate)

  File "nrf_sniffer_for_bluetooth_le_4.1.0/extcap/SnifferAPI/Packet.py", line 74, in __init__

    self.uart = UART.Uart(portnum, baudrate)

  File "nrf_sniffer_for_bluetooth_le_4.1.0/extcap/SnifferAPI/UART.py", line 130, in __init__

    self.ser.baudrate = baudrate

  File "Library/Python/3.8/lib/python/site-packages/serial/serialutil.py", line 299, in baudrate

    self._reconfigure_port()

  File "Library/Python/3.8/lib/python/site-packages/serial/serialposix.py", line 524, in _reconfigure_port

    self._set_special_baudrate(custom_baud)

  File "Library/Python/3.8/lib/python/site-packages/serial/serialposix.py", line 225, in _set_special_baudrate    fcntl.ioctl(self.fd, IOSSIOSPEED, buf, 1)

OSError: [Errno 22] Invalid argument

macOS 12.1, python 3.8

Parents Reply Children
  • Could you please try to apply the following 2 changes to the UART.py script in your extcap directory?

    diff --git a/Host/SnifferAPI/UART.py b/Host/SnifferAPI/UART.py
    index bcae188..f4cff87 100644
    --- a/Host/SnifferAPI/UART.py
    +++ b/Host/SnifferAPI/UART.py
    @@ -123,11 +123,10 @@ class Uart:
    
    self.ser = serial.Serial(
    port=portnum,
    - baudrate=9600,
    + baudrate=baudrate,
    rtscts=True,
    exclusive=True
    )
    - self.ser.baudrate = baudrate
    
    except Exception:
    if self.ser:
  • Yes.

    I did it manually.

    self.ser = serial.Serial(
    port=portnum,
    baudrate=baudrate,
    rtscts=True,
    exclusive=True
    )

    except Exception:
    if self.ser:
    self.ser.close()
    self.ser = None
    raise

    and i get the same error.

      File "~/Library/Python/3.8/lib/python/site-packages/serial/serialposix.py", line 225, in _set_special_baudrate

        fcntl.ioctl(self.fd, IOSSIOSPEED, buf, 1)

  • It's a bit  difficult to debug as we still have not been able to replicate the issue on our end, unfortunately.  Could you try to apply this change as well:

    --- a/Host/SnifferAPI/UART.py
    +++ b/Host/SnifferAPI/UART.py
    @@ -63,7 +63,7 @@ def find_sniffer(write_data=False):
    reader = None
    l_errors = [serial.SerialException, ValueError, Exceptions.LockedException]
    if os.name == 'posix':
    - l_errors.append(termios.error)
    + l_errors.append(termios.error, OSError)
    try:
    reader = Packet.PacketReader(portnum=port, baudrate=rate)
    try:

    ?

    Thanks,

  • It gives an error

      File "nrf_sniffer_for_bluetooth_le_4.1.0/extcap/SnifferAPI/UART.py", line 66, in find_sniffer

        l_errors.append(termios.error, OSError)

    TypeError: append() takes exactly one argument (2 given)

  • Sorry, append() only lets you add one element at a time. Can you try this instead: 

    --- a/SnifferAPI/UART.py
    +++ b/SnifferAPI/UART.py
    @@ -61,7 +61,8 @@ def find_sniffer(write_data=False):
         for port in [x.device for x in open_ports]:
             for rate in SNIFFER_BAUDRATES:
                 reader = None
    -            l_errors = [serial.SerialException, ValueError, Exceptions.LockedException]
    +            l_errors = [serial.SerialException, ValueError,
    +                        Exceptions.LockedException, OSError]
                 if os.name == 'posix':
                     l_errors.append(termios.error)
                 try:

Related