用于Adafruit Blinka等库的平台检测。
Adafruit-PlatformDetect的Python项目详细描述
简介
此库为一系列单板提供最佳猜测平台检测 计算机和(潜在的)其他平台。它主要是为使用而写的 在Adafruit_Blinka中,但可能是 在其他情况下有用。
平台检测分为“芯片”和“板”检测,后者 一般依赖前者。平台信息收集自:
- Python’s sys.platform
- Various files on Linux systems:
- /proc/cpuinfo (for processor info, Raspberry Pi hardware revisions, etc.)
- /proc/device-tree/compatible (for 96Boards info)
- Beaglebone EEPROM board IDs
- Distribution-specific files such as /etc/armbian-release.
api目前不稳定,在将来的版本中可能会有很大的变化。
安装
在支持的gnu/linux系统(如raspberry pi)上,可以在本地安装驱动程序from PyPI。为当前用户安装:
pip3 install Adafruit-PlatformDetect
要在系统范围内安装(在某些情况下可能需要安装):
sudo pip3 install Adafruit-PlatformDetect
在当前项目的虚拟环境中安装:
mkdir project-name &&cd project-name python3 -m venv .env source .env/bin/activate pip3 install Adafruit-PlatformDetect
用法
fromadafruit_platformdetectimportDetectordetector=Detector()print("Chip id: ",detector.chip.id)print("Board id: ",detector.board.id)# Check for specific board models:print("Pi 3B+? ",detector.board.RASPBERRY_PI_3B_PLUS)print("BBB? ",detector.board.BEAGLEBONE_BLACK)print("Orange Pi PC? ",detector.board.ORANGE_PI_PC)print("generic Linux PC? ",detector.board.GENERIC_LINUX_PC)
有关更多可能检测到的电路板,请参见https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/master/bin/detect.py。