DE,则无需安装 PlatformIO Core。PlatformIO Core 内置于 PlatformIO IDE中,您可以在PlatformIO IDE终端中使用它。
如果您需要在PlatformIO IDE之外使用 PlatformIO Core 命令,请安装 Shell Commands( https://docs.platformio.org/en/latest/core/installation/shell-commands.html#piocore-install-shell-commands )。
3.1 安装
3.1.1 Super-Quick (macOS / Linux)
curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py
# 或
pip install -U platformio
其他系统参考 https://docs.platformio.org/en/latest/core/installation/methods/installer-script.html
PlatformIO Core(CLI)由系统中的2个独立工具组成:
- platformio 或 pio(简称)
- piodebuggdb - pio调试
Linux 用户必须为支持 PlatformIO 的板卡/设备安装 udev 规则。最新版本的规则可在 https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules 上找到。
请检查您的板卡的PID和VID是否列在规则中。您可以使用pio device lis 命令列出已连接的设备及其PID/VID。
该文件必须放置在/etc/udev/rules.d/99-platformio-udev.rules (首选位置)或 /lib/udev/rules.d/99-platformio-udev.rules (某些坏系统需要)。
请打开系统终端并键入
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
或手动下载文件并复制到目标文件夹
sudo cp 99-platformio-udev.rules /etc/udev/rules.d/99-platformio-udev.rules
重启 "udev "管理工具:
sudo service udev restart
或
sudo udevadm control --reload-rules
sudo udevadm trigger
如果 Ubuntu/Debian 用户不是 "root",可能需要将自己的 "username "添加到 "dialout "组。
sudo usermod -a -G dialout $USER
sudo usermod -a -G plugdev $USER
同样,Arch 用户可能需要将自己的用户添加到 "uucp "组中
sudo usermod -a -G uucp $USER
sudo usermod -a -G lock $USER
注意您需要注销并重新登录(或重启)用户组更改才能生效。
安装此文件后,拔下并重新连接板卡。
参考资料
3.1.1.1 与自定义应用程序(扩展、插件)集成
当您将PlatformIO Core集成到应用程序(如集成开发环境的扩展或插件)中时,我们建议您使用PlatformIO Core安装程序脚本。
3.1.1.1.1 前提条件
PlatformIO Core安装脚本由Python编写,兼容Python 2.7+和Python 3.5+。我们强烈建议使用最新的Python 3。
将get-platformio.py文件捆绑到您的应用程序中;或按需下载 get-platformio.py 文件。
在这两种情况下您都需要在最终用户机器上安装get-platformio.py脚本。您可以将其复制或下载到缓存/临时文件夹中。
帮助:
$ python get-platformio.py --help
Usage: get-platformio.py [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--verbose Verbose output
--shutdown-piohome / --no-shutdown-piohome
--dev
--ignore-python TEXT A path to Python to be ignored (multiple
options and unix wildcards are allowed)
--pypi-index-url TEXT Custom base URL of the Python Package Index
(default `https://pypi.org/simple`)
--help Show this message and exit.
Commands:
check
pack
3.1.1.1.2 Workflow
我们将介绍一个简单的工作流程,说明如何为应用程序/扩展的最终用户自动安 PlatformIO Core (CLI)。
- 步骤1. PlatformIO Core安装在何处?
每次用户启动应用程序时,您都应检查 PlatformIO Core的安装状态。您需要调用带有检查核心参数的安装程序脚本:
$ python get-platformio.py check core
Found compatible PlatformIO Core 6.1.10 -> /home/andrew/.platformio/penv/b