矩阵实验室坏图书馆
matrix-io-malos的Python项目详细描述
一个简单的基于"python"的驱动程序,用于与"matrix-malos服务"通信。
如"license"文件中所述。
代码块::console
>运行cli客户端
====
库包括一个简单的命令行客户端,可以立即从
malos服务读取数据。
…代码块::控制台
$malosclient-h 192.168.0.100湿度
生成器,因此在代码中可以执行以下操作:
…代码块::python
import asyncio
import sys
from matrix\io.malos.driver import imu\port,uv_port
从matrix_io.proto.malos.v1导入驱动程序_pb2
从matrix_io.proto.malos.v1导入sense_pb2
打印(sense_pb2.imu().fromstring(msg))
等待异步睡眠(1.0)
async def uv_数据(uv_驱动程序):
async for msg in uv_驱动程序。get_data():
打印(sense_pb2.uv().fromstring(msg))
等待异步睡眠(1.0)
定义状态处理程序(驱动程序):
type_mapping={
driver_pb2.status.message_type_not_defined:"未定义",
driver_pb2.status.started:"已启动",
driver_pb2.status.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",
驱动程序pb2.status.status警告:"警告"
驱动程序pb2.status.status信息:"信息"
驱动程序pb2.status.status调试:"调试"
}
如果msg.uuid:
打印("uuid:{}"。格式(msg.uuid))
如果msg.message:
打印("message:{}"。格式(msg.message))
等待异步睡眠(1.0)
=driver_pb2.driverconfig()
uv_端口)
循环。创建任务(uv_driver.start_keep_alive())
loop.create_task(status_handler(uv_driver))
尝试:
loop.run_forever()
除了键盘中断:
print('关闭。再见,再见!,file=sys.stderr)
最后:
loop.stop()
asyncio.gather(*asyncio.task.all_tasks()).cancel()
loop.run_直到完成(loop.shutdown_asyncgens())
loop.close()
谁可以回答有关此库的问题?=
=
>-heitor席尔瓦和lt;heitor.silva@admobilize.com>;
-maciej ruckkgaber和lt;maciek.ruckgaaber@admobilize.com>;
>
==============
=============
/>…目录树::
:仅标题:
changelog
…_ 0mq:http://zeromq.org/
。_ python:https://www.python.org/
。_ virtualenv:https://virtualenv.pypa.io/en/stable/
。_ matrix io-protos-0.0.25:https://pypi.org/project/matrix io proto
。_ PYPI:https://pypi.org/
…_ matrix-malos服务:https://matrix io.github.io/matrix documentation/matrix core/getting started/understanding core/
如"license"文件中所述。
代码块::console
>运行cli客户端
====
库包括一个简单的命令行客户端,可以立即从
malos服务读取数据。
…代码块::控制台
$malosclient-h 192.168.0.100湿度
生成器,因此在代码中可以执行以下操作:
…代码块::python
import asyncio
import sys
from matrix\io.malos.driver import imu\port,uv_port
从matrix_io.proto.malos.v1导入驱动程序_pb2
从matrix_io.proto.malos.v1导入sense_pb2
打印(sense_pb2.imu().fromstring(msg))
等待异步睡眠(1.0)
async def uv_数据(uv_驱动程序):
async for msg in uv_驱动程序。get_data():
打印(sense_pb2.uv().fromstring(msg))
等待异步睡眠(1.0)
定义状态处理程序(驱动程序):
type_mapping={
driver_pb2.status.message_type_not_defined:"未定义",
driver_pb2.status.started:"已启动",
driver_pb2.status.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",
驱动程序pb2.status.status警告:"警告"
驱动程序pb2.status.status信息:"信息"
驱动程序pb2.status.status调试:"调试"
}
如果msg.uuid:
打印("uuid:{}"。格式(msg.uuid))
如果msg.message:
打印("message:{}"。格式(msg.message))
等待异步睡眠(1.0)
=driver_pb2.driverconfig()
uv_端口)
循环。创建任务(uv_driver.start_keep_alive())
loop.create_task(status_handler(uv_driver))
尝试:
loop.run_forever()
除了键盘中断:
print('关闭。再见,再见!,file=sys.stderr)
最后:
loop.stop()
asyncio.gather(*asyncio.task.all_tasks()).cancel()
loop.run_直到完成(loop.shutdown_asyncgens())
loop.close()
谁可以回答有关此库的问题?=
=
>-heitor席尔瓦和lt;heitor.silva@admobilize.com>;
-maciej ruckkgaber和lt;maciek.ruckgaaber@admobilize.com>;
>
==============
=============
/>…目录树::
:仅标题:
changelog
…_ 0mq:http://zeromq.org/
。_ python:https://www.python.org/
。_ virtualenv:https://virtualenv.pypa.io/en/stable/
。_ matrix io-protos-0.0.25:https://pypi.org/project/matrix io proto
。_ PYPI:https://pypi.org/
…_ matrix-malos服务:https://matrix io.github.io/matrix documentation/matrix core/getting started/understanding core/