Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile bma220.py #640

Open
nageshu opened this issue Apr 15, 2018 · 9 comments
Open

Unable to compile bma220.py #640

nageshu opened this issue Apr 15, 2018 · 9 comments

Comments

@nageshu
Copy link

nageshu commented Apr 15, 2018

Hey
unable to compile a program bma220.py
error showing no module named 'upm'
can you explain?

@pylbert
Copy link
Contributor

pylbert commented Apr 15, 2018

@nageshu, make sure you install after building the modules.

The CMake install command for UPM installs python2/3 modules under ${CMAKE_INSTALL_PREFIX}/${PYTHON2/3_PACKAGES_PATH}/upm. The PYTHON2_PACKAGES_PATH can generally be site-packages or dist-packages depending on your distro.

You can grep this install path from your build directory. For examples:

$ grep 'CMAKE_INSTALL_PREFIX' CMakeCache.txt
CMAKE_INSTALL_PREFIX:PATH=/usr/local

$ grep 'PYTHON.*PACKAGES' CMakeCache.txt
PYTHON2_PACKAGES_PATH:PATH=lib/python2.7/dist-packages
PYTHON3_PACKAGES_PATH:PATH=lib/python3.5/dist-packages

Would install to:

/usr/local/lib/python2.7/dist-packages/upm

@nageshu
Copy link
Author

nageshu commented Apr 16, 2018

hey,
thank you for reply
I want to know is this command be sufficient
${CMAKE_INSTALL_PREFIX}/${PYTHON2/3_PACKAGES_PATH}/upm

because I am new at linux I am just unable to figure out the technical terms.please suggest the commands which can help me in this.
and will be beneficial if you explain the above examples.

thanks in advance!

@pylbert
Copy link
Contributor

pylbert commented Apr 16, 2018

@nageshu, most likely you need to install upm once you've built the project. Try these steps (starting from the upm directory).

mkdir build
cd build
cmake ..
make
make install (or 'sudo make install' if you're installing /usr/local/ in which case you will probably need a 'sudo ldconfig' as well)

Then open python and import the bma220 module:

$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from upm import pyupm_bma220
>>>

note - the above steps assume an install of mraa.

@nageshu
Copy link
Author

nageshu commented Apr 18, 2018

Hey,
Thank you for replying my problem is solved now program is getting compiled.

But it is showing that value error the path it is showing is as follows:
/usr/local/lib/python2.7/dist-package/upm/_pyupm_bma220.py

In this file on line 332 in__init__ . it is showing error:
Value Error : UPM invalid argument : Unknown error in i2c ::readReg()

can you tell why it is showing this error?
and what method should I approach to overcome this error?
even if i am trying to make changes but i am unable to make changes. While saving program it is showing that permission denied.

Thanks In Advance!

@pylbert
Copy link
Contributor

pylbert commented Apr 18, 2018

@nageshu,
Which platform are you using?
Make sure you provide a valid I2C bus. If you have the mraa tools installed, you can list them with

$ mraa-i2c list
Bus   0: id=05 type=linux  default
Bus   1: id=04 type=linux

You can also look into some debugging with mraa.

But it is showing that value error the path it is showing is as follows:
/usr/local/lib/python2.7/dist-package/upm/_pyupm_bma220.py

Each python module has a python wrapper (pyupm_bma220.py) and shared library (_pyupm_bma220.so - translates python calls to the base library libupm-bma220.so). None of these files are meant to be edited.

Here is a simple usage for the bma220 python module which reads the chip ID:

$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from upm import pyupm_bma220
>>> x = pyupm_bma220.BMA220(bus = 0, addr = 0xa)
>>> chipid = x.getChipID()

You can also reference the examples to see other intended usages:
https://github.com/intel-iot-devkit/upm/blob/master/examples/python/bma220.py
https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/bma220.cxx

@nageshu
Copy link
Author

nageshu commented Apr 19, 2018

Hey,
Thank you for replying,
I am using dragon board 410c having pre-installed linux in it.
as you suggested I checked i2c bus list it is showing they are working
when I gone through the method you suggested it is showing following error

I have done following process:
linaro@linaro-alip:/mraa/build/upm/examples/python$ mraa-i2c list
Bus 0: id=00 type=linux default
Bus 1: id=00 type=linux
linaro@linaro-alip:
/mraa/build/upm/examples/python$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from upm import pyupm_bma220
x= pyupm_bma220.BMA220(bus = 0, addr = 0xa)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/upm/pyupm_bma220.py", line 332, in init
this = _pyupm_bma220.new_BMA220(bus, addr)
ValueError: UPM Invalid Argument: Unknown error in I2c::readReg()

please help me resolve this it will be really helpfull.

@nageshu
Copy link
Author

nageshu commented Apr 24, 2018

Hey,
do i need to change register address according to my board?

@pylbert
Copy link
Contributor

pylbert commented Apr 25, 2018

@nageshu, I tested my up² with a bma220. For reference, here's some I2C basics.

The mraa-i2c tool shows that the mraa index of '0' (mraa's default I2C bus) is the system I2C bus '5':

$ mraa-i2c list
Bus   0: id=05 type=linux  default
Bus   1: id=04 type=linux

Doing a quick scan with mraa-i2c detect shows that there is a device on mraa I2C index '0' at 0x0a (the default I2C address of the bma220:

$ mraa-i2c detect 0
00: -- -- -- -- -- -- -- -- -- -- 0a -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

I also verified w/i2cdetect (from i2c-tools) to make sure the same addresses are returned (note, I2C system bus 5 == mraa I2C index 0) :

$ i2cdetect -y -r 5
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- 0a -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Using the UPM python module I'm able to read the bma220's chip id:

$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyupm_bma220
>>> x = pyupm_bma220.BMA220()
>>> hex(x.getChipID())
'0xdd'

If the above detect commands are not showing a device at address 0x0a, then the UPM module is not going to be able to read the device. Here are some things to try:

  1. Verify your wiring and power (my dfrobot bma220 has a (bright) blue LED)
  2. Do you need sudo to access your IO?
  3. Can you access any other devices w/I2C?
  4. Pull-ups required?
  5. Mraa will log its business to syslog (errors and info). Take a look at your syslog for more information on the failure:
$ sudo grep mraa /var/log/syslog
...
Apr 25 02:58:02 UP-APL01 libmraa[18138]: libmraa version v1.9.0-24-g91fb838 initialised by user 'neck' with EUID 1001
Apr 25 02:58:02 UP-APL01 libmraa[18138]: Adding i2c bus found on i2c-5 on adapter i2c_designware.1
Apr 25 02:58:02 UP-APL01 libmraa[18138]: Adding i2c bus found on i2c-4 on adapter i2c_designware.0
Apr 25 02:58:02 UP-APL01 libmraa[18138]: up2: kernel pinctrl driver available
Apr 25 02:58:02 UP-APL01 libmraa[18138]: gpio: support for chardev interface is activated
Apr 25 02:58:02 UP-APL01 libmraa[18138]: libmraa initialised for platform 'UP2' of type 16
Apr 25 02:58:06 UP-APL01 libmraa[18138]: i2c_init: Selected bus 0

@pylbert
Copy link
Contributor

pylbert commented May 2, 2018

@nageshu, any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants