Open nageshu opened 6 years ago
@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
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!
@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.
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 ininit . 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!
@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
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.
Hey, do i need to change register address according to my board?
@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:
$ 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
@nageshu, any progress?
Hey unable to compile a program bma220.py error showing no module named 'upm' can you explain?