From ea55ec786f561759c4065e4973e720fc756ea149 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 13 Aug 2023 04:11:45 +0200 Subject: [PATCH] ignore empty inputs from serial (idk why this happens) --- serial-to-file.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/serial-to-file.py b/serial-to-file.py index 09d7248..759432b 100755 --- a/serial-to-file.py +++ b/serial-to-file.py @@ -16,10 +16,12 @@ outfile = "epever-tracer.json" while 1: # ser.readline() Data = ser.readline().decode('ascii') + print("Data: ") print(Data) - outFile = open(outfile, "w") - outFile.write(Data) - outFile.close + if len(Data) > 0: + outFile = open(outfile, "w") + outFile.write(Data) + outFile.close ##while 1: ## # { "command": "switch", "arg": "one", "state": "off", "ver":"1690931931"}