Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
version.py
Go to the documentation of this file.
1 import re
2 import sys
3 
4 VERSION = '0.7.1'
5 VERSION_STRING = "WebIOPi/%s/Python%d.%d" % (VERSION, sys.version_info.major, sys.version_info.minor)
6 PYTHON_MAJOR = sys.version_info.major
7 BOARD_REVISION = 0
8 
9 _MAPPING = [[], [], [], []]
10 _MAPPING[1] = ["V33", "V50", 0, "V50", 1, "GND", 4, 14, "GND", 15, 17, 18, 21, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7]
11 _MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7]
12 _MAPPING[3] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7, "DNC", "DNC" , 5, "GND", 6, 12, 13, "GND", 19, 16, 26, 20, "GND", 21]
13 
14 
15 try:
16  with open("/proc/cpuinfo") as f:
17  rc = re.compile("Revision\s*:\s(.*)\n")
18  info = f.read()
19  result = rc.search(info)
20  if result != None:
21  hex_cpurev = result.group(1)
22  if hex_cpurev.startswith("1000"):
23  hex_cpurev = hex_cpurev[-4:]
24  cpurev = int(hex_cpurev, 16)
25  if cpurev < 4:
26  BOARD_REVISION = 1
27  elif cpurev < 7:
28  BOARD_REVISION = 2
29  else:
30  BOARD_REVISION = 3
31 
32 except:
33  pass
34 
35 MAPPING = _MAPPING[BOARD_REVISION]