Skip to content

Commit a174e7c

Browse files
authored
Merge pull request #62 from mruz/master
Get revision from device-tree if None
2 parents 0eb6058 + 797bbbe commit a174e7c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

adafruit_platformdetect/board.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,21 @@ def _pi_rev_code(self):
116116
if self.detector.chip.id != chips.BCM2XXX:
117117
# Something else, not a Pi.
118118
return None
119-
return self.detector.get_cpuinfo_field('Revision')
119+
rev = self.detector.get_cpuinfo_field('Revision')
120+
121+
if rev is not None:
122+
return rev
123+
else:
124+
try:
125+
with open("/proc/device-tree/system/linux,revision", "rb") as revision:
126+
rev_bytes = revision.read()
127+
128+
if rev_bytes[:1] == b'\x00':
129+
rev_bytes = rev_bytes[1:]
130+
131+
return rev_bytes.hex()
132+
except FileNotFoundError:
133+
return None
120134

121135
# pylint: disable=no-self-use
122136
def _beaglebone_id(self):

0 commit comments

Comments
 (0)