From 84b9ddcc2905f5d8667cfef1359b724c23d27365 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 29 Oct 2020 12:11:32 +0100 Subject: Setup basic Systemd Units --- barcode_scanner_daemon.py | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100755 barcode_scanner_daemon.py (limited to 'barcode_scanner_daemon.py') diff --git a/barcode_scanner_daemon.py b/barcode_scanner_daemon.py deleted file mode 100755 index 09139f7..0000000 --- a/barcode_scanner_daemon.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python3 - - -"""Executable to read the Key Events from the Barcode Scanner (root Priviledges necessary)""" - - -import evdev -import os - -import iot_barcode_scanner.config as config - - -def main(): - - try: - # read config - cfg = config.get_config() - fifo_path = cfg["scanner"]["fifo_path"] - event_device_path = cfg["scanner"]["evdev_path"] - - # prepare fifo - os.makedirs(os.path.dirname(fifo_path), exist_ok=True) - os.mkfifo(fifo_path) - - barcode_scanner = evdev.InputDevice(event_device_path) - with barcode_scanner.grab_context(): - for event in barcode_scanner.read_loop(): - if event.type == evdev.ecodes.EV_KEY: - eventdata = evdev.categorize(event) - if eventdata.keystate: - with open(fifo_path, "w") as fifo: - fifo.write(eventdata.keycode) - fifo.flush() - - except KeyboardInterrupt: - pass - - finally: - os.remove(fifo_path) - - -if __name__ == "__main__": - main() -- cgit v1.2.3-70-g09d2