Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update board_revision.py #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion quick2wire/board_revision.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
"""
This function returns 2 for the 40 pin pin-out and 1 for 26 pin. Otherwise it returns 0
"""
def revision():
pinout1 = ['0002','0003','0004','0005','0006','0007','0008','0009','000d','000e','000f','0011','0014']
pinout2 = ['0012','0015','a01041','a21041','a22042','900092','900093','9000C1','a02082','a22082','a020d3']

try:
with open('/proc/cpuinfo','r') as f:
for line in f:
if line.startswith('Revision'):
return 1 if line.rstrip()[-1] in ['2','3'] else 2
if line.rstrip()[-4:] in pinout1:
return 1
elif line.rstrip()[-4:] in pinout2:
return 2
elif line.rstrip()[-6:] in pinout2:
return 2
else:
return 0
else:
return 0
except:
return 0

"""
These have i2c-0 as default
Pi 1 Model B Rev 1 0002
Pi 1 Model B Rev 1 ECN0001 0003
Pi 1 Model B Rev 2 0004, 0005, 0006
Pi 1 Model A 0007, 0008, 0009
Pi 1 Model B Rev 2 000d, 000e, 000f
Pi 1 Compute Module 0011, 0014

These have i2c-1 as default
Pi 1 Model A+ 0012, 0015
Pi 2 Model B V1.1 a01041, a21041
Pi 2 Model B V1.2 a22042
Pi Zero V1.2 900092
Pi Zero V1.3 900093
Pi Zero W 9000C1
Pi 3 Model B a02082, a22082
Pi 3 Model B+ a020d3
"""