|
@ -11,27 +11,27 @@ server_port = "443" |
|
|
API_ENDPOINT = 'https://' + server_ip + ':' + server_port + '/' |
|
|
API_ENDPOINT = 'https://' + server_ip + ':' + server_port + '/' |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
ser = serial.Serial( |
|
|
# ser = serial.Serial( |
|
|
port='/dev/ttyACM0', |
|
|
# port='/dev/ttyACM0', |
|
|
baudrate = 9600, |
|
|
# baudrate = 9600, |
|
|
parity=serial.PARITY_NONE, |
|
|
# parity=serial.PARITY_NONE, |
|
|
stopbits=serial.STOPBITS_ONE, |
|
|
# stopbits=serial.STOPBITS_ONE, |
|
|
bytesize=serial.EIGHTBITS, |
|
|
# bytesize=serial.EIGHTBITS, |
|
|
timeout=1 |
|
|
# timeout=1 |
|
|
) |
|
|
# ) |
|
|
|
|
|
|
|
|
c = requests.get(url=API_ENDPOINT, params = {}) |
|
|
c = requests.get(url=API_ENDPOINT, params = {}) |
|
|
doc = c.json() |
|
|
doc = c.json() |
|
|
|
|
|
|
|
|
parking = None |
|
|
parking = None |
|
|
for park in doc: |
|
|
for park in doc: |
|
|
if doc[str(park)] == 1: |
|
|
if park['status'] == True: |
|
|
parking = park |
|
|
parking = park #{"no": park['no'], "status": park['status']} |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|
print ("Free parking is Number: " + parking) |
|
|
print ("Free parking is Number: " + str(parking['no'])) |
|
|
ser.write("b'" + parking + "'") |
|
|
# ser.write("b'" + parking['no'] + "'") |
|
|
ser.flush() |
|
|
# ser.flush() |
|
|
except (NameError, TypeError) as e: |
|
|
except (NameError, TypeError) as e: |
|
|
print ("No free parking") |
|
|
print ("No free parking") |
|
|
except requests.exceptions.ConnectionError: |
|
|
except requests.exceptions.ConnectionError: |
|
|