MATRIXIO Python MALOS Driver
============================
A simple `Python`_ coroutine based driver for communicating with `MATRIX-MALOS services`_.
License
=======
This application follows the GNU General Public License, as described in the ``LICENSE`` file.
Installing
==========
The package is available on PyPI, so you can easily install via pip:
.. code-block:: console
$ pip install matrix-io-malos
Running the CLI client
======================
The library includes a simple command line client to start reading data from
your MALOS service right away.
.. code-block:: console
# Get the malosclient help screen
$ malosclient --help
# Get IMU data to STDOUT from a locally running MALOS service
$ malosclient IMU
# Get HUMIDITY data to STDOUT from a remotely running MALOS service
$ malosclient -h 192.168.0.100 HUMIDITY
# Get FACE detection data using a serialized driver config file
$ malosclient --driver-config-file ~/driver_config.proto VISION
Using the MalosDriver
=====================
To use the MALOS driver works as an async generator so in your code
you can do the following:
.. code-block:: python
import asyncio
import sys
from matrix_io.malos.driver import IMU_PORT, UV_PORT
from matrix_io.proto.malos.v1 import driver_pb2
from matrix_io.proto.malos.v1 import sense_pb2
from matrix_io.malos.driver import MalosDriver
async def imu_data(imu_driver):
async for msg in imu_driver.get_data():
print(sense_pb2.Imu().FromString(msg))
await asyncio.sleep(1.0)
async def uv_data(uv_driver):
async for msg in uv_driver.get_data():
print(sense_pb2.UV().FromString(msg))
await asyncio.sleep(1.0)
async def status_handler(driver):
type_mapping = {
driver_pb2.Status.MESSAGE_TYPE_NOT_DEFINED: "Not Defined",
driver_pb2.Status.STARTED: "Started",
driver_pb2.Status.STOPPED: "Stopped",
driver_pb2.Status.CONFIG_RECEIVED: "Config Received",
driver_pb2.Status.COMMAND_EXECUTED: "Command Executed",
driver_pb2.Status.STATUS_CRITICAL: "Critical",
driver_pb2.Status.STATUS_ERROR: "Error",
driver_pb2.Status.STATUS_WARNING: "Warning",
driver_pb2.Status.STATUS_INFO: "Info",
driver_pb2.Status.STATUS_DEBUG: "Debug"
}
async for msg in driver.get_status():
print(type_mapping[msg.type])
if msg.uuid:
print("UUID: {}".format(msg.uuid))
if msg.message:
print("MESSAGE: {}".format(msg.message))
await asyncio.sleep(1.0)
# Driver configuration
driver_config = driver_pb2.DriverConfig()
# Create the drivers
imu_driver = MalosDriver('localhost', IMU_PORT)
uv_driver = MalosDriver('localhost', UV_PORT)
# Create loop and initialize keep-alive
loop = asyncio.get_event_loop()
loop.run_until_complete(imu_driver.configure(driver_config))
loop.run_until_complete(uv_driver.configure(driver_config))
loop.create_task(imu_driver.start_keep_alive())
loop.create_task(uv_driver.start_keep_alive())
# Initialize data and error handlers
loop.create_task(imu_data(imu_driver))
loop.create_task(uv_data(uv_driver))
loop.create_task(status_handler(imu_driver))
loop.create_task(status_handler(uv_driver))
try:
loop.run_forever()
except KeyboardInterrupt:
print('Shutting down. Bye, bye !', file=sys.stderr)
finally:
loop.stop()
asyncio.gather(*asyncio.Task.all_tasks()).cancel()
loop.run_until_complete(loop.shutdown_asyncgens())
loop.close()
Who can answer questions about this library?
============================================
- Heitor Silva <heitor.silva@admobilize.com>
- Maciej Ruckgaber <maciek.ruckgaber@admobilize.com>
More Documentation
==================
.. toctree::
:titlesonly:
CHANGELOG
.. _0MQ: http://zeromq.org/
.. _Python: https://www.python.org/
.. _virtualenv: https://virtualenv.pypa.io/en/stable/
.. _matrixio-protos-0.0.25: https://pypi.org/project/matrix-io-proto
.. _pypi: https://pypi.org/
.. _MATRIX-MALOS services: https://matrix-io.github.io/matrix-documentation/matrix-core/getting-started/understanding-core/
Metadata
Release files for matrix-io-malos 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matrix_io-malos-0.4.1.tar.gz | 7.9 kB | Without provenance | Details for matrix_io-malos-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matrix_io_malos-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for matrix_io_malos-0.4.1-py3-none-any.whl |
Total release size: 29.5 kB
Release files / matrix_io-malos-0.4.1.tar.gz
| Download URL | matrix_io-malos-0.4.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce185b1a5e16f4c0a7b9798dfcadcadbe441a4a1db87a8bc4a57e4b5c7e8b6e9
|
|
BLAKE2b-256 checksum How to use checksums |
1f610283fbfcce9bc9103585be2551dac9806560d286d4c1cb6b564b91f1fb7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|
Release files / matrix_io_malos-0.4.1-py3-none-any.whl
| Download URL | matrix_io_malos-0.4.1-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff701b4f650ae45b6ea10c6a881a8809b080c310d2c97452ec88602d04cadc46
|
|
BLAKE2b-256 checksum How to use checksums |
871a96ccbd4e25c8e91f3075d0e8afafa28f5a6133de839270cd40fb9d4f812c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|
Security for matrix-io-malos 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.