Closed quatre432 closed 2 years ago
TypeError: 'async for' requires an object with aiter method, got WebsocketImplProtocol
seems the error has to do with websockets, try reinstall websockets on your pi by sudo python3 -m pip uninstall websockets; sudo python3 -m pip install websockets
On your pi, disable cozmars server by sudo systemctl disable cozmars.service
then you run the script https://github.com/hyansuper/wsmprpc/blob/master/examples/server_test_sanic.py
and then from your PC run https://github.com/hyansuper/wsmprpc/blob/master/examples/client_test.py, see if any error occur from your pi or PC
remember to change the address at https://github.com/hyansuper/wsmprpc/blob/master/examples/client_test.py#L5 to your pi's address
my screen is just showing cozmars 37d0 on boot up and doesn't change
that's not an error, 37d0 is your robot's serial code. the robot does not do any thing unless you control it
Thanks for the response i ran the script on the pi and tried both your script and the client test on the client test i recieved this response on the pi
[2021-11-06 14:37:06 -0500] [1379] [INFO] connection open [2021-11-06 14:37:06 -0500] [1379] [ERROR] Exception occurred while handling uri: 'ws://192.168.0.181:8000/' Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sanic/app.py", line 891, in _websocket_handler await fut File "server_test_sanic.py", line 48, in home await RPCServer(ws, SimpleHandler()).run() File "/usr/local/lib/python3.7/dist-packages/wsmprpc/server.py", line 27, in run async for data in self.ws: TypeError: 'async for' requires an object with aiter method, got WebsocketImplProtocol
which is more or less what i got before , i have uninstalled websockets and reinstalled them, its on version 10.0 if it helps
Try the very basic server - client example from https://websockets.readthedocs.io/en/stable/ If it produce the same error, you can seek help at https://github.com/aaugustin/websockets
Thank I Have tried there basic server and client and they work successfully without error
I can't reproduce the error, I suggest you clone the latest code on pi
git clone https://github.com/r-cute/rcute-cozmars-server.git
cd rcute-cozmars-server
sudo python3 -m pip install -e .
sudo systemctl restart cozmars.service
if the same error shows again, try edit you file /usr/local/lib/python3.7/dist-packages/wsmprpc/server.py and change line27 into the following 2 lines
while True:
data = await self.ws.recv()
Thanks changing that code seems to make it respond properly now, screen and servos work but not motors or sound im going to make sure they are on the correct pins though
I am generally new at python, but im trying to get cozmars working the html doesn't seem to do anything doing a basic connection from my pc doesn't seem to change anything my screen is just showing cozmars 37d0 on boot up and doesn't change
I'm not sure if i don't have things plugged in right or maybe something is wrong on my install on pi can anyone give me any tips for diagnosis
Another a little investigation on Robot connection through python or html this error is returned
[2021-10-26 07:12:15 -0900] [877] [INFO] connection open [2021-10-26 07:12:25 -0900] [877] [ERROR] Exception occurred while handling uri: 'ws://192.168.0.181/rpc' Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sanic/app.py", line 891, in _websocket_handler await fut File "/usr/local/lib/python3.7/dist-packages/rcute_cozmars_server/main.py", line 83, in rpc await RPCServer(ws, cozmars_rpc_server).run() File "/usr/local/lib/python3.7/dist-packages/wsmprpc/server.py", line 27, in run async for data in self.ws: TypeError: 'async for' requires an object with aiter method, got WebsocketImplProtocol