convert_and_read_many.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:python-MCP342x 作者: stevemarple 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号