def test_it_will_detect_a_raspberry_pi(self):
        if platform.platform_detect() != platform.RASPBERRY_PI:
            self.skipTest(
                "Raspberry Pi detection can only be tested on a Raspberry Pi device"
            )

        expected_revision = platform.pi_revision()
        expected_version = platform.pi_version()

        device = Device.detect()
        self.assertTrue(isinstance(device, RaspberryPiDevice))
        self.assertEqual(expected_revision, device.getRevision())
        self.assertEqual(expected_version, device.getVersion())
Example #2
0
def get_platform():
	"""Return a DHT platform interface for the currently detected platform."""
	plat = platform_detect.platform_detect()
	if plat == platform_detect.RASPBERRY_PI:
		# Check for version 1 or 2 of the pi.
		version = platform_detect.pi_version()
		if version == 1:
			import Adafruit_DHT.Raspberry_Pi as Raspberry_Pi
			return Raspberry_Pi
		elif version == 2:
			import Adafruit_DHT.Raspberry_Pi_2  as Raspberry_Pi_2
			return Raspberry_Pi_2
		else:
			raise RuntimeError('No driver for detected Raspberry Pi version available!')
	elif plat == platform_detect.BEAGLEBONE_BLACK:
		import Adafruit_DHT.Beaglebone_Black as Beaglebone_Black
		return Beaglebone_Black
	else:
		raise RuntimeError('Unknown platform.')
Example #3
0
def get_platform():
    """Return a DHT platform interface for the currently detected platform."""
    plat = platform_detect.platform_detect()
    if plat == platform_detect.RASPBERRY_PI:
        # Check for version 1 or 2 of the pi.
        version = platform_detect.pi_version()
        if version == 1:
            import Adafruit_DHT.Raspberry_Pi as Raspberry_Pi
            return Raspberry_Pi
        elif version == 2:
            import Adafruit_DHT.Raspberry_Pi_2 as Raspberry_Pi_2
            return Raspberry_Pi_2
        else:
            raise RuntimeError(
                'No driver for detected Raspberry Pi version available!')
    elif plat == platform_detect.BEAGLEBONE_BLACK:
        import Adafruit_DHT.Beaglebone_Black as Beaglebone_Black
        return Beaglebone_Black
    else:
        raise RuntimeError('Unknown platform.')
Example #4
0
elif '--force-bbb' in sys.argv:
	platform = platform_detect.BEAGLEBONE_BLACK
	sys.argv.remove('--force-bbb')
elif '--force-test' in sys.argv:
	platform = 'TEST'
	sys.argv.remove('--force-test')
else:
	# No explicit platform chosen, detect the current platform.
	platform = platform_detect.platform_detect()

# Pick the right extension to compile based on the platform.
extensions = []
if platform == platform_detect.RASPBERRY_PI:
	# Get the Pi version (1 or 2)
	if pi_version is None:
		pi_version = platform_detect.pi_version()
	# Build the right extension depending on the Pi version.
	if pi_version == 1:
		extensions.append(Extension("Adafruit_DHT.Raspberry_Pi_Driver",
									["source/_Raspberry_Pi_Driver.c", "source/common_dht_read.c",
									 "source/Raspberry_Pi/pi_dht_read.c", "source/Raspberry_Pi/pi_mmio.c"],
									libraries=['rt'],
									extra_compile_args=['-std=gnu99']))
	elif pi_version == 2:
		extensions.append(Extension("Adafruit_DHT.Raspberry_Pi_2_Driver",
									["source/_Raspberry_Pi_2_Driver.c", "source/common_dht_read.c",
									 "source/Raspberry_Pi_2/pi_2_dht_read.c", "source/Raspberry_Pi_2/pi_2_mmio.c"],
									libraries=['rt'],
									extra_compile_args=['-std=gnu99']))
	else:
		raise RuntimeError('Detected Pi version that has no appropriate driver available.')
Example #5
0
    platform = 'TEST'
    sys.argv.remove('--force-test')
else:
    # No explicit platform chosen, detect the current platform.
    platform = platform_detect.platform_detect()

# Pick the right extension to compile based on the platform.
extensions = []
if not is_binary_install():
    print(
        'Skipped loading platform-specific extensions for Adafruit_DHT (we are generating a cross-platform source distribution).'
    )
elif platform == platform_detect.RASPBERRY_PI:
    # Get the Pi version
    if pi_version is None:
        pi_version = platform_detect.pi_version()
    # Build the right extension depending on the Pi version.
    if pi_version == 1:
        extensions.append(
            Extension("Adafruit_DHT.Raspberry_Pi_Driver", [
                "source/_Raspberry_Pi_Driver.c", "source/common_dht_read.c",
                "source/Raspberry_Pi/pi_dht_read.c",
                "source/Raspberry_Pi/pi_mmio.c"
            ],
                      libraries=['rt'],
                      extra_compile_args=['-std=gnu99']))
    elif pi_version >= 2 and pi_version <= 4:
        extensions.append(
            Extension("Adafruit_DHT.Raspberry_Pi_2_Driver", [
                "source/_Raspberry_Pi_2_Driver.c", "source/common_dht_read.c",
                "source/Raspberry_Pi_2/pi_2_dht_read.c",