Cannot connect using the python wrapper for Metawear

Hi team,
I am having issues connecting to metawear using the python wrapper api.
This is the error I am getting, can someone help or point out the issue here ?

error 1533846775.660968: Error on line: 296 (src/blestatemachine.cc): Operation now in progress

Comments

  • That message can be ignored.

    Monitor the BT activity and confirm that a connection is indeed failing to be made.

  • Perfect ! Works just fine

  • Hi Eric:
    I did a fresh reinstall of MetaWear-SDK-Python following the instructions in
    I am having the same error message. Nothing happens on the device (MetaMotionC). I have to KeyboardInterrupt.
    Here is the trace.

    Appreciate your help.

    $ python led.py "F9:4E:B7:A1:F7:CE"error 1540422236.556516: Error on line: 296 (src/blestatemachine.cc): Operation now in progress

    ^CTraceback (most recent call last):
    File "led.py", line 11, in
    device.connect()
    File "/home/pi/SSquare/sspy35_env/lib/python3.5/site-packages/mbientlab/metawear/metawear.py", line 143, in connect
    e.wait()
    File "/usr/lib/python3.5/threading.py", line 549, in wait
    signaled = self._cond.wait(timeout)
    File "/usr/lib/python3.5/threading.py", line 293, in wait
    waiter.acquire()
    KeyboardInterrupt

  • Quoting my previous post:

    @Eric said:
    That message can be ignored.

    Monitor the BT activity and confirm that a connection is indeed failing to be made.

  • I ignore it. But nothing happens. LED does not bling.
    So I Control-C to exit.

  • Read the second sentence from my post.

  • Eric:

    Yes, I read the second sentence. There is no activity.
    Its stuck in connection.
    File "/home/pi/SSquare/sspy35_env/lib/python3.5/site-packages/mbientlab/metawear/metawear.py", line 143, in connect

    What's the solution? I checked that battery is alive.

    Appreciate your help.

    Thanks,
    Raj

  • My post asked you to monitor the BT activity. If you have done so, post a log of what the BT adapter was doing when you ran the led script.

  • I have two virtual python environments Python 2.7 and Python3.5 in which I installed the metawear packages.
    I had some installation errors installing some dependencies for metawear in Python3.5 so metawear python examples hanged in connect.

    Fortunately, in Python2.7 the example scripts (e.g. led.py) work fine.

    In Python3.5 installation, pip install pybluez[ble] failed because,
    /usr/bin/ld: cannot find -lboost_python-py34
    collect2: error: ld returned 1 exit status
    error: command 'arm-linux-gnueabihf-g++' failed with exit status 1
    So, In /usr/lib/arm-linux-gnueabihf, I did a symbolic link:
    i. sudo ln -s libboost_python-py35.so.1.62.0 libboost_python-py34.so
    ii. With that, the build succeeded, but not working.

    So for now, I can continue in Python2.7 environment and try to do a clean install metawear packages later.

    If anyone else had similar problem installing metawear packages in Python3.x environment and got it working, your please share any insight you may have.

    Thanks

  • @Eric said:
    My post asked you to monitor the BT activity. If you have done so, post a log of what the BT adapter was doing when you ran the led script.

    how exactly would you monitor the BT activity? is there a cli command. am on raspbian. thank u

  • Check out tools like btmon, learn to use it.

  • edited February 2019

    Hi all,

    A few updates. First I updated the tutorials to include a Ubuntu based setup, please see here: https://mbientlab.com/tutorials/Linux.html.

    Second, I ran a few examples and did notice that a few times you may get an error because the BLE fails to connect. You either need to try to connect again or update the Python scripts to automatically try to connect again.

    It also helps to verify this by running: sudo btmon

    That being said, on Ubuntu and Python2.7, the Python MetaWear SDK does work fine:

    The LED successfully turned on in this example and the BTMON shows a successful command set.

    Continue to ignore the src/blestatemachine.cc error.

  • Hi Laura,

    thank you for the nice tutorial. I set everything up like you described it on ubuntu and python 2.7. Now, most of the time i get the mentioned error. I tried to catch it as a python exception, but i always get a buffer overflow and python termineates completely. Have you found a workaround, so i don't have to restart my script manually until i works?

    I am using Ubuntu 18.04 and Python 2.7 and get the same error with pymetawear library and the libmetawear python library and even the scan_connect.py example provieded on github.

    Error Message:
    Connecting to E9:..:..:..:...
    error 1553596815.329482: Error on line: 296 (src/blestatemachine.cc): Operation now in progress
    *** buffer overflow detected ***: python terminated
    Abgebrochen (German for Aborted)

    the line error155.... even appears when the connection works.

    Thank you for your help

    Felix

  • If you are running on a small system like a raspberryPi, can you try to increase the swap?
    https://wpitchoune.net/tricks/raspberry_pi3_increase_swap_size.html
    http://www.linuxandubuntu.com/home/how-to-create-or-increase-swap-space-in-linux

    Can you try to run this on a different system and see if the same issue occurs (for example if you are running on raspberryPi with Raspian, try running on a Desktop Ubuntu).

    Get back to me on this.

  • Hi,
    I am using a rather capable Dell Optiplex and Ubuntu 18.04. Today I am lucky and I only got once the buffer overflow error back. So I can't reproduce the error now. Today it works like a charm. If i have bad luck another day i will try observing the swap.
    I was actually planning to use a Pi in the future. So if it fails there i am prepared. Thank you!

Sign In or Register to comment.