Skip to main content

Extends pyserial to make serial device interfaces.

Project description


- Name: serial_interface
- Description: Extends pyserial to make serial device interfaces.
- Version: 2.3.1
- Release Date: 2022-12-21
- Creation Date: 2018-01-11
- License: BSD-3-Clause
- URL:
- Author: Peter Polidoro
- Email:
- Copyright: 2022 Howard Hughes Medical Institute
- References:
- Dependencies:
  - pyserial

Example Usage


from serial_interface import SerialInterface, find_serial_interface_ports
find_serial_interface_ports() # Returns list of available serial ports

dev = SerialInterface() # Might automatically find device if one available

# if it is not found automatically, specify port directly
dev = SerialInterface(port='/dev/ttyUSB0') # Linux
dev = SerialInterface(port='/dev/tty.usbmodem262471') # Mac OS X
dev = SerialInterface(port='COM3') # Windows


from serial_interface import SerialInterfaces

devs = SerialInterfaces()  # Might automatically find all available devices

# if they are not found automatically, specify ports to use
devs = SerialInterfaces(use_ports=['/dev/ttyUSB0','/dev/ttyUSB1']) # Linux
devs = SerialInterfaces(use_ports=['/dev/tty.usbmodem262471','/dev/tty.usbmodem262472']) # Mac OS X
devs = SerialInterfaces(use_ports=['COM3','COM4']) # Windows

dev = devs[0]

Command Line




GNU/Linux computers usually have all of the necessary drivers already installed, but users need the appropriate permissions to open the device and communicate with it.

Udev is the GNU/Linux subsystem that detects when things are plugged into your computer.

Udev may be used to detect when a serial device is plugged into the computer and automatically give permission to open that device.

If you plug a sensor into your computer and attempt to open it and get an error such as: "FATAL: cannot open /dev/ttyUSB0: Permission denied", then you need to install udev rules to give permission to open that device.

Udev rules may be downloaded as a file and placed in the appropriate directory using these instructions:


  1. Download rules into the correct directory

    curl -fsSL | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
  2. Restart udev management tool

    sudo service udev restart
  3. Ubuntu/Debian users may need to add own “username” to the “dialout” group

    sudo usermod -a -G dialout $USER
    sudo usermod -a -G plugdev $USER
  4. After setting up rules and groups

    You will need to log out and log back in again (or reboot) for the user group changes to take effect.

    After this file is installed, physically unplug and reconnect your board.

Python Code

The Python code in this library may be installed in any number of ways, chose one.

  1. pip

    python3 -m venv ~/venvs/serial_interface
    source ~/venvs/serial_interface/bin/activate
    pip install serial_interface
  2. guix

    Setup guix-janelia channel:

    guix install python-serial-interface



Download and install driver for the specific serial device.

Python Code

The Python code in this library may be installed in any number of ways, chose one.

  1. pip

    python3 -m venv C:\venvs\serial_interface
    pip install serial_interface


Install Guix

Install Guix

Clone Repository

git clone
cd serial_interface_python


make metadata-edits


make metadata

Test Python package using ipython shell

make ipython-shell # PORT=/dev/ttyUSB0
# make PORT=/dev/ttyUSB1 ipython-shell
import serial_interface

Test installation of Guix package

make installed-shell # PORT=/dev/ttyUSB0
# make PORT=/dev/ttyUSB1 installed-shell

Upload Python package to pypi

make upload

Test direct device interaction using serial terminal

make serial-shell # PORT=/dev/ttyUSB0
# make PORT=/dev/ttyUSB1 serial-shell
? # help
[C-a][C-x] # to exit

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serial_interface-2.3.1.tar.gz (9.9 kB view hashes)

Uploaded source

Built Distribution

serial_interface-2.3.1-py3-none-any.whl (9.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page