Issues communicating via I2C: BBB --> PCA9685

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bRitch022
 
Posts: 8
Joined: Wed Jun 12, 2019 10:49 am

Issues communicating via I2C: BBB --> PCA9685

Post by bRitch022 »

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

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

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

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    .?...?BANNED
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    BANNED
f0: XX XX XX XX XX XX XX XX XX XX 00 00 00 00 1e 00    BANNED....?.

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


User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

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

Post by drewfustini »

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

sudo apt-get install strace
Then run strace, replace test.py with the name of your test program:

Code: Select all

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.

User avatar
bRitch022
 
Posts: 8
Joined: Wed Jun 12, 2019 10:49 am

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

Post by bRitch022 »

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.

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

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

Post by drewfustini »

could you please include the contents of strace.log in the gist?

this shows which system calls were made.

User avatar
bRitch022
 
Posts: 8
Joined: Wed Jun 12, 2019 10:49 am

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

Post by bRitch022 »

I was trying to access the wrong I2C bus. Once I ensured I was addressing the correct bus, it worked.
Thank you for your help Drew! I'll try to make less NOOB mistakes in the future :-p

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”