Skip to main content

A Python3 API to interface with Rainforest Automation's EMU-2

Project description

Emu-Api

This library allows communication with a Rainforest Automation EMU-2 device. It is a rewrite of Rainforest's Emu-Serial-API in Python 3, and follows a similar architectural pattern where possible.

Usage

This API can be used in asynchronous mode or synchronous mode. Technically, communication always happens asynchronously with the Emu, but this library allows for a synchronous API to emulated.

As in Rainforest's library, we do not automatically start communication once the main object is instantiated. This is done because the EMU-2 constantly pushes data to us over the serial connection, so we want to give the consumer control over when this channel is opened. Before any commands are issued, the start_serial(<serial port>) method must be called to open the serial port and begin receiving data.

The serial port name is the platform-specific device that you wish to use. Note that unlike Rainforest's library, we do not attempt to detect the host platform or set any port prefixes - this means that the full name of the device (prefixed with COM for Windows or /dev for OSX and Linux, usually) must be used.

Example Usage

Synchronous

from emu-power import Emu

api = Emu(synchronous=True)
api.start_serial("/dev/tty.usbmodem146101")

# This will return an instance of InstantaneousUsage, or None on timeout.
response = api.get_instantaneous_usage()

Asynchronous

from emu-power import Emu
from emu-power.response_entities import InstantaneousUsage
import time

api = Emu()
api.start_serial("/dev/tty.usbmodem146101")

# This will return immediately. The response data will become available
# when the device responds.
api.get_instantaneous_usage()
time.sleep(5)
response = api.get_data(InstantaneousUsage)

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

emu-power-1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emu_power-1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file emu-power-1.0.tar.gz.

File metadata

  • Download URL: emu-power-1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for emu-power-1.0.tar.gz
Algorithm Hash digest
SHA256 cf1afc808161506583e54f5078ad898a174c1be21b1c2e4f0626cf1fd2d99615
MD5 99479a4ba0b95032c0c1744807b8d7b3
BLAKE2b-256 6b01ea160671b47be7e0f49cd5c49f6029433eeee7b8fadd6b676a58a45fe91e

See more details on using hashes here.

File details

Details for the file emu_power-1.0-py3-none-any.whl.

File metadata

  • Download URL: emu_power-1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for emu_power-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73e69a45a16da59d2fe29e072cef40a86f2e91133f656c67cc59e9507e9bafea
MD5 721dfa93e8b904d9f3de9401f83496f9
BLAKE2b-256 89f6bf8ade1d44bf73c28cf672f429ddc106ba7bb00e0f8d56c21421a4e1d3e7

See more details on using hashes here.

Supported by

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