def __init__(self): #Pinout can be found at: http://www.element14.com/community/servlet/JiveServlet/previewBody/73950-102-4-309126/GPIO_Pi2.png #Pin numbers refers to GPIO pin numbers print("Controller object initialized!") #Print status messages or not self.verbose = True #define max command retries self.max_tries = 5 #default slave address self.default_address = 5 #IACK gpio pin number self.iack_pin_number = 4 #Reset gpio pin number self.reset_pin_number = 17 #interupt 0 pin, maps to interupt 0 on arduino self.interupt_0_pin = 5 #interupt 1 pin, maps to interupt 1 on arduino self.interupt_1_pin = 6 #create I2C bus object on i2c port 1 self.bus = smbus.SMBus(1) #create routing table object self.rt = routing_table() #initialize gpio self.init_gpio() #initialize IACK gpio line self.init_gpio_iack() #initialize reset gpio line self.init_gpio_reset() #initialize interupt lines self.init_gpio_interupts()
import smbus import time import sys import RPi.GPIO as GPIO from routingTable import routing_table #create routing table rt = routing_table() bus = smbus.SMBus(1) default_address = 5 address_table = [] GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(4, GPIO.OUT) def init_i2c(): bus = smbus.SMBus(1) def get_table(): for x in range(0,127): try: bus.write_byte_data(x, 0x00, 111) time.sleep(0.05) address_table.append(x) except: pass print("Address table: ["),