#NEWLINE# def lookup( self , addr , debug = False ) : #NEWLINE# #INDENT# ' lookup available device drivers by hex address,\n            import and create driver class,\n            setup particular devices so easily retrieved by consumers. ' #NEWLINE# if debug : #NEWLINE# #INDENT# logging . debug ( ( 'CFG:\tChecking for driver for device at i2c %s' % addr ) ) #NEWLINE# #UNINDENT# import raspberrypi #NEWLINE# if ( addr == 104 ) : #NEWLINE# #INDENT# return ( 'RTC' , 'Driver not loaded - DS1307' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( addr == 32 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from sensor.GPS_I2C import GPS_NavigatronSensor #NEWLINE# self . gps_sensor = GPS_NavigatronSensor ( i2c_bus = raspberrypi . i2c_bus ( ) , debug = debug ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# logging . warning ( ( 'CFG:\tError setting up GPS over i2c - %s' % ex ) ) #NEWLINE# #UNINDENT# return ( 'GPS' , self . gps_sensor ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( addr == 72 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from sensor.temperature_TMP102 import TemperatureSensor #NEWLINE# self . temperature_sensor = TemperatureSensor ( i2c_bus = raspberrypi . i2c_bus ( ) , debug = debug ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# logging . warning ( ( 'CFG:\tError setting up TEMPERATURE over i2c - %s' % ex ) ) #NEWLINE# #UNINDENT# return ( 'TEMPERATURE' , self . temperature_sensor ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( addr == 96 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from sensor.compass_CMPS10 import Cmps10_Sensor #NEWLINE# self . compass_sensor = Cmps10_Sensor ( i2c_bus = raspberrypi . i2c_bus ( ) , debug = debug ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# logging . warning ( ( 'CFG:\tError setting up COMPASS over i2c - %s' % ex ) ) #NEWLINE# #UNINDENT# return ( 'COMPASS' , self . compass_sensor ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( addr == 64 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from vehicle.drive_controller import AdafruitDriveController #NEWLINE# self . drive_controller = AdafruitDriveController ( i2c_addr = addr , i2c_bus = raspberrypi . i2c_bus ( ) , debug = debug ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# logging . info ( ( 'CFG:\tError setting up DRIVECONTROLLER over i2c - %s' % ex ) ) #NEWLINE# self . drive_controller = DummyDriveController ( ) #NEWLINE# #UNINDENT# return ( 'DRIVECONTROLLER' , self . drive_controller ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( addr == 50 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from vehicle.drive_controller import PyJuiceDriveController #NEWLINE# self . drive_controller = PyJuiceDriveController ( i2c_addr = addr , i2c_bus = raspberrypi . i2c_bus ( ) , debug = debug ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# logging . info ( ( 'CFG:\tError setting up DRIVECONTROLLER over i2c - %s' % ex ) ) #NEWLINE# self . drive_controller = DummyDriveController ( ) #NEWLINE# #UNINDENT# return ( 'DRIVECONTROLLER' , self . drive_controller ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self == 30 ) : #NEWLINE# #INDENT# return ( 'COMPASS' , 'Driver not loaded - HMC5883L' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( addr == 83 ) or ( addr == 29 ) ) : #NEWLINE# #INDENT# return ( 'ACCELEROMETER' , 'Driver not loaded - ADXL345' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( addr == 105 ) : #NEWLINE# #INDENT# return ( 'GYRO' , 'Driver not loaded - ITG3200' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( 'unknown' , None )