peterzuger / pyserial-micropython

pySerial for micropython unix port

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyserial-micropython

Table of Contents

About

This is a port of pySerial for the unix port of micropython.

For the documentation of the pySerial module see here: readthedocs.

Getting Started

Prerequisites

This port of pySerial is designed for micropython.

git clone --recurse-submodules https://github.com/micropython/micropython.git

Installing

pyserial-micropython will very likely only work on the unix port of micropython.

First create a modules folder next to your copy of micropython.

project/
├── manifest.py
├── modules/
│   └──pyserial-micropython/
│       ├──...
│       └──manifest.py
└── micropython/
    ├──ports/
   ... ├──stm32/
      ...

And now put this project in the modules folder.

cd modules
git clone https://gitlab.com/peterzuger/pyserial-micropython.git

This module is implemented in pure micropython, to include this in your final unix executable it has to be included via a custom manifest.py wich could reside in the top level directory above the modules and the micropython folder like shown in the example tree above.

This custom manifest.py could look like this if only this custom module will be included in the final binary:

include("modules/pyserial-micropython/manifest.py")

Now that you have everything that is needed, it is time to build micropython. First the mpy-cross compiler has to be built:

make -C micropython/mpy-cross

Now compile the unix port and configure your custom FROZEN_MANIFEST like this:

make -C micropython/ports/unix FROZEN_MANIFEST=$PWD/manifest.py

and you are ready to use serial for micropython.

Usage

The module is available by just importing serial:

import serial

port = serial.Serial("/dev/ttyUSB0", 115200)

About

pySerial for micropython unix port

License:MIT License


Languages

Language:Python 100.0%