Balaji-Ganesh / ESP32-SelfDrivingCar

An undergraduate major project with ESP32-camera module and a Flask webclient
MIT License
0 stars 0 forks source link

Capturing navigation controls from web-app and sending to ESP32 #2

Open Balaji-Ganesh opened 1 year ago

Balaji-Ganesh commented 1 year ago
Balaji-Ganesh commented 1 year ago

In middleware, tried using python-socktio (as a client, in async mode). Unable to make a connection. Check the logs pasted in the file.

Balaji-Ganesh commented 1 year ago

Used this repo as a reference -> esp32_SocketIO, which as a library used ESP32/8266 socketio-client library.

Experiment lesson

Logs.. in middleware side..

...............
INFO:     connection closed
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 254, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
  File "/usr/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/fastapi/applications.py", line 282, in __call__
    await super().__call__(scope, receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 149, in __call__
    await self.app(scope, receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/usr/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/routing.py", line 443, in handle
    await self.app(scope, receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/engineio/async_drivers/asgi.py", line 65, in __call__
    await self.not_found(receive, send)
  File "/home/arjuna/.local/lib/python3.10/site-packages/engineio/async_drivers/asgi.py", line 108, in not_found
    await send({'type': 'http.response.start',
  File "/home/arjuna/.local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in sender
    await send(message)
  File "/usr/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 317, in asgi_send
    raise RuntimeError(msg % message_type)
RuntimeError: Expected ASGI message 'websocket.accept' or 'websocket.close', but got 'http.response.start'.

INFO:     connection open
ERROR:    closing handshake failed
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 959, in transfer_data
    message = await self.read_message()
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1029, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1104, in read_data_frame
    frame = await self.read_frame(max_size)
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1161, in read_frame
    frame = await Frame.read(
  File "/usr/lib/python3.10/site-packages/websockets/legacy/framing.py", line 68, in read
    data = await reader(2)
  File "/usr/lib/python3.10/asyncio/streams.py", line 705, in readexactly
    raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/websockets/legacy/server.py", line 248, in handler
    await self.close()
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 766, in close
    await self.write_close_frame(Close(code, reason))
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1232, in write_close_frame
    await self.write_frame(True, OP_CLOSE, data, _state=State.CLOSING)
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1205, in write_frame
    await self.drain()
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 1194, in drain
    await self.ensure_open()
  File "/usr/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 935, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: sent 1000 (OK); no close frame received
..............

Log of ESP32

...........
[SIoC] Disconnected!
[SIoC] add packet 42["status",Hello from esp32!]
[SIoC] add packet 42["status",Hel�2ɽ� esp32!]
[SIoC] Disconnected!
[SIoC] add packet 42["status",Hello from esp32!]
[SIoC] Disconnected!
[SIoC] add packet 42["status",Hello from esp32!]
[SIoC] add packet 42["status",Hello fro+*�32!]
[SIoC] Disconnected!
...........