Skip to main content

Communicate with the embody device over a serial port

Project description

Embody Serial

PyPI Status Python Version License

Tests

pre-commit Black

Features

  • Connects to an EmBody device over the serial port
  • Uses the EmBody protocol to communicate with the device
  • Integrates with the EmBody Protocol Codec project
  • Asynchronous send without having to wait for response
  • Synchronous send where response message is returned
  • Send facade for protocol agnostic communication with device
  • Provides callback interfaces for incoming messages, response messages and connect/disconnect
  • All methods and callbacks are threadsafe
  • Separate threads for send, receive and callback processing
  • Type safe code using mypy for type checking

Requirements

  • Python 3.11 or newer
  • Access to private Aidee Health repositories on Github

Installation

You can install Embody Serial via pip:

$ pip install embody-serial

This adds embody-serial as a library, but also provides the CLI application with the same name.

Usage

A very basic example where you send a message request and get a response:

from embodyserial.embodyserial import EmbodySerial
from embodyserial.helpers import EmbodySendHelper

embody_serial = EmbodySerial()
send_helper = EmbodySendHelper(sender=embody_serial)
print(f"Serial no: {send_helper.get_serial_no()}")
embody_serial.shutdown()

Logging

This library uses Python's standard logging module and follows best practices for libraries:

For Library Users

The library is silent by default - it won't produce any output unless you configure logging. To enable logging from the library:

import logging

# Enable INFO level logging for embodyserial
logging.getLogger('embodyserial').setLevel(logging.INFO)
logging.getLogger('embodyserial').addHandler(logging.StreamHandler())

# Or configure specific modules
logging.getLogger('embodyserial.embodyserial').setLevel(logging.DEBUG)

For CLI Users

The CLI configures logging automatically. Use --log-level to control verbosity:

embody-serial --get serialno --log-level DEBUG

Available levels: CRITICAL, WARNING, INFO, DEBUG (default: WARNING)

Using the application from the command line

The application also provides a CLI application that is automatically added to the path when installing via pip.

Once installed with pip, type:

embody-serial --help

To see which options are available.

Note The serial port is automatically detected, but can be overridden by using the --device option.

Example - List all attribute values

embody-serial --get-all

Example - Get serial no of device

embody-serial --get serialno

Example - List files over serial port

embody-serial --list-files

Example - Set time current time (UTC)

embody-serial --set-time

Example - Download files

embody-serial --download-files

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Troubleshooting

I get an error message saying 'no module named serial' or similar

This is a known issue and is usually caused by one of two things.

Ensure you haven't installed serial or jserial

Embody-serial uses the pyserial library. Run pip list to see if either the serial or jserial library is installed. If they are, remove them with pip uninstall serial.

Problems with pyserial

Sometimes, for whatever reason, it is necessary to re-install pyserial. Perform a pip uninstall pyserial and then pip install pyserial to see if this helps.

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

embody_serial-1.0.36.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

embody_serial-1.0.36-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file embody_serial-1.0.36.tar.gz.

File metadata

  • Download URL: embody_serial-1.0.36.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for embody_serial-1.0.36.tar.gz
Algorithm Hash digest
SHA256 429786dedb4209de6018ea560338c957642597d54952cfb1676ed1f09856f95c
MD5 9ce3c336bb7300b8ace70aaaca2d4774
BLAKE2b-256 234a9cbc42ef0e35d055d5624b8e7cea5ed302a0f36b0f8e75fa125977eec153

See more details on using hashes here.

File details

Details for the file embody_serial-1.0.36-py3-none-any.whl.

File metadata

  • Download URL: embody_serial-1.0.36-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for embody_serial-1.0.36-py3-none-any.whl
Algorithm Hash digest
SHA256 7d1916c118f7339a7693f8e0b999e8a6912e0f02d9534c75a0efc6d1cb5746da
MD5 bccd6fb0c86c8e5043fefd1e6e0ca937
BLAKE2b-256 cbb7dfdffb608f09a07b7eb8a3986a2f48a2f60a0a80a03569bfe1e174008bb7

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