def get_smbus():
candidates = []
prefix = '/dev/i2c-'
for bus in glob.glob(prefix + '*'):
try:
n = int(bus.replace(prefix, ''))
candidates.append(n)
except:
pass
if len(candidates) == 1:
return smbus.SMBus(candidates[0])
elif len(candidates) == 0:
raise Exception("Could not find an I2C bus")
else:
raise Exception("Multiple I2C busses found")
convert_and_read_many.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录