Skip to main content

About

- Name: serial_interface
- Description: Extends pyserial to make serial device interfaces.
- Version: 2.4.4
- Python Version: 3.10
- Release Date: 2025-03-20
- Creation Date: 2018-01-11
- License: BSD-3-Clause
- URL: https://github.com/janelia-python/serial_interface_python
- Author: Peter Polidoro
- Email: peter@polidoro.io
- Copyright: 2025 Howard Hughes Medical Institute
- References:
  - https://pyserial.readthedocs.io/en/latest/
- Dependencies:
  - pyserial

Example Usage

Python

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

dev.get_device_info()

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

devs.get_devices_info()
devs.sort_by_port()
dev = devs[0]
dev.get_device_info()

Command Line


Installation

https://github.com/janelia-python/python_setup

GNU/Linux

Drivers

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:

99-platformio-udev.rules

  1. Download rules into the correct directory

    curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | 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/
    source ~/venvs//bin/activate
    pip install 
    
  2. guix

    Setup guix-janelia channel:

    https://github.com/guix-janelia/guix-janelia

    guix install python-serial-interface
    

Windows

Drivers

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\
    C:\venvs\\Scripts\activate
    pip install 
    

Development

Install Guix

Install Guix

Clone Repository

git clone https://github.com/janelia-python/serial_interface_python
cd serial_interface_python

Edit metadata.org

make metadata-edits

Tangle metadata.org

make metadata

Test Python package using ipython shell

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

Test installation of Guix package

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

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
settings
[C-a][C-x] # to exit

Metadata

Release files for serial-interface 2.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serial-interface 2.4.4
File Size Uploaded Provenance Actions
serial_interface-2.4.4.tar.gz 9.9 kB Without provenance Details for serial_interface-2.4.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for serial-interface 2.4.4
File Interpreter ABI Platform Actions
serial_interface-2.4.4-py3-none-any.whl Python 3 none any Details for serial_interface-2.4.4-py3-none-any.whl

Total release size: 19.2 kB

Release files / serial_interface-2.4.4.tar.gz

Download URL serial_interface-2.4.4.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9388a2566c57e4dd603fddd514d9a1ac0c23d23fb4538cc9c5793f962a1f1288
BLAKE2b-256 checksum
How to use checksums
33e6b16b38eab31e5443ca65622b772420db67ef2438d05df9cc51746ac39628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.7

Release files / serial_interface-2.4.4-py3-none-any.whl

Download URL serial_interface-2.4.4-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3893760e578cc7e64536ea929af270ff1ad053d7b6a5ebb461ff764f6064789
BLAKE2b-256 checksum
How to use checksums
90732842cdbe5d77ab975d7f7f584d724770eb05efc6872962667f6e17029985
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.7

Security for serial-interface 2.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page