|
@ -1,23 +1,33 @@ |
|
|
|
|
|
#Authors: Oulis Evangelos, Oulis Nikolaos, Drosos Katsibras |
|
|
|
|
|
#=================================================================== |
|
|
#!/usr/bin/env python |
|
|
#!/usr/bin/env python |
|
|
|
|
|
|
|
|
import time |
|
|
import time |
|
|
import serial |
|
|
import serial |
|
|
import requests |
|
|
import requests |
|
|
|
|
|
import json |
|
|
|
|
|
|
|
|
API_ENDPOINT = 'http://192.168.1.13:8080/parkingStatus' |
|
|
with open('data.json') as json_file: |
|
|
parkingCode = "1" |
|
|
server_par = json.load(json_file) |
|
|
ser = serial.Serial( |
|
|
|
|
|
|
|
|
server_ip = server_par['ip'] |
|
|
|
|
|
server_port = server_par['port'] |
|
|
|
|
|
|
|
|
|
|
|
if server_ip != None and server_port != None: |
|
|
|
|
|
API_ENDPOINT = 'http://' + server_ip + ':' + server_port + '/parkingStatus' |
|
|
|
|
|
parkingCode = "1" |
|
|
|
|
|
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 |
|
|
) |
|
|
) |
|
|
counter=0 |
|
|
counter=0 |
|
|
|
|
|
|
|
|
prev_status = ser.readline() |
|
|
prev_status = ser.readline() |
|
|
while 1: |
|
|
while 1: |
|
|
park_status = ser.readline() |
|
|
park_status = ser.readline() |
|
|
try: |
|
|
try: |
|
|
if park_status != prev_status: |
|
|
if park_status != prev_status: |
|
@ -32,4 +42,6 @@ while 1: |
|
|
except NameError: |
|
|
except NameError: |
|
|
print("**Not already prev variable.\n") |
|
|
print("**Not already prev variable.\n") |
|
|
prev_status = park_status |
|
|
prev_status = park_status |
|
|
|
|
|
else: |
|
|
|
|
|
print("Create a *.json configuration like: {'ip' : 'xxx.xxx.xxx.xxx', 'port': 'xxxx'}") |
|
|
|
|
|
|
|
|