Skip to main content

Frontend for connecting to devlprd and processing data from a FANTM DEVLPR

Project description

pydevlpr

Overview

Enables simple muscle to application connections. Pydevlpr is the front-end for devlprd <https://github.com/FANTM/devlprd>_, and the third piece of the muscle-to-app pipeline.

Getting Started

After installing pydevlpr, integrating it into a project is straightforward. First launch the devlprd daemon <https://github.com/FANTM/devlprd>_, and then use the add_callback(...) function to attach a handler to the incoming data. The callback you attach will get the incoming payload as its only parameter, and then the data is yours to handle.

Supported Topics

This list will expand as the package matures, but when adding/removing callbacks use a data topic from this list as it maps directly to the daemon.

  • DataTopic.RAW_DATA_TOPIC - Data straight off the DEVLPR Arduino Shield. Range: 0-1023.
  • DataTopic.FLEX_TOPIC - 1 when there has been a flex, 0 when muscle is relaxed.

API

def stop() -> None:

Stops listening to the server.

def add_callback(topic: str, pin: int, fn: Callable[[str], None], ws: websocket.server.WebSocketServerProtocol = None) -> None:

Attaches a function to be called whenever a message is received at a particular topic and relating to a particular DEVLPR (as specified by the pin parameter).

  • topic: str - Specifies the data stream, differentiating filtered vs. raw data.
  • pin: int - Connects the callback to a physical board. Each DEVLPR is connection to the Arduino via an analog pin, and the message from the daemon relates which pin this is.
  • fn: Callable[[str], None] - Function to be called when a message is received that is both the specified topic and pin. It expects to receive the payload of the incoming message.
  • ws: websocket.server.WebSocketServerProtocol - Websocket connection, by default set to None and uses pydevlprs global connection. Pass a connection in if it is going to be used in another context, or for testing.

def remove_callback(topic: str, pin: int, fn: Callable[[str], None]) -> None:

Stops a function from being called whenever a new qualified packet is received.

  • topic: str - The data stream the existing callback is attached to.
  • pin: int - The DEVLPR the callback is attached to.
  • fn: Callable[[str], None] - Function to remove from the callback list.

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

pydevlpr-0.3.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

pydevlpr-0.3.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pydevlpr-0.3.1.tar.gz.

File metadata

  • Download URL: pydevlpr-0.3.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.1 Windows/10

File hashes

Hashes for pydevlpr-0.3.1.tar.gz
Algorithm Hash digest
SHA256 37f185b0fcf9585817f9cb46eae92d73b43a7a89bbef044bf048f02fdb31fcd5
MD5 a575e8b724cb19da11c4d6d436d89c38
BLAKE2b-256 2eeb902c322161b452a489ef396047a63f242445c8934dc60a1750cd6cb31f33

See more details on using hashes here.

File details

Details for the file pydevlpr-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pydevlpr-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.1 Windows/10

File hashes

Hashes for pydevlpr-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be0061e30454d4a2d3ad52d6e1cbf2fb8aacfbd16a79fd735abe6edc4f253bf2
MD5 888719047e8e53135e544698e36d7ae0
BLAKE2b-256 c81843c396201e3f2c4ab618354cc692a4d54839683e11fd17e81c4c412328b3

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