def test_revision_1(self): with patch('__builtin__.open') as mock_open: handle = mock_open.return_value.__enter__.return_value handle.__iter__.return_value = iter(['Revision : 0002']) rev = Platform.pi_revision() self.assertEquals(rev, 1) with patch('__builtin__.open') as mock_open: handle = mock_open.return_value.__enter__.return_value handle.__iter__.return_value = iter(['Revision : 0003']) rev = Platform.pi_revision() self.assertEquals(rev, 1)
def test_revision_1(self): with patch('__builtin__.open') as mock_open: handle = mock_open.return_value.__enter__.return_value handle.__iter__.return_value = iter(['Revision : 0002']) rev = Platform.pi_revision() self.assertEquals(rev, 1) with patch('__builtin__.open') as mock_open: handle = mock_open.return_value.__enter__.return_value handle.__iter__.return_value = iter(['Revision : 0003']) rev = Platform.pi_revision() self.assertEquals(rev, 1)
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. For a Beaglebone Black the first user accessible bus, 1, will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 elif plat == Platform.BEAGLEBONE_BLACK: # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20). return 1 elif plat == Platform.CHIP: # CHIP has 2 user accessible I2C busses, default to 2 (U1425 and U14_26) # We want the CHIP to default to 2 as the PocketCHIP header breaks out # this interface # But, the CHIP Pro defaults to bus 1 import CHIP_IO.Utilities as UT if UT.is_chip_pro(): return 1 else: return 2 else: raise RuntimeError('Could not determine default I2C bus for platform.')
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 else: raise RuntimeError('Could not determine default I2C bus for platform.')
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. For a Beaglebone Black the first user accessible bus, 1, will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 elif plat == Platform.BEAGLEBONE_BLACK: # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20). return 1 else: raise RuntimeError('Could not determine default I2C bus for platform.')
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. For a Beaglebone Black the first user accessible bus, 1, will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 elif plat == Platform.BEAGLEBONE_BLACK: # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20). return 1 else: raise RuntimeError('Could not determine default I2C bus for platform.')
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. For a Beaglebone Black the first user accessible bus, 1, will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 elif plat == Platform.BEAGLEBONE_BLACK: # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20). return 1 elif plat == Platform.CHIP: # CHIP has 2 user accessible I2C busses, default to 2 (U1425 and U14_26) # The 4.4 Kernel CHIPs remove i2c-1 for the ability to set with a dtb overlay # and therefore isn't accessible without one return 2 else: raise RuntimeError("Could not determine default I2C bus for platform.")
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. For a Beaglebone Black the first user accessible bus, 1, will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 elif plat == Platform.BEAGLEBONE_BLACK: # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20). return 1 elif plat == Platform.CHIP: # CHIP has 2 user accessible I2C busses, default to 2 (U1425 and U14_26) # The 4.4 Kernel CHIPs remove i2c-1 for the ability to set with a dtb overlay # and therefore isn't accessible without one return 2 else: raise RuntimeError('Could not determine default I2C bus for platform.')
def get_default_bus(): """Return the default bus number based on the device platform. For a Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned. For a Beaglebone Black the first user accessible bus, 1, will be returned. """ plat = Platform.platform_detect() if plat == Platform.RASPBERRY_PI: if Platform.pi_revision() == 1: # Revision 1 Pi uses I2C bus 0. return 0 else: # Revision 2 Pi uses I2C bus 1. return 1 elif plat == Platform.BEAGLEBONE_BLACK: # Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20). return 1 #################################################################################################### #our modifaction to allow this code to work with the jetson tx2 board bus 0 elif plat == Platform.JETSON_TX2: # change the return value to the i2c bus you want to use. return 1 #return 0 orginally at BUS 0 adjusting code for all sensors to be BUS 1 else: raise RuntimeError('Could not determine default I2C bus for platform.')
def test_revision_2(self): with patch("__builtin__.open") as mock_open: handle = mock_open.return_value.__enter__.return_value handle.__iter__.return_value = iter(["Revision : 000e"]) rev = Platform.pi_revision() self.assertEquals(rev, 2)