Git Product home page Git Product logo

connio's Introduction

connio

Pypi version

A python concurrency agnostic communication library.

Pass a URL to the single point API function connio.connection_for_url() and it will return a communication object with a common generic API.

Helpful when dealing with instrumentation which work over serial line or TCP (and in future USB) with simple REQ-REP communication protocols (example: SCPI).

The request for a communication object is forwarded to the corresponding serialio or sockio libraries depending on the URL you give.

Written in asyncio with support for different concurrency models:

  • asyncio
  • classic blocking API
  • future based API
  • python 2 compatible blocking API (for those pour souls stuck with python 2)

Installation

From within your favorite python environment:

pip install connio

Usage

import asyncio
from connio import connection_for_url

async def main():

    # A local async serial line
    sl = connection_for_url("serial:///dev/ttyS0", parity="E")
    print(await sl.write_readline(b"*IDN?\n"))

    # An async serial line over telnet server
    sl = connection_for_url("rfc2217://moxa.acme.org:7890", parity="E")
    print(await sl.write_readline(b"*IDN?\n"))

    # An async TCP connection
    tcp = connection_for_url("tcp://gepace.acme.org:5025")
    print(await tcp.write_readline(b"*IDN?\n"))

    # An sync TCP connection
    tcp = connection_for_url("tcp://gepace.acme.org:5025", concurrency="sync")
    print(tcp.write_readline(b"*IDN?\n"))

asyncio.run(main())

connio's People

Contributors

fabaff avatar rhomspuron avatar tiagocoutinho avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.