pyBusPirateLite icon indicating copy to clipboard operation
pyBusPirateLite copied to clipboard

Current I2C Version breaks 2017 working code.

Open pacmac opened this issue 4 years ago • 0 comments

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

pacmac avatar Sep 09 '19 05:09 pacmac