From e83ffadadac3aaeae79eec228eeec2409e4ea7c2 Mon Sep 17 00:00:00 2001 From: Evangelos Oulis Date: Thu, 5 Dec 2019 16:37:46 +0200 Subject: [PATCH] Update gateway node v1.1 --- gatewayNode/parking.py | 21 +++++++++++---------- git | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/gatewayNode/parking.py b/gatewayNode/parking.py index 04a3dc6..daa906b 100644 --- a/gatewayNode/parking.py +++ b/gatewayNode/parking.py @@ -28,8 +28,9 @@ if json_data != "" and json_data != None: timeout=1 ) counter=0 - - prev_status = ser.readline() + + ser.readline() + prev_status = "-1" while 1: park_status = ser.readline() park_status_data = str(park_status).split("#") @@ -38,16 +39,16 @@ if json_data != "" and json_data != None: parkingStatus = park_status_data[1].replace('\\r\\n\'', '') try: - if park_status != prev_status: - if parkingStatus == "1": - print("parking reserved. RESPONSE :", r.status_code, "\n") - elif parkingStatus == "0": - print("parking not reserved. RESPONSE : ", r.status_code, "\n") + if parkingStatus != prev_status: data = """{"no":""" + parkingCode + ""","status":""" + parkingStatus + """}""" r = requests.post(url = API_ENDPOINT, data = data) - except NameError: - print("**Not already prev variable.\n") - prev_status = park_status + if parkingStatus == "0": + print("parking reserved. RESPONSE :", r.status_code, "\n") + elif parkingStatus == "1": + print("parking not reserved. RESPONSE : ", r.status_code, "\n") + except NameError as e: + print("**Not already prev variable. : ", str(e), "\n") + prev_status = parkingStatus else: print("Create a *.json configuration like: {'ip' : 'xxx.xxx.xxx.xxx', 'port': 'xxxx'}") diff --git a/git b/git index 4bc601a..0195621 100644 --- a/git +++ b/git @@ -1,2 +1,4 @@ cs151051\nv)MEw)73 push origin cs151051\nv)MEw)73 push origin +cs151051 +v)MEw)73 push origin