Segmentation Fault While using Open and Close Adapter API's In PC-BLE Driver

Hello,

Aim : Our application uses the PC-BLE driver for serialization purpose as well as the nrfutil for DFU purpose in the same script, we switch between the two by opening and closing the adapters regularly. We use the "adapter.driver.open()" and "adapter.driver.close()" API's to achieve this functionally.

Working : We are able to successfully use this API's to execute our application most of the times

Problem : We are facing "segmentation fault" errors while using this API's randomly. We tried tracing the origin of the segmentation fault and found out that it originates during the opening/closing of the adapter.
We assume that the issue is caused due to the adapter is busy in the connected state and we are trying to access it without verifying its state.

Please let us know if there is any API to validate the adapter is in free state and ready to be opened/closed?

Thanks

Sakib

  • Hi Sakib, 

    I'm checking internally to see if there is any API that can check the state of the adapter. Could you show the exact log of the error when it happens ? 

    But please be aware that the pc-ble-driver was provided as an example library showcasing what you can do to interface with the connectivity firmware on the nRF52. Care must be taken if you plan to use it as an end product. 

  • Hello Hung Bui,

    Following is the screen shot of the error

    Following log shows the origin of the segmentation fault that we got after placing the trace function.

    Fatal Python error: Segmentation fault
    
    Thread 0xac8ff460 (most recent call first):
      File "/usr/lib/python3.6/threading.py", line 299 in wait
      File "/usr/lib/python3.6/queue.py", line 173 in get
      File "/usr/lib/python3.6/site-packages/pc_ble_driver_py-0.15.0-py3.6-linux-armv7l.egg/pc_ble_driver_py/ble_driver.py", line 2336 in ble_event_handler_thread
      File "/usr/lib/python3.6/threading.py", line 864 in run
      File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
      File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap
    
    Thread 0xad2ff460 (most recent call first):
      File "/usr/lib/python3.6/threading.py", line 299 in wait
      File "/usr/lib/python3.6/queue.py", line 173 in get
      File "/usr/lib/python3.6/site-packages/pc_ble_driver_py-0.15.0-py3.6-linux-armv7l.egg/pc_ble_driver_py/ble_driver.py", line 2287 in status_handler_thread
      File "/usr/lib/python3.6/threading.py", line 864 in run
      File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
      File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap
    
    Thread 0xadc2e460 (most recent call first):
      File "/usr/lib/python3.6/threading.py", line 299 in wait
      File "/usr/lib/python3.6/queue.py", line 173 in get
      File "/usr/lib/python3.6/site-packages/pc_ble_driver_py-0.15.0-py3.6-linux-armv7l.egg/pc_ble_driver_py/ble_driver.py", line 2326 in log_message_handler_thread
      File "/usr/lib/python3.6/threading.py", line 864 in run
      File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
      File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap
    
    Current thread 0xaea8e010 (most recent call first):
      File "/usr/lib/python3.6/site-packages/pc_ble_driver_py-0.15.0-py3.6-linux-armv7l.egg/pc_ble_driver_py/ble_driver.py", line 1788 in close
      File "/usr/lib/python3.6/site-packages/wrapt-1.13.0rc2-py3.6-linux-armv7l.egg/wrapt/decorators.py", line 469 in _synchronized
      File "/usr/lib/python3.6/site-packages/pc_ble_driver_py-0.15.0-py3.6-linux-armv7l.egg/pc_ble_driver_py/ble_driver.py", line 101 in wrapper
      File "/home/root/smartmeshsdk/app/Simple/BleCommLib.py", line 159 in close
      File "Ble_Mote_Scheduler.py", line 1100 in disconnect_manager
      File "Ble_Mote_Scheduler.py", line 918 in start_dfu
      File "Ble_Mote_Scheduler.py", line 1168 in <module>
    Segmentation fault (core dumped)

    Do you mean that the pc-ble-driver(python) must not be used for production software, we have referred the "heart-rate-monitoring.py" example as a starting point for our development and have already developed a python script that uses the pc-ble-driver with the nrf52840 chip having connectivity firmware that enables serialization process. Also we have used the BLE custom services and characteristics.

    Please let us know if we are missing anything.

    Thanks and Regards,
    Sakib

  • Hi Sakib, 

    I wouldn't say that the pc-ble-driver-py must not be used for production software. What I meant was that the library was created as an example of what you can do. It's more of a reference that you can develop your software on. But we haven't done thorough test and may not be very stable. 


    If you are open and close the adapter, I would suggest to find a way to trigger a soft reset on the firmware running on the nRF52 so that when you open the adapter it will start fresh. 

  • If you are open and close the adapter, I would suggest to find a way to trigger a soft reset on the firmware running on the nRF52 so that when you open the adapter it will start fresh. 

    We tried this with no success.

    Next we tried using the garbage collector python library while switching the adapter, we observed that the segmentation error rate decreases.

    Please note that we are not observing this issue on the windows setup, however we are getting this issue when we are using the same script on our ARM7 32bit Quectel based SC20 processor.

    Please let us know what else we can try to resolve this issue.

    Thanks,
    Sakib

  • Hi Sakib, 

    I don't have further comment as I'm not very familiar with running Python on ARM core processor. But I have forwarded your question to our R&D team. I will let you know if I get any update. 

Related