ampy(adafruit micropython tool)是一个通过串行连接与circuitpython或micropython板交互的命令行工具。

adafruit-amp的Python项目详细描述


安比

adafruit micropython工具(ampy)-通过串行连接与circuitpython或micropython板交互的实用程序。

ampy是一个简单的命令行工具,用于在circuitpython或 通过串行连接的micropython板。 使用ampy,您可以将文件从计算机发送到 Board的文件系统,从Board下载文件到您的计算机,甚至发送一个Python脚本 一个被处决的董事会。

注意ampy by design的目的是简单的,不支持像shell那样的高级交互 或终端将输入发送到板。查看其他micropython工具 就像rshell 或者mpfshell用于与板进行更高级的交互。

安装

您可以将ampy与python 2.7.x或3.x一起使用,并可以从 python的包索引。在MacOS或Linux上,在终端中运行以下命令(假设 Python3):

pip3 install --user adafruit-ampy

在Windows上,请执行以下操作:

pip install adafruit-ampy

注意:在某些Linux和Mac OSX系统上,您可能需要使用sudo以根用户身份运行:

sudo pip3 install adafruit-ampy

如果没有python 3,请尝试使用python 2和:

pip install adafruit-ampy

安装后,请确认您可以运行ampy程序并获得帮助输出:

ampy --help

您应该看到如下显示的使用信息:

Usage: ampy [OPTIONS] COMMAND [ARGS]...

  ampy - Adafruit MicroPython Tool

  Ampy is a tool to control MicroPython boards over a serial connection.
  Using ampy you can manipulate files on the board's internal filesystem and
  even run scripts.

Options:
  -p, --port PORT  Name of serial port for connected board.  [required]
  -b, --baud BAUD  Baud rate for the serial connection. (default 115200)
  --help           Show this message and exit.

Commands:
  get  Retrieve a file from the board.
  ls   List contents of a directory on the board.
  put  Put a file on the board.
  rm   Remove a file from the board.
  run  Run a script and print its output.

如果您想从github源代码安装,那么使用标准的python setup.py安装(或开发模式):

python3 setup.py install

注意:要在Python2上运行单元测试,必须安装模拟库:

pip install mock

用法

ampy是用来通过串行连接与电路python micropython板进行通信的。你会 需要您的板连接和任何驱动程序访问它的串行端口安装。 然后,例如要列出板上的文件,请运行如下命令:

ampy --port /dev/tty.SLAB_USBtoUART ls

您应该会看到在板的根目录上的文件列表打印到 终点站。注意,您需要将port参数更改为name或path 连接到micropython板所连接的串行端口。

其他命令可用,请使用--help运行ampy以查看更多信息:

ampy --help

每个子命令都有自己的帮助,例如查看ls命令运行的帮助(注意 很遗憾,必须连接一个板并指定串行端口:

ampy --port /dev/tty.SLAB_USBtoUART ls --help

配置

为了方便起见,您可以设置将要使用的AMPY_PORT环境变量 如果未指定端口参数。例如在Linux或OSX上:

export AMPY_PORT=/dev/tty.SLAB_USBtoUART
ampy ls

或者在Windows(未测试)上,尝试set命令:

set AMPY_PORT=COM4
ampy ls

类似地,您可以设置AMPY_BAUDAMPY_DELAY来控制波特率和 进入原始模式之前的延迟。

要在每次运行ampy时自动设置这些变量,请将它们复制到 文件名.ampy

# Example .ampy file# Please fill in your own port, baud rate, and delayAMPY_PORT=/dev/cu.wchusbserial1410
AMPY_BAUD=115200# Fix for macOS users' "Could not enter raw repl"; try 2.0 and lower from there:AMPY_DELAY=0.5

您可以将.ampy文件放在工作目录、其父目录之一或 你的主目录。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java SimpleFramework和工厂方法   Java适当地处理异常   java单例类不起作用   java小程序和Swing在eclipse中不显示组件   多个键上的java Redisson FastRemove不起作用   java验证请求正文不等于模式   在Java中从URL读取数据   eche RecyclerView项的java Set自定义字体   string Java如何从Date获取HH:mm:ss   当Java应用程序落后于负载均衡器时,在某些URL上强制使用SSL   使用esapi时发生java错误   java使用流根据第二个列表中的值更新一个列表中的对象   组织。openqa。硒。Java中的NoTouchElementException WebDriver?   从JSON字符串Java创建CSV文件