self.assertTrue(line.is_requested())
self.assertTrue(line.is_open_drain())
self.assertFalse(line.is_open_source())
+ self.assertEqual(line.bias(), gpiod.Line.BIAS_AS_IS)
+
+ def test_exported_open_drain_line(self):
+ with gpiod.Chip(mockup.chip_name(0)) as chip:
+ line = chip.get_line(4)
+ flags = gpiod.LINE_REQ_FLAG_OPEN_DRAIN
+ line.request(consumer=default_consumer,
+ type=gpiod.LINE_REQ_DIR_OUT,
+ flags=flags)
+ self.assertEqual(line.offset(), 4)
+ self.assertEqual(line.name(), 'gpio-mockup-A-4')
+ self.assertEqual(line.direction(), gpiod.Line.DIRECTION_OUTPUT)
+ self.assertEqual(line.active_state(), gpiod.Line.ACTIVE_HIGH)
+ self.assertEqual(line.consumer(), default_consumer)
+ self.assertTrue(line.is_used())
+ self.assertTrue(line.is_requested())
+ self.assertTrue(line.is_open_drain())
+ self.assertFalse(line.is_open_source())
+ self.assertEqual(line.bias(), gpiod.Line.BIAS_AS_IS)
+
+ def test_exported_open_source_line(self):
+ with gpiod.Chip(mockup.chip_name(0)) as chip:
+ line = chip.get_line(4)
+ flags = gpiod.LINE_REQ_FLAG_OPEN_SOURCE
+ line.request(consumer=default_consumer,
+ type=gpiod.LINE_REQ_DIR_OUT,
+ flags=flags)
+ self.assertEqual(line.offset(), 4)
+ self.assertEqual(line.name(), 'gpio-mockup-A-4')
+ self.assertEqual(line.direction(), gpiod.Line.DIRECTION_OUTPUT)
+ self.assertEqual(line.active_state(), gpiod.Line.ACTIVE_HIGH)
+ self.assertEqual(line.consumer(), default_consumer)
+ self.assertTrue(line.is_used())
+ self.assertTrue(line.is_requested())
+ self.assertFalse(line.is_open_drain())
+ self.assertTrue(line.is_open_source())
+ self.assertEqual(line.bias(), gpiod.Line.BIAS_AS_IS)
+
+ def test_exported_bias_disable_line(self):
+ with gpiod.Chip(mockup.chip_name(0)) as chip:
+ line = chip.get_line(4)
+ flags = gpiod.LINE_REQ_FLAG_BIAS_DISABLE
+ line.request(consumer=default_consumer,
+ type=gpiod.LINE_REQ_DIR_OUT,
+ flags=flags)
+ self.assertEqual(line.offset(), 4)
+ self.assertEqual(line.name(), 'gpio-mockup-A-4')
+ self.assertEqual(line.direction(), gpiod.Line.DIRECTION_OUTPUT)
+ self.assertEqual(line.active_state(), gpiod.Line.ACTIVE_HIGH)
+ self.assertEqual(line.consumer(), default_consumer)
+ self.assertTrue(line.is_used())
+ self.assertTrue(line.is_requested())
+ self.assertFalse(line.is_open_drain())
+ self.assertFalse(line.is_open_source())
+ self.assertEqual(line.bias(), gpiod.Line.BIAS_DISABLE)
+
+ def test_exported_bias_pull_down_line(self):
+ with gpiod.Chip(mockup.chip_name(0)) as chip:
+ line = chip.get_line(4)
+ flags = gpiod.LINE_REQ_FLAG_BIAS_PULL_DOWN
+ line.request(consumer=default_consumer,
+ type=gpiod.LINE_REQ_DIR_OUT,
+ flags=flags)
+ self.assertEqual(line.offset(), 4)
+ self.assertEqual(line.name(), 'gpio-mockup-A-4')
+ self.assertEqual(line.direction(), gpiod.Line.DIRECTION_OUTPUT)
+ self.assertEqual(line.active_state(), gpiod.Line.ACTIVE_HIGH)
+ self.assertEqual(line.consumer(), default_consumer)
+ self.assertTrue(line.is_used())
+ self.assertTrue(line.is_requested())
+ self.assertFalse(line.is_open_drain())
+ self.assertFalse(line.is_open_source())
+ self.assertEqual(line.bias(), gpiod.Line.BIAS_PULL_DOWN)
+
+ def test_exported_bias_pull_up_line(self):
+ with gpiod.Chip(mockup.chip_name(0)) as chip:
+ line = chip.get_line(4)
+ flags = gpiod.LINE_REQ_FLAG_BIAS_PULL_UP
+ line.request(consumer=default_consumer,
+ type=gpiod.LINE_REQ_DIR_OUT,
+ flags=flags)
+ self.assertEqual(line.offset(), 4)
+ self.assertEqual(line.name(), 'gpio-mockup-A-4')
+ self.assertEqual(line.direction(), gpiod.Line.DIRECTION_OUTPUT)
+ self.assertEqual(line.active_state(), gpiod.Line.ACTIVE_HIGH)
+ self.assertEqual(line.consumer(), default_consumer)
+ self.assertTrue(line.is_used())
+ self.assertTrue(line.is_requested())
+ self.assertFalse(line.is_open_drain())
+ self.assertFalse(line.is_open_source())
+ self.assertEqual(line.bias(), gpiod.Line.BIAS_PULL_UP)
def test_update_line_info(self):
with gpiod.Chip(mockup.chip_name(0)) as chip:
#
if __name__ == '__main__':
- check_kernel(5, 2, 11)
+ check_kernel(5, 5, 0)
mockup = gpiomockup.Mockup()
unittest.main()