Add serial and Arduino file
This commit is contained in:
23
barcode_server/notifier/serial.py
Normal file
23
barcode_server/notifier/serial.py
Normal 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}")
|
Reference in New Issue
Block a user