Skip to content

Commit a1cbc7b

Browse files
authored
Merge pull request #81 from geekguy-wy/add_udoo_bolt_detect
Added board detection for UDOO Bolt using check_board_asset_value()
2 parents e8b0a2c + e16fed5 commit a1cbc7b

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

adafruit_platformdetect/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def check_board_asset_tag_value(self):
127127

128128
try:
129129
with open("/sys/devices/virtual/dmi/id/board_asset_tag", "r") as tag_file:
130-
tag = tag_file.read()
130+
tag = tag_file.read().strip()
131131
except FileNotFoundError:
132132
pass
133133

adafruit_platformdetect/board.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def id(self):
120120
elif chip_id == chips.RK3308:
121121
board_id = self._rock_pi_id()
122122
elif chip_id == chips.RYZEN_V1605B:
123-
board_id = boards.UDOO_BOLT
123+
board_id = self._udoo_id()
124124

125125
return board_id
126126

@@ -316,6 +316,14 @@ def _clockwork_pi_id(self):
316316
board = boards.CLOCKWORK_CPI3
317317
return board
318318

319+
def _udoo_id(self):
320+
"""Try to detect the id of udoo board."""
321+
board_asset_tag = self.detector.check_board_asset_tag_value()
322+
for board_id, board_tags in boards._UDOO_BOARD_IDS.items():
323+
if any(v == board_asset_tag for v in board_tags):
324+
return board_id
325+
return None
326+
319327
@property
320328
def any_96boards(self):
321329
"""Check whether the current board is any 96boards board."""
@@ -396,6 +404,11 @@ def any_clockwork_pi_board(self):
396404
"""Check whether the current board is any Clockwork Pi device."""
397405
return self.CLOCKWORK_CPI3
398406

407+
@property
408+
def any_udoo_board(self):
409+
"""Check to see if the current board is an UDOO board"""
410+
return self.id in boards._UDOO_BOARD_IDS
411+
399412
@property
400413
def any_embedded_linux(self):
401414
"""Check whether the current board is any embedded Linux device."""
@@ -415,6 +428,7 @@ def any_embedded_linux(self):
415428
self.any_pynq_board,
416429
self.any_rock_pi_board,
417430
self.any_clockwork_pi_board,
431+
self.any_udoo_board,
418432
]
419433
)
420434

adafruit_platformdetect/constants/boards.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
ROCK_PI_S = "ROCK_PI_S"
9696

9797
GREATFET_ONE = "GREATFET_ONE"
98-
9998
UDOO_BOLT = "UDOO_BOLT"
10099

101100
# pylint: enable=bad-whitespace
@@ -344,3 +343,6 @@
344343

345344
# Pine64 boards and devices
346345
_PINE64_DEV_IDS = (PINE64, PINEBOOK, PINEPHONE)
346+
347+
# UDOO
348+
_UDOO_BOARD_IDS = {UDOO_BOLT: ("SC40-2000-0000-C0|C",)}

bin/detect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
detector = adafruit_platformdetect.Detector()
66

77
print("Chip id: ", detector.chip.id)
8-
98
print("Board id: ", detector.board.id)
9+
print()
1010

1111
print("Is this a DragonBoard 410c?", detector.board.DRAGONBOARD_410C)
1212
print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
@@ -23,6 +23,7 @@
2323
print("Is this a Clockwork Pi board?", detector.board.any_clockwork_pi_board)
2424
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
2525
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
26+
print("Is this a UDOO Bolt?", detector.board.UDOO_BOLT)
2627
print(
2728
"Is this an OS environment variable special case?",
2829
detector.board.FTDI_FT232H

0 commit comments

Comments
 (0)