Add serial and Arduino file

This commit is contained in:
2022-06-24 15:55:13 -07:00
parent 27fc1f5e16
commit 0e638e51bf
12 changed files with 133 additions and 73 deletions

View File

@ -0,0 +1,23 @@
import serial
import logging
# import time as sleep
from prometheus_async.aio import time
from barcode_server.barcode import BarcodeEvent
from barcode_server.notifier import BarcodeNotifier
from barcode_server.stats import SERIAL_NOTIFIER_TIME
LOGGER = logging.getLogger(__name__)
class SerialNotifier(BarcodeNotifier):
def __init__(self, path: str, usb: serial):
super().__init__()
self.path = path
self.usb = usb
@time(SERIAL_NOTIFIER_TIME)
async def _send_event(self, event: BarcodeEvent):
self.usb.write(event.barcode.encode())
LOGGER.debug(f"Notified {self.path}: {event.barcode}")