0

Issues communicating via I2C: BBB --> PCA9685
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Issues communicating via I2C: BBB --> PCA9685

by bRitch022 on Mon Jul 08, 2019 6:45 pm

While attempting to use the Adafruit_Python_PCA9685 library with BeagleBone Black, I am running into the following error during runtime:
IOError: [Errno 16] Device or resource busy.

I have tried using different hardware to see if that was an issue, to include new jumper wires and a new PCA9685 dev board.
All libraries are up to date and installed as well. Any thoughts?

Error snippet from Cloud9 IDE:
Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "/var/lib/cloud9/Adafruit_Python_PCA9685/examples/simpletest.py", line 17, in <module>
    pwm = Adafruit_PCA9685.PCA9685()
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_PCA9685-1.0.1-py2.7.egg/Adafruit_PCA9685/PCA9685.py", line 75, in __init__
    self.set_all_pwm(0, 0)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_PCA9685-1.0.1-py2.7.egg/Adafruit_PCA9685/PCA9685.py", line 111, in set_all_pwm
    self._device.write8(ALL_LED_ON_L, on & 0xFF)
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 116, in write8
  File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 256, in write_byte_data
IOError: [Errno 16] Device or resource busy


Version Info:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ uname -a
Linux beaglebone 4.14.71-ti-r80 #1 SMP PREEMPT Fri Oct 5 23:50:11 UTC 2018 armv7l GNU/Linux

debian@beaglebone:~$ python --version
Python 2.7.13


A look at the I2C bus data: (It's best to view this with a full browser window)
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ i2cdump 2 0x40
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2, address 0x40, mode byte
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 11 04 e2 e4 e8 e0 00 00 00 10 00 00 00 10 00 00    ??????...?...?..
10: 00 10 00 00 00 10 00 00 00 10 00 00 00 10 00 00    .?...?...?...?..
20: 00 10 00 00 00 10 00 00 00 10 00 00 00 10 00 00    .?...?...?...?..
30: 00 10 00 00 00 10 00 00 00 10 00 00 00 10 00 00    .?...?...?...?..
40: 00 10 00 00 00 10 XX XX XX XX XX XX XX XX XX XX    .?...?XXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX 00 00 00 00 1e 00    XXXXXXXXXX....?.

debian@beaglebone:~$ i2cdetect -r 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --

debian@beaglebone:/dev$ cat i2c-2
cat: i2c-2: Remote I/O error
debian@beaglebone:/dev$ cat i2c-1
cat: i2c-1: Device or resource busy
debian@beaglebone:/dev$ cat i2c-0
cat: i2c-0: Remote I/O error

debian@beaglebone:~$ i2cdetect -F 2
Functionalities implemented by /dev/i2c-2:
I2C                              yes
SMBus Quick Command              no
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               yes
SMBus Block Write                yes
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        yes
I2C Block Write                  yes
I2C Block Read                   yes


bRitch022
 
Posts: 4
Joined: Wed Jun 12, 2019 10:49 am

Re: Issues communicating via I2C: BBB --> PCA9685

by drewfustini on Thu Jul 11, 2019 9:23 am

It appears that there PCA9685 address is detected ok by i2cdetect, correct?

To dig deeper in the Python error, it would be helpful if you could run strace so that I can better understand what is happening.

Install strace (if it doesn't already exist):
Code: Select all | TOGGLE FULL SIZE
sudo apt-get install strace

Then run strace, replace test.py with the name of your test program:
Code: Select all | TOGGLE FULL SIZE
strace -f -o strace.log python test.py

Paste the contents of strace.log into a GitHub Gist and post the link in a reply here.

drewfustini
 
Posts: 903
Joined: Sat Dec 26, 2015 1:19 pm

Re: Issues communicating via I2C: BBB --> PCA9685

by bRitch022 on Fri Jul 12, 2019 10:24 am

Here it is,
https://gist.github.com/bRitch022/d5d64 ... 7f6e81731b

Also, this is happening with other I2C example programs that I have tried. I included this other one in the gist file.

bRitch022
 
Posts: 4
Joined: Wed Jun 12, 2019 10:49 am

Please be positive and constructive with your questions and comments.