def test_it_will_raise_an_exception_for_unknown(self):
        if platform.platform_detect() == platform.RASPBERRY_PI:
            self.skipTest(
                "Unknown device detection cannot be tested on a Raspberry Pi device"
            )
        if platform.platform_detect() == platform.BEAGLEBONE_BLACK:
            self.skipTest(
                "Unknown device detection cannot be tested on a Beaglebone Black device"
            )

        self.assertRaises(UnknownDeviceException, Device.detect)
def get_platform():
	"""Return a DHT platform interface for the currently detected platform."""
	plat = platform_detect.platform_detect()
	if plat == platform_detect.RASPBERRY_PI:
		import Adafruit_DHT.Raspberry_Pi as Raspberry_Pi
		return Raspberry_Pi
	elif plat == platform_detect.BEAGLEBONE_BLACK:
		import Adafruit_DHT.Beaglebone_Black as Beaglebone_Black
		return Beaglebone_Black
	else:
		raise RuntimeError('Unknown platform.')
    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())
Exemple #4
0
    def test_sensor_will_return_actual_readings(self, device:int, deviceName:str):
        if platform.platform_detect() != device:
            self.skipTest("Unable to perform full sensor test as current device is not a %s" % deviceName)

        sensor = AdafruitSensor.configureDetectedDevice(
            AdafruitSensorConfiguration.fromNameAndGpioPin('DHT22', 4)
        )

        self.assertIsInstance(sensor, AdafruitSensor)

        actualReadings = sensor.getReadings()

        self.assertGreaterEqual(actualReadings['temperature'], 0)
        self.assertGreaterEqual(actualReadings['humidity'], 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.')
Exemple #6
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.')
Exemple #7
0
	platform = platform_detect.RASPBERRY_PI
	pi_version = 1
	sys.argv.remove('--force-pi')
elif '--force-pi2' in sys.argv:
	platform = platform_detect.RASPBERRY_PI
	pi_version = 2
	sys.argv.remove('--force-pi2')
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:
Exemple #8
0
    platform = platform_detect.RASPBERRY_PI
    pi_version = 3
    sys.argv.remove('--force-pi3')
elif '--force-pi4' in sys.argv:
    platform = platform_detect.RASPBERRY_PI
    pi_version = 4
    sys.argv.remove('--force-pi4')
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 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", [
 def test_it_will_detect_a_beaglebone_black(self):
     if platform.platform_detect() != platform.BEAGLEBONE_BLACK:
         self.skipTest(
             "Beaglebone Black detection can only be tested on a Beaglebone Black device"
         )