invalid escape sequence \s

Greetings all. I am troubleshooting an issue on my BLE sniffer setup. While I don't 'think' this is causing my actual current failure (Wireshark not detecting COM6) I wanted to verify, if possible, that my 'fix' isn't causing more issues or just flat out wrong.

While testing the .\nrf_sniffer_ble.bat --extcap-interfaces command, I received the following error:

C:\Users\Project Help Desk\AppData\Roaming\Wireshark\extcap\nrf_sniffer_ble.py:187: SyntaxWarning: invalid escape sequence '\s'
"{validation=^\s*((37|38|39)\s*,\s*){0,2}(37|38|39){1}\s*$}{required=true}" % CTRL_ARG_ADVHOP)
C:\Users\Project Help Desk\AppData\Roaming\Wireshark\extcap\nrf_sniffer_ble.py:716: SyntaxWarning: invalid escape sequence '\s'
m = re.search("^\s*rssi\s*(>=?)\s*(-?[0-9]+)\s*$", capture_filter, re.IGNORECASE)

I checked the python code, and made the following changes:

Line 187 Installed:         "{validation=^\s*((37|38|39)\s*,\s*){0,2}(37|38|39){1}\s*$}{required=true}" % CTRL_ARG_ADVHOP)

Line 187 My Edit:          "{validation=^\\s*((37|38|39)\\s*,\\s*){0,2}(37|38|39){1}\\s*$}{required=true}" % CTRL_ARG_ADVHOP)

Line 716 Installed:         m = re.search("^\s*rssi\s*(>=?)\s*(-?[0-9]+)\s*$", capture_filter, re.IGNORECASE)

Line 716 My Edit:         m = re.search("^\\s*rssi\\s*(>=?)\\s*(-?[0-9]+)\\s*$", capture_filter, re.IGNORECASE)

So as you can see, I basically just added an additional \ to the 8 instances of \s*

Because I am troubleshooting an issue with my COM port, and because line 187 is part of get_interfaces(), it has me suspecting that my fix is just wrong. I am fairly new to Python.

My Setup:

Hardware:

Lenovo W541 Laptop

nRF52840DK with NFC Antenna installed and factory supplied USB cable from Mouser.com

Software:

Windows 10 Pro 64: 19045.3930 - Freshly installed for this project and fully updated.

Wireshark: Version 4.2.2 (v4.2.2-0-g404592842786)

nRF Connect For Desktop 4.3.0: Used for launching Programmer

Programmer 4.2.0: Used to flash firmware

Firmware File: sniffer_nrf52840dk_nrf52840_4.1.1.hex

Sniffing Program: nrf_sniffer_for_bluetooth_le_4.1.1 ------- This where I found the nrf_sniffer_ble.py file that is giving me syntax errors. ---------

Python: Python 3.12.1

Any ideas are appreciated.

  • Making the above changes, resolved my Syntax Errors, and now I just get the Wireshark COM Error. The COM error was present before and after my changes. But my changes resolved the syntax error. I am mainly verifying that my fix is valid and not causing issues before I continue to troubleshoot my original error.

  • Hi,

     

    Could you try to downgrade python to v3.11.x?

    We have not yet updated the ble sniffer for v3.12.x compatibility.

     

    Kind regards,

    Håkon

  • That did resolve the issue of syntax errors. On a side note, my original changes also resolved my errors and I was able to connect to my com port and pull traces without issue.

  • Hi,

    Project Help Desk said:
    On a side note, my original changes also resolved my errors and I was able to connect to my com port and pull traces without issue.

    Thanks for reporting this back to us. I'll report this back internally!

     

    Kind regards,

    Håkon

  • You can edit the .py file in the folder, search for \s and add a r just before the double quotes. For example, one of the lines was

        m = re.search("^\s*rssi\s*(>=?)\s*(-?[0-9]+)\s*$", capture_filter, re.IGNORECASE)

    And I turned it to:

        m = re.search(r"^\s*rssi\s*(>=?)\s*(-?[0-9]+)\s*$", capture_filter, re.IGNORECASE)

    Notice the r between the open parenthesis and the double quotes.

    I had to edit two such lines. It works now.