Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
smbus contention handling
#1
I have several threads needing to use the Raspberry Pi3 single I2C bus. The threads aren't called all that frequently, the fastest being one per second and the slowest once every 10 minutes. Since the Pi3 has four processors I believe that there will be times when two (or more) threads will try to access I2C at the same time and mess things up.

What I've done is created a global variable: i2c_busy and in each called thread I do the following before actually attempting to use the bus.

while i2c_busy
    time.sleep(.1)

i2c_busy = True
some_value = some_i2c_call()
i2c_busy = False
First question: Is there actually going to be a bus contention problem? I think yes but I could be wrong - not an expert.
Second question: Does this seem like a reasonable way of dealing with said contention?

Thanks!
Reply


Messages In This Thread
smbus contention handling - by PatM - Sep-21-2017, 01:21 PM
RE: smbus contention handling - by PatM - Sep-21-2017, 07:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Star python exception handling handling .... with traceback mg24 3 1,263 Nov-09-2022, 07:29 PM
Last Post: Gribouillis
  SMBUS 'no such file or directory' hcccs 2 5,988 Jan-31-2021, 04:47 PM
Last Post: hcccs
  SMBUS Support RWP 1 4,289 Nov-06-2017, 08:45 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020