fix: strip() doesn't work for some reason. do it manually

This commit is contained in:
Yiao Shen 2022-10-04 17:39:33 -04:00
parent 9e0d995b3f
commit 4cefa3264f
Signed by: y266shen
GPG Key ID: D126FA196DA0F362
1 changed files with 3 additions and 2 deletions

View File

@ -7,9 +7,10 @@ app = Flask(__name__)
@app.route("/") @app.route("/")
def lux(): def lux():
ser = serial.Serial('/dev/ttyACM0') ser = serial.Serial('/dev/ttyACM0')
data = ser.readline() # Remove trailing newline (for some reason strip() doesn't work)
data = str(ser.readline()).split("\\")[0]
if data: if data:
l = float(data.split("=")[1].strip()) l = float(data.split("=")[1])
return str(l) return str(l)
else: else:
return "error" return "error"