-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathBoardDetector.py
More file actions
62 lines (45 loc) · 1.36 KB
/
BoardDetector.py
File metadata and controls
62 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
"""
BoardDetector.py
This example recognizes the expansion board where the Intel Edison module is.
The board could be the Arduino Expansion Board or the Mini-Breakout Board.
This example code is in the public domain.
Revision History
----------------------------------------------------------
Author Date Description
----------------------------------------------------------
Diego Villalobos 09-24-2015 Example created
"""
import os
BOARD = "???"
class text_colors:
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
END = '\033[0m'
def checkPlatform():
"""
Returns the board used. If the board is not the Arduino Expansion Board
we assume the board is the Mini-Breakout Board.
"""
os.system("echo 214 > /sys/class/gpio/export 2> tmp_log.txt")
f = open('tmp_log.txt', "r")
content = f.readline()
os.system('rm tmp_log.txt')
if "No such device" in content:
return "MINIBOARD"
else:
return "ARDUINOBOARD"
def main():
global BOARD
# Make sure which board is currently used
BOARD = checkPlatform()
if BOARD == "ARDUINOBOARD":
print text_colors.CYAN + "Arduino Expansion Board Detected" + text_colors.END
else:
print text_colors.YELLOW + "Mini-Breakout Board Detected" + text_colors.END
if __name__ == "__main__":
main()