Skip to content

Commit 7d2e0c8

Browse files
committed
fix a couple of bugs in beaglebone detection; tested for BBB
...unfortunately, requires root as-written, which probably makes this a lot less useful.
1 parent aca915f commit 7d2e0c8

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

adafruit_platformdetect/board.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,18 @@ def _pi_rev_code(self):
178178
return None
179179
return self.detector.get_cpuinfo_field('Revision')
180180

181-
@property
182181
def _beaglebone_id(self):
183182
"""Try to detect id of a Beaglebone."""
184183
try:
185184
with open("/sys/bus/nvmem/devices/0-00500/nvmem", "rb") as eeprom:
186185
eeprom_bytes = eeprom.read(16)
187-
except:
186+
except FileNotFoundError:
188187
return None
189188

190189
if eeprom_bytes[:4] != b'\xaaU3\xee':
191190
return None
192191

193-
id_string = str(eeprom_bytes[4:])
192+
id_string = eeprom_bytes[4:].decode("ascii")
194193
for model, ids in _BEAGLEBONE_BOARD_IDS.items():
195194
for id in ids:
196195
if id_string == id[1]:

adafruit_platformdetect/chip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def _linux_id(self):
3333
hardware = self.detector.get_cpuinfo_field("Hardware")
3434
if hardware in ('BCM2708', 'BCM2708', 'BCM2835'):
3535
id = BCM2XXX
36-
elif "AM33XX" in hardwarename:
36+
elif "AM33XX" in hardware:
3737
id = AM33XX
38-
elif "sun8i" in hardwarename:
38+
elif "sun8i" in hardware:
3939
id = SUN8I
4040

4141
return id

bin/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
print("Raspberry Pi detected.")
1616
print("Revision code: ", detector.board._pi_rev_code())
1717

18-
if detector.board.beaglebone_black:
18+
if detector.board.BEAGLEBONE_BLACK:
1919
print("BBB detected")

0 commit comments

Comments
 (0)