Help with old script
Forums:
Hi, reviving my old picoborg rev. I want to be able to control my robot with the web ui but not have the camera, I copied a script I'd previously used,(attached) corrected the print functions for python 3 amended Socket Server to socket server but am getting a few errors which I have attached. My board is connected properly works with the GUI and tested it with joystick and it works (only works with Thonny not when I execute in term)
Can you please help.
piborg
Thu, 02/03/2022 - 10:02
Permalink
[Errno 13] Permission denied
This one isn't actually a code problem, it's a user permissions problem instead :)
On Linux the low number ports (below 1024) can only be opened by the superuser. When the script tries to open port 80 it is denied permission and fails.
There are two easy solutions for this.
1. Run the script / python session using
sudo
.This runs the code as the superuser, giving it the permission to open port 80 as intended.
2. Use a higher number port by changing the
webPort
value.Changing the port to a higher number, such as 8000, should allow the script to run with normal user permissions. The only downside to this is having to add the port number after the IP address in the web browser URL.
For example http://192.168.0.100:8000 talks to port 8000 of IP address 192.168.0.100 instead of the standard port 80.
clankerr02
Thu, 02/03/2022 - 23:01
Permalink
Thanks but still not working
Hi, Changing the port to 8000 stopped the previous error. However when I log in to my IP address I get another error and the page wont load.please see attached.
Also is there a solution to cv2 as I'm unable to install it.
Thanks
piborg
Fri, 02/04/2022 - 10:50
Permalink
Python 3 bytes vs string
This is another of those Python 2 vs 3 differences :)
In Python 2 strings are used for both "raw data" and text. In Python 3 a separate bytes type was introduced for this purpose.
All we need to do is convert between the types by telling it how to interpret the raw data into actual text. In our case UTF-8 is the typical choice for text sent to web browsers.
On the receiving side we decode the request as UTF-8:
On the sending side we encode the reply as UTF-8:
I have attached a version with these changes. I also changed the top line to say
python3
instead ofpython
so it can be run directly using./diddyWeb.py
like before.OpenCV (cv2) is only used for capturing and processing images, so you should not really need it if you are not using a camera.
You should be able to install OpenCV for Python 3 using this command:
clankerr02
Mon, 04/25/2022 - 15:17
Permalink
Video stream missing
Hi, I'm trying to get my diddyWeb script running. I'm using a Pi3 and picoborg rev. I've downloaded all relevant software, Opencv, amended the script for python 3 downloaded all missing dependencies. I have no errors when running diddyWeb.py. However when I open my web browser I have no video, the buttons all work. I can take a picture and it is saved on the Pi but there is no video stream. Ive run the same script on a different Pi and still get no video stream.
Could you have a quick look through it and see where Iam going wrong.
Thanks
john
piborg
Tue, 04/26/2022 - 15:13
Permalink
Picamera is not currently supported on Bullseye
It looks like the latest version of Raspbian does not support Picamera or an equivalent at present.
"new Raspberry Pi OS releases will no longer support the familiar raspicam apps and Picamera Python library"
"There is no Python interface yet. An alternative to the old Picamera, imaginatively named Picamera2, is in development."
https://www.raspberrypi.com/news/bullseye-camera-system/
When I tried to run your script I just get MMAL errors from Picamera and it fails to start. Based on the above the same would likely be true for any of the standard Web UI scripts as well.
I think this means the choices are: