selyunin / bno055_usb_stick_py

BNO055 USB Stick Linux Python 3 Driver
MIT License
12 stars 2 forks source link

No module named pyudev #3

Closed vanvince closed 5 years ago

vanvince commented 5 years ago

HI!

I've followed every step written in guide but when I try to launch this code:

bno_usb_stick = BnoUsbStick()
reg_addr = 0x00
reg_val = bno_usb_stick.read_register(reg_addr)
print(f"bno chip id addr: 0x{reg_addr:02X}, value: 0x{reg_val:02X}")

I have this error : ModuleNotFoundError: No module named 'pyudev'. I've already installed pyudev through pip3 install pyudev Anyone can help me?

Regards, Vincenzo

selyunin commented 5 years ago

This is probably due to different python environments / versions. Using conda or virtualenv you can create multiple environments, with multiple environments and multiple python versions. Probably you install pyudev, but in some other environment or for different python version.

Try using conda and environment.yml from the project, and this guide

vanvince commented 5 years ago

Hi @selyunin,

thanks for your previous reply. By the way, I am using a raspberry pi3. I didn't mention that in the other post (sorry). So I installed berryconda (miniconda version for pi3), created the env, installed all the packages (pyserial,pyudev,dataclasses). After that I copied the whole directory (bno055_usb_stick_py) in the env directory and launch python3.6 example.py these are the results: Traceback (most recent call last): File "bnoUSBstickTEST/bno055_usb_stick_py/examples.py", line 1, in <module> from bno055_usb_stick_py import BnoUsbStick ModuleNotFoundError: No module named 'bno055_usb_stick_py' Of course everything is at its place inside the directory.

Do you have any idea about the error?

thank you in advance, Vincenzo

vanvince commented 5 years ago

Maybe I found out the issue. The missing module is bno055_usb_stickUNDERSCOREpy while inside the directory there is bno055_usb_stickDOTpy and no bno055_usb_stickUNDERSCOREpy.

What can I do?

selyunin commented 5 years ago

After resolving the dependencies for your python environment, I would recommend to install the module using pip, as it is described in the README

vanvince commented 5 years ago

Thank you @selyunin , now the code starts without the problems listed above. Nevertheless, when I run examples.py I have this message: bno055_usb_stick_py.bno055_usb_stick.BnoException: BNO USB Stick not detected! Of course bno055 usb stick is plugged!

Have I to close this Issue and open a new one?

selyunin commented 5 years ago

No need to open new issue.

I have tried this for the "red" BNO USB Stick. (1) Which PCB color BNO USB Stick you have (green / red)? (2) Can you post output from ls -la /dev/ttyACM*? (3) Can you post output from the groups? (4) Can you post output from udevadm info -q all /dev/ttyACM0 where/dev/ttyACM0 is your device corresponding to BNO USB Stick?

vanvince commented 5 years ago
  1. red

  2. crw-rw---- 1 root dialout 166, 0 giu 17 16:54 /dev/ttyACM0

  3. pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi

  4. P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/1-1.1.2:1.0/tty/ttyACM0
    N: ttyACM0
    S: serial/by-id/usb-Bosch_Sensortec_Bosch_Sensortec_BNO_stick_001-if00
    S: serial/by-path/platform-3f980000.usb-usb-0:1.1.2:1.0
    E: DEVLINKS=/dev/serial/by-id/usb-Bosch_Sensortec_Bosch_Sensortec_BNO_stick_001-if00 /dev/serial/by-path/platform-3f980000.usb-usb-0:1.1.2:1.0
    E: DEVNAME=/dev/ttyACM0
    E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/1-1.1.2:1.0/tty/ttyACM0
    E: ID_BUS=usb
    E: ID_MODEL=Bosch_Sensortec_BNO_stick
    E: ID_MODEL_ENC=Bosch\x20Sensortec\x20BNO\x20stick
    E: ID_MODEL_ID=80c1
    E: ID_PATH=platform-3f980000.usb-usb-0:1.1.2:1.0
    E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_1_2_1_0
    E: ID_REVISION=0100
    E: ID_SERIAL=Bosch_Sensortec_Bosch_Sensortec_BNO_stick_001
    E: ID_SERIAL_SHORT=001
    E: ID_TYPE=generic
    E: ID_USB_CLASS_FROM_DATABASE=Communications
    E: ID_USB_DRIVER=cdc_acm
    E: ID_USB_INTERFACES=:020201:0a0000:
    E: ID_USB_INTERFACE_NUM=00
    E: ID_VENDOR=Bosch_Sensortec
    E: ID_VENDOR_ENC=Bosch\x20Sensortec
    E: ID_VENDOR_FROM_DATABASE=Thesycon Systemsoftware & Consulting GmbH
    E: ID_VENDOR_ID=152a
    E: MAJOR=166
    E: MINOR=0
    E: SUBSYSTEM=tty
    E: TAGS=:systemd:
    E: USEC_INITIALIZED=52374254
selyunin commented 5 years ago

The inputs look right, actually it should detect the stick. Are you also running the program as root?

When creating the BnoUsbStick object try to pass the port argument, like this:

bno_usb_stick = BnoUsbStick(port='/dev/ttyACM0')
vanvince commented 5 years ago

YEAH!!! I passed the port = '/dev/ttyACM0' creating the object. Now everything is working!

Thank you very much @selyunin! 😄

selyunin commented 5 years ago

Great! Could you also help me? I want to create a small FAQ, s.t. it is easy to find out the problems and solutions. Could you please quickly summarize what problems you encountered, and how did you solve them?

vanvince commented 5 years ago

Yes of course, It is a pleasure for me!

Python dependences First of all I had problems with Python dependences and pyudev installation. In order to solve this problem I installed berryconda, Raspbery Pi's version for miniconda, so I created a virtual environment ( conda create -n envName python=3.6.1 ). With this brand new env I installed all the needed packages ( pyserial, pyudev and dataclasses), some of that through conda (conda install pyserial) while someone else through pip (pip install pyudev and pip install dataclasses). At the end I installed pip install bno055-usb-stick-py as reported in the README. At this point I had another issue.

BNO USB Stick not detected! For this one I changed the object creation inside code in this way: bno_usb_stick = BnoUsbStick(port='/dev/ttyACM0') where ttyACM0 is mine BNOUSB's port. I followed your istructions as well (expecially for dialout group)

I hope I was clear with all the issue and solutions.