Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current I2C Version breaks 2017 working code. #24

Open
pacmac opened this issue Sep 9, 2019 · 0 comments
Open

Current I2C Version breaks 2017 working code. #24

pacmac opened this issue Sep 9, 2019 · 0 comments

Comments

@pacmac
Copy link

pacmac commented Sep 9, 2019

Hi;

I have a python script from 2017 that was working and I decided to pull the latest version which appears to have broken I2C BB Mode.

This is the code that I previously used to initialise and connect, what is the equivalent code now ?

def i2cinit():
  global i2c
  i2c = I2C("/dev/tty.usbserial-A600aSfe", 115200, 5)
  tries=0
  
  ## Pullups - disable on sniff.
  pups=True;
  if(cmd=='sniff'): pups=False
	
  while True:
    tries+=1
    
    if(tries>1):
      print('Initializing...',tries)		
    
    if not i2c.BBmode():
      msg="Can't set binmode on Buspirate!"
      continue
    
    elif not i2c.enter_I2C():
      msg = "Can't set raw mode on Buspirate!"
      continue
    
    elif not i2c.set_speed(I2CSpeed._50KHZ):
      msg = "Can't set I2C speed on Buspirate!"
      continue
    
    elif pups and not i2c.cfg_pins(I2CPins.POWER | I2CPins.PULLUPS):
      msg = "Failed to set I2C peripherals."
      continue
    else:
      break

This just fails with:

Traceback (most recent call last):
  File "./aibobat.py", line 801, in <module>
    i2cinit();
  File "./aibobat.py", line 85, in i2cinit
    if not i2c.BBmode():
AttributeError: 'I2C' object has no attribute 'BBmode'

Is it possible to easily get my old code to run with the new version without a complete re-write ?

Many Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant