eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.37k stars 613 forks source link

i2c writeReg() failure on MinnowboardMax #251

Closed tripzero closed 9 years ago

tripzero commented 9 years ago

Here's my output from testing:

I'm testing with the max and the pca9685 PWM controller from adafruit. writeReg() returns INVALID_HANDLE (5).

>>> import mraa
>>> i = mraa.I2c(0)
>>> i.address(0x40)
0
>>> i.readReg(0x00)
0L
>>> i.writeReg(0x00, 0x31)
5
>>> quit()

i2cset, however seems to work:

root@intel-corei7-64:~# i2cset 7 0x40 0x00 0x31
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will write to device file /dev/i2c-7, chip address 0x40, data address
0x00, data 0x31, mode byte.
Continue? [Y/n] y
root@intel-corei7-64:~#
arfoll commented 9 years ago

Can you use i2c in raw mode to check its not an 0 != 7 issue?

Otherwise not sure, can you paste the output of journalctl &| syslog?

tripzero commented 9 years ago

Tried with i = mraa.I2c(0, raw=True), same result. Below is the journalctl output:

Aug 07 21:09:47 intel-corei7-64 libmraa[504]: libmraa version v0.7.3 initialised by user 'root' with EUID 0
...
Aug 07 21:18:49 intel-corei7-64 libmraa[504]: i2c: Failed to write
Aug 07 21:18:58 intel-corei7-64 libmraa[504]: i2c: Failed to write
arfoll commented 9 years ago

You'd want:

mraa.I2c(7, True) On 7 Aug 2015 22:20, "Kevron Rees" notifications@github.com wrote:

Tried with i = mraa.I2c(0, raw=True), same result. Below is the journalctl output:

Aug 07 21:09:47 intel-corei7-64 libmraa[504]: libmraa version v0.7.3 initialised by user 'root' with EUID 0 ... Aug 07 21:18:49 intel-corei7-64 libmraa[504]: i2c: Failed to write Aug 07 21:18:58 intel-corei7-64 libmraa[504]: i2c: Failed to write

— Reply to this email directly or view it on GitHub https://github.com/intel-iot-devkit/mraa/issues/251#issuecomment-128836394 .

tripzero commented 9 years ago
import mraa
i = mraa.I2c(7, True)
i.address(0x40)
i.writeReg(0x00, 0x31)
0

Looks like 0 != 7. How to fix?

arfoll commented 9 years ago

What mraa version are you running exactly? Any patches? Can you try with master and see if you can reproduce? I'd also like to see syslog output.

tripzero commented 9 years ago

Testing master without any patches I get:

import mraa
i = mraa.I2c(0) 
i.address(0x40)
5
i = mraa.I2c(7, True)
i.address(0x40)
0

journalctl sees:

Aug 11 17:14:32 intel-corei7-64 libmraa[495]: libmraa version v0.7.3 initialised by user 'root' with EUID 0 Aug 11 17:14:41 intel-corei7-64 libmraa[495]: i2c: Failed to open requested i2c port /dev/i2c-1264 Aug 11 17:14:41 intel-corei7-64 libmraa[495]: i2c: Failed to get I2C_FUNC map from device Aug 11 17:14:48 intel-corei7-64 libmraa[495]: i2c: Failed to set slave address 64

SovatnaPhon commented 5 years ago

I installed mraa, while it is problem for me with Invalid I2c bus. Can you help me?