diff options
-rwxr-xr-x | iot_barcode_device_handler | 1 | ||||
-rwxr-xr-x | iot_barcode_transmitter | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/iot_barcode_device_handler b/iot_barcode_device_handler index 5c05aab..ef40d3e 100755 --- a/iot_barcode_device_handler +++ b/iot_barcode_device_handler @@ -30,6 +30,7 @@ def main(): if eventdata.keystate: with open(fifo_path, "w") as fifo: fifo.write(eventdata.keycode) + fifo.write("\n") fifo.flush() except KeyboardInterrupt: diff --git a/iot_barcode_transmitter b/iot_barcode_transmitter index 5b08111..37336ef 100755 --- a/iot_barcode_transmitter +++ b/iot_barcode_transmitter @@ -25,8 +25,12 @@ def main(): while True: with open(fifo_path, "r") as fifo: - keycode = fifo.read() - character = KEYMAP[keycode] + keycode = fifo.readline() + if keycode in KEYMAP: + character = KEYMAP[keycode] + else: + print("Keycode not recognized") + character = "" if character is "\n": mqtt_service.client.publish( topic, |