Skip to content

Commit ccb2313

Browse files
authored
Merge pull request #265 from makermelissa/main
Improved Detector Script and fixed some missing edge cases
2 parents 7126b96 + a8ef1a2 commit ccb2313

File tree

2 files changed

+60
-39
lines changed

2 files changed

+60
-39
lines changed

adafruit_platformdetect/board.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,25 @@ def any_libre_computer_board(self) -> bool:
772772
"""Check whether the current board is any defined Libre Computer board."""
773773
return self.id in boards._LIBRE_COMPUTER_IDS
774774

775+
@property
776+
def os_environ_board(self) -> bool:
777+
"""Check whether the current board is an OS environment variable special case."""
778+
779+
def lazily_generate_conditions():
780+
yield self.board.FTDI_FT232H
781+
yield self.board.FTDI_FT2232H
782+
yield self.board.MICROCHIP_MCP2221
783+
yield self.board.BINHO_NOVA
784+
yield self.board.GREATFET_ONE
785+
yield self.board.PICO_U2IF
786+
yield self.board.FEATHER_U2IF
787+
yield self.board.ITSYBITY_U2IF
788+
yield self.board.MACROPAD_U2IF
789+
yield self.board.QTPY_U2IF
790+
yield self.board.QT2040_TRINKEY_U2IF
791+
792+
return any(condition for condition in lazily_generate_conditions())
793+
775794
@property
776795
def any_embedded_linux(self) -> bool:
777796
"""Check whether the current board is any embedded Linux device."""
@@ -806,9 +825,15 @@ def lazily_generate_conditions():
806825
yield self.any_lichee_riscv_board
807826
yield self.any_pcduino_board
808827
yield self.any_libre_computer_board
828+
yield self.generic_linux
809829

810830
return any(condition for condition in lazily_generate_conditions())
811831

832+
@property
833+
def generic_linux(self) -> bool:
834+
"""Check whether the current board is an Generic Linux System."""
835+
return self.id == boards.GENERIC_LINUX_PC
836+
812837
@property
813838
def ftdi_ft232h(self) -> bool:
814839
"""Check whether the current board is an FTDI FT232H."""

bin/detect.py

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,55 +25,54 @@
2525

2626
detector = adafruit_platformdetect.Detector()
2727

28+
print("Board Detection Test")
29+
print()
30+
print("Check that the Chip and Board IDs match your board and that this it is")
31+
print("correctly detecting whether or not it is a Linux board.")
32+
print()
2833
print("Chip id: ", detector.chip.id)
2934
print("Board id: ", detector.board.id)
3035
print()
36+
print("Linux Detection")
37+
print("---------------")
38+
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
39+
print()
40+
print("Raspberry Pi Boards")
41+
print("-------------------")
42+
if detector.board.any_raspberry_pi:
43+
print("Raspberry Pi detected.")
44+
print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
45+
print("Is this a Pi 4B?", detector.board.RASPBERRY_PI_4B)
46+
print("Is this a 40-pin Raspberry Pi?", detector.board.any_raspberry_pi_40_pin)
47+
print("Is this a Raspberry Pi Compute Module?", detector.board.any_raspberry_pi_cm)
48+
print()
3149

50+
print("Other Boards")
51+
print("-------------------")
3252
print(
3353
"Is this a Siemens Simatic IOT2000 Gateway?",
3454
detector.board.any_siemens_simatic_iot2000,
3555
)
36-
print("Is this a DragonBoard 410c?", detector.board.DRAGONBOARD_410C)
37-
print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
38-
print("Is this a Pi 4B?", detector.board.RASPBERRY_PI_4B)
39-
print("Is this a 40-pin Raspberry Pi?", detector.board.any_raspberry_pi_40_pin)
40-
print("Is this a Raspberry Pi Compute Module?", detector.board.any_raspberry_pi_cm)
41-
print("Is this a BeagleBone Board?", detector.board.any_beaglebone)
42-
print("Is this a Giant Board?", detector.board.GIANT_BOARD)
43-
print("Is this a Coral Dev Board?", detector.board.CORAL_EDGE_TPU_DEV)
44-
print("Is this a Coral Dev Board Mini?", detector.board.CORAL_EDGE_TPU_DEV_MINI)
45-
print("Is this a MaaXBoard?", detector.board.MAAXBOARD)
46-
print("Is this a MaaXBoard Mini?", detector.board.MAAXBOARD_MINI)
47-
print("Is this a SiFive Unleashed? ", detector.board.SIFIVE_UNLEASHED)
48-
print("Is this a PYNQ Board?", detector.board.PYNQ_Z1 | detector.board.PYNQ_Z2)
56+
print("Is this a 96boards board?", detector.board.any_96boards)
57+
print("Is this a BeagleBone board?", detector.board.any_beaglebone)
58+
print("Is this a Giant board?", detector.board.any_giant_board)
59+
print("Is this a Coral Dev board?", detector.board.any_coral_board)
60+
print("Is this a MaaXBoard?", detector.board.any_maaxboard)
61+
print("Is this a SiFive board? ", detector.board.any_sifive_board)
62+
print("Is this a PYNQ board?", detector.board.any_pynq_board)
4963
print("Is this a Rock Pi board?", detector.board.any_rock_pi_board)
5064
print("Is this a NanoPi board?", detector.board.any_nanopi)
51-
print("Is this a Khadas VIM3 board?", detector.board.KHADAS_VIM3)
65+
print("Is this a Khadas VIM3 board?", detector.board.khadas_vim3_40_pin)
5266
print("Is this a Clockwork Pi board?", detector.board.any_clockwork_pi_board)
53-
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
54-
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
55-
print("Is this a UDOO Bolt?", detector.board.UDOO_BOLT)
56-
print("Is this a ODYSSEY X86YJ4105?", detector.board.ODYSSEY_X86J4105)
57-
print("Is this an ASUS Tinker Board?", detector.board.ASUS_TINKER_BOARD)
58-
print("Is this an STM32MP1 Board?", detector.board.any_stm32mp1)
67+
print("Is this a Seeed Board?", detector.board.any_seeed_board)
68+
print("Is this a UDOO board?", detector.board.any_udoo_board)
69+
print("Is this an ASUS Tinker board?", detector.board.any_asus_tinker_board)
70+
print("Is this an STM32MP1 board?", detector.board.any_stm32mp1)
71+
print("Is this a generic Linux PC?", detector.board.generic_linux)
5972
print(
60-
"Is this an OS environment variable special case?",
61-
detector.board.FTDI_FT232H
62-
| detector.board.FTDI_FT2232H
63-
| detector.board.MICROCHIP_MCP2221
64-
| detector.board.BINHO_NOVA
65-
| detector.board.GREATFET_ONE
66-
| detector.board.PICO_U2IF
67-
| detector.board.FEATHER_U2IF
68-
| detector.board.ITSYBITY_U2IF
69-
| detector.board.MACROPAD_U2IF
70-
| detector.board.QTPY_U2IF
71-
| detector.board.QT2040_TRINKEY_U2IF,
73+
"Is this an OS environment variable special case?", detector.board.os_environ_board
7274
)
7375

74-
if detector.board.any_raspberry_pi:
75-
print("Raspberry Pi detected.")
76-
7776
if detector.board.any_jetson_board:
7877
print("Jetson platform detected.")
7978

@@ -89,9 +88,6 @@
8988
if detector.board.any_odroid_40_pin:
9089
print("Odroid detected.")
9190

92-
if detector.board.khadas_vim3_40_pin:
93-
print("Khadas VIM3 detected.")
94-
9591
if detector.board.any_onion_omega_board:
9692
print("Onion Omega detected.")
9793

@@ -101,7 +97,7 @@
10197
if detector.board.any_rock_pi_board:
10298
print("Rock Pi device detected.")
10399

104-
if detector.board.any_clockwork_pi:
100+
if detector.board.any_clockwork_pi_board:
105101
print("Clockwork Pi device detected.")
106102

107103
if detector.board.any_asus_tinker_board:

0 commit comments

Comments
 (0)