Skip to main content

*nix virtual serial ports

Project description

PyVirtualSerialPorts

A Python implementation of virtual serial ports. Useful for developing and testing programs which need to talk to a serial port.

Demo

Example uses:

  • Create a virtual port which echoes back any data sent to it.
  • Create a two or more ports; sending data to one sends data to the others.

Has no dependencies other than the Python standard library.

Only works on *nix type systems. Tested on Debian Linux, but should work on others (macOS, BSD, etc.). For Windows, look at com0com or Virtual Serial Port Driver.

Installation

Current user

$ pip3 install PyVirtualSerialPorts

System-wide

$ sudo pip3 install PyVirtualSerialPorts

Running

If the script install folder is in your PATH (almost certainly the case if installed as root), you can simply run:

$ virtualserialports ...

Otherwise, you can use it as a module:

$ python3 -m virtualserialports ...

Usage

usage: virtualserialports [-h] [-l] [-d] num_ports

positional arguments:
  num_ports       number of ports to create

optional arguments:
  -h, --help      show this help message and exit
  -l, --loopback  echo data back to the sending device too
  -d, --debug     log received data to stderr

Examples

Create a single port, and echo back anything sent to it

$ virtualserialports -l 1

The created port will be printed on the command line e.g. /dev/pts/0, and can be used with any serial program, e.g. minicom:

$ minicom -D /dev/pts/0

Create a pair of ports, sending the data between them

$ virtualserialports 2

The two created ports will be printed, and again can be used with any serial program. E.g. in one terminal window:

$ minicom -D /dev/pts/0

and in a second:

$ minicom -D /dev/pts/1

Now typing data on one terminal will appear in the other.

Create three ports, sending data received from any of them to all three

$ virtualserialports -l 3

Use as a library

virtualserialports.run(num_ports, loopback=False, debug=False)

  • num_ports: number of ports to create.
  • loopback: whether to echo data back to the sender.
  • debug: whether to print debugging info to stdout.

Example

import virtualserialports
virtualserialports.run(2, loopback=True, debug=False)

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

PyVirtualSerialPorts-1.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

PyVirtualSerialPorts-1.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file PyVirtualSerialPorts-1.0.1.tar.gz.

File metadata

  • Download URL: PyVirtualSerialPorts-1.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for PyVirtualSerialPorts-1.0.1.tar.gz
Algorithm Hash digest
SHA256 879c424f3ce9786eab21e39eb945f5cb90894a481a672d1e57ee40dced8100dc
MD5 f2ec45ea6665ab10625bc9da77a62068
BLAKE2b-256 41e337131bd806190bf9df14aff5542fe24e146711b3711198866d3d642257f3

See more details on using hashes here.

File details

Details for the file PyVirtualSerialPorts-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: PyVirtualSerialPorts-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for PyVirtualSerialPorts-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98cc826d9968e29edd1dcf029a30c1ccde4251c94927ddc681680f82d17f2c94
MD5 b508358a6ac53c5c5140c30d684ef88e
BLAKE2b-256 0d21e02537725c3982a10d841b2cba2934c549cc4c56b3d9306e21b857411fb1

See more details on using hashes here.

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