diff --git a/__pycache__/app_account.cpython-310.pyc b/__pycache__/app_account.cpython-310.pyc new file mode 100644 index 0000000..305bffa Binary files /dev/null and b/__pycache__/app_account.cpython-310.pyc differ diff --git a/__pycache__/app_account.cpython-311.pyc b/__pycache__/app_account.cpython-311.pyc new file mode 100644 index 0000000..bcd42bb Binary files /dev/null and b/__pycache__/app_account.cpython-311.pyc differ diff --git a/__pycache__/app_car.cpython-310.pyc b/__pycache__/app_car.cpython-310.pyc new file mode 100644 index 0000000..6575be2 Binary files /dev/null and b/__pycache__/app_car.cpython-310.pyc differ diff --git a/__pycache__/app_car.cpython-311.pyc b/__pycache__/app_car.cpython-311.pyc new file mode 100644 index 0000000..d009e07 Binary files /dev/null and b/__pycache__/app_car.cpython-311.pyc differ diff --git a/__pycache__/app_events.cpython-310.pyc b/__pycache__/app_events.cpython-310.pyc new file mode 100644 index 0000000..50afc3e Binary files /dev/null and b/__pycache__/app_events.cpython-310.pyc differ diff --git a/__pycache__/app_events.cpython-311.pyc b/__pycache__/app_events.cpython-311.pyc new file mode 100644 index 0000000..56f775a Binary files /dev/null and b/__pycache__/app_events.cpython-311.pyc differ diff --git a/__pycache__/app_obd.cpython-310.pyc b/__pycache__/app_obd.cpython-310.pyc new file mode 100644 index 0000000..14a7f83 Binary files /dev/null and b/__pycache__/app_obd.cpython-310.pyc differ diff --git a/__pycache__/app_obd.cpython-311.pyc b/__pycache__/app_obd.cpython-311.pyc new file mode 100644 index 0000000..48d43ab Binary files /dev/null and b/__pycache__/app_obd.cpython-311.pyc differ diff --git a/app.py b/app.py index c7dbfaf..872803c 100644 --- a/app.py +++ b/app.py @@ -3,8 +3,8 @@ from flask import Flask, render_template, make_response, json from app_events import socketio port_number = 8000 - app = Flask(__name__) + @app.route('/') def index(): print("hello") @@ -24,7 +24,6 @@ def data(): if __name__ == '__main__': socketio.init_app(app) - p_obd_connection = threading.Thread(target=app_obd.obd_connection) p_obd_connection.start() diff --git a/app_events.py b/app_events.py index d1d731b..b4d5bb4 100644 --- a/app_events.py +++ b/app_events.py @@ -10,7 +10,8 @@ os_type = ["Linux","Windows"] def connect_event(): print('Client connected') print('Getting OBD status...') - uptime() + socketio.emit("connect", "connected with server") + # uptime() def uptime(): thread = Thread(target=loop_uptime(os_type[1])) @@ -37,6 +38,7 @@ def loop_uptime(os): while loop == True: time.sleep(1) socketio.emit("rpi_uptime", "1") + print("[+] sent uptime windows (1) packet") diff --git a/app_obd.py b/app_obd.py index e18b8c2..d5e0fcf 100644 --- a/app_obd.py +++ b/app_obd.py @@ -44,19 +44,20 @@ def obd_connection(): else: print("OBD connection failed.") print(obd_status[0]) - obd_events(2) + obd_events(0) @socketio.on('obd') def obd_events(status): if status == 1: - thread_speed = Thread(target=obd_state(1)) - thread_speed.daemon = True - thread_speed.start() + thread_state = Thread(target=obd_state(1)) + thread_state.daemon = True + thread_state.start() - elif status == 2: - thread_speed = Thread(target=obd_state(2)) - thread_speed.daemon = True - thread_speed.start() + # change status to 2 when done testing + elif status == 0: + thread_state = Thread(target=obd_state(2)) + thread_state.daemon = True + thread_state.start() # debug speed for testing thread_speed = Thread(target=obd_speed) @@ -75,15 +76,12 @@ def obd_events(status): def obd_state(status): - obd_state_lock.acquire() loop = True - try: - while loop == True: - print(obd_status[status]) - socketio.emit('obd_status', obd_status[status]) - time.sleep(2) - finally: - obd_state_lock.release() + while loop == True: + print(obd_status[status]) + socketio.emit('obd_status', obd_status[status]) + print("[+] websocket packet sent...") + time.sleep(2) def obd_speed(): obd_speed_lock.acquire() @@ -98,7 +96,7 @@ def obd_speed(): speed = speed + 1 time.sleep(1) if response.is_null(): - print("No data received. #"+ str(get_speedtime())) + print("TEST SPEED for DEBUG #"+ str(get_speedtime())) socketio.emit('obd_speed', get_speedtime()) else: print("Original value:", response.value)