]> ToastFreeware Gitweb - toast/airingbutler.git/blobdiff - log_mhz19.py
log_mhz19.py: fix deprecation warning with python 3.10
[toast/airingbutler.git] / log_mhz19.py
old mode 100644 (file)
new mode 100755 (executable)
index 57140d6..7dea051
@@ -1,3 +1,5 @@
+#!/usr/bin/python3
+
 import argparse
 import asyncio
 import logging
@@ -26,7 +28,7 @@ class Receiver(asyncio.Protocol):
 
     def data_received(self, data):
         data = data.decode()
-        print(data, end='')
+        print(data, end='', flush=True)
 
     def connection_lost(self, exc):
         log.debug('port closed')
@@ -38,7 +40,7 @@ def main():
     parser.add_argument('--device', '-d', default='/dev/ttyACM0', help='Device where Arduino is connected to')
     args = parser.parse_args()
     logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(message)s')
-    loop = asyncio.get_event_loop()
+    loop = asyncio.new_event_loop()
     coro = serial_asyncio.create_serial_connection(loop, Receiver, args.device, baudrate=115200)
     loop.run_until_complete(coro)
     loop.run_forever()