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