project restructure
This commit is contained in:
parent
0140c2f9dc
commit
e682106f10
BIN
docs/dashboard.png
Normal file
BIN
docs/dashboard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
29
main.py
29
main.py
@ -1,29 +0,0 @@
|
|||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
import aioserial
|
|
||||||
import asyncio
|
|
||||||
import socket
|
|
||||||
import signal
|
|
||||||
|
|
||||||
from ubxhandler import UBXHandler
|
|
||||||
from handler import MQTTConfig
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
|
||||||
handler_id = f"example-gps-{socket.gethostname()}"
|
|
||||||
mqtt_config = MQTTConfig(host="127.0.0.1", port=1883)
|
|
||||||
|
|
||||||
serial_port = aioserial.AioSerial(
|
|
||||||
port="/tmp/ttyV0",
|
|
||||||
baudrate=115200,
|
|
||||||
timeout=0.05, # 50 ms
|
|
||||||
)
|
|
||||||
|
|
||||||
handler = UBXHandler(mqtt_config, handler_id, serial_port)
|
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, lambda signum, frame: handler.stop())
|
|
||||||
await handler.run()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
asyncio.run(main())
|
|
||||||
0
mqtthandler/__init__.py
Normal file
0
mqtthandler/__init__.py
Normal file
@ -6,7 +6,7 @@ import signal
|
|||||||
import json
|
import json
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from command import (
|
from .command import (
|
||||||
Command,
|
Command,
|
||||||
CommandResponse,
|
CommandResponse,
|
||||||
CommandArgumentError,
|
CommandArgumentError,
|
||||||
30
ubxhandler.py → ubx.py
Normal file → Executable file
30
ubxhandler.py → ubx.py
Normal file → Executable file
@ -1,12 +1,18 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import aioserial
|
import aioserial
|
||||||
import aiomqtt
|
import aiomqtt
|
||||||
import pyubx2
|
import pyubx2
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
import aioserial
|
||||||
|
import asyncio
|
||||||
|
import socket
|
||||||
|
import signal
|
||||||
|
|
||||||
from command import command
|
from mqtthandler.command import command
|
||||||
from handler import MQTTHandler, task
|
from mqtthandler.handler import MQTTConfig, MQTTHandler, task
|
||||||
|
|
||||||
# The pyubx2 library spams the console with errors that aren't errors.
|
# The pyubx2 library spams the console with errors that aren't errors.
|
||||||
# I don't care if you failed to parse an incomplete buffer.
|
# I don't care if you failed to parse an incomplete buffer.
|
||||||
@ -165,3 +171,23 @@ class UBXHandler(MQTTHandler):
|
|||||||
)
|
)
|
||||||
num_bytes = await self.serial_port.write_async(message.serialize())
|
num_bytes = await self.serial_port.write_async(message.serialize())
|
||||||
return num_bytes
|
return num_bytes
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
handler_id = f"example-gps-{socket.gethostname()}"
|
||||||
|
mqtt_config = MQTTConfig(host="127.0.0.1", port=1883)
|
||||||
|
|
||||||
|
serial_port = aioserial.AioSerial(
|
||||||
|
port="/tmp/ttyV0",
|
||||||
|
baudrate=115200,
|
||||||
|
timeout=0.05, # 50 ms
|
||||||
|
)
|
||||||
|
|
||||||
|
handler = UBXHandler(mqtt_config, handler_id, serial_port)
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, lambda signum, frame: handler.stop())
|
||||||
|
await handler.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
Loading…
Reference in New Issue
Block a user