Posts: 38
Joined: Mon Feb 16, 2015 9:19 am

Cambot Web Control Issues

Sat Mar 28, 2015 6:38 pm

I have converted an old RC Truck into a pi hearted vehicle with picam mounted on a pan and tilt unit. My Python script works fine with wired mouse and monitor and also via VNC over Wi-Fi on my home network. VNC is not an ideal route to control the device so I have set about trying to build a web based solution. Stupidly I thought I just needed to strip the tkinter window and controls out of the Python script and build an html/javascript/jqueryui web page to generate the control variables values and send them to the python truncated script now residing in a cgi-bin folder. The web server is lighttpd (I tried to get fastcgi working but gave up after hours of fiddling). I have successfully called script called test.py which ran the cgi.test code successfully so I think cgi is setup ok.
I have two (that I know about) problems:
1) the truncated python script in the cgi-bin fails saying it can't import PicoBorgReverse because it doesn't exist. This isn't correct since the full version of the script works fine (all of the files are set to allow anyone to do anything including execute them).
2) I have attempted to set up a test of the return of values from the html to cgi using json . an example slider script on the html page is:
$("#speed" ).slider({
min : -100,
max : 100,
orientation: "vertical",
value : 0,
slide: function(event, ui){
method: "POST",
url: "cgi-bin/cambot-control.py",
data: {data:("slide", function(event,ui){}) }
.done(function( msg ) {
alert( "Data Saved" );
and in the test python cgi script (which should print the structure of the incoming data):
#recieve cgi data
import cgi
import cgitb
cgitb.enable(display=0, logdir="home/var/log/")
import json
print "content-type: application/json"
print form.keys()

If I load the html into a browser and move a slider it generates a series of data saved boxes. However running the python script yields no keys or values.

Is there a way of telling whether the client browser is actually sending the values back to the web server and where? currently it doesn't generate a message or log. in Lighttpd.conf there is the line "cgi.assign = (".py" => "/usr/bin/python")", mod_cgi is in the server section, and ".py" is in the static-file exclude extensions line

Any help would be appreciated the last few days of trying to suss it out feel like they were round in circles.

Thanks for any help

Return to “Automation, sensing and robotics”