Ich glaube ich habe den größten Flaschenhals gefunden: beim CGI muss erst Python gestartet werden, und auf einem 400MHz MIPS core dauert das anscheinend ein bisschen.. 
Aber ich habe einen Lösungspfad gefunden -> Einen Webserver in Python, der auf einem anderen Port läuft und die POST-Anfragen entgegen nimmt und gleich die anderen µC über I2C ansteuert.
Das HTML-File mit den Buttons (fast gleich wie oben, sieht auch genauso aus):
HTML-Code:
<html>
<head><title>Robot</title></head>
<body>
<h4> Hello, this is Robot </h4>
<style>
.hide { overflow:hidden; position:absolute; top:-1px; left:-1px; width:1px; height:1px; }
</style>
<iframe name="hiddenFrame" class="hide">⇄ </iframe>
<form action="http://192.168.0.251:8001/" method="POST" target="hiddenFrame">
Movement:<br/>
<input type="submit" value="↖ " name="Submit_FL" style="height:80px; width:80px" />
<input type="submit" value="↑ " name="Submit_F" style="height:80px; width:80px" />
<input type="submit" value="↗ " name="Submit_FR" style="height:80px; width:80px" />
<br/>
<input type="submit" value="← " name="Submit_L" style="height:80px; width:80px" />
<input type="submit" value="Stop" name="Submit_Stop" style="height:80px; width:80px" />
<input type="submit" value="→ " name="Submit_R" style="height:80px; width:80px" />
<br/>
<input type="submit" value="↙ " name="Submit_BL" style="height:80px; width:80px" />
<input type="submit" value="↓ " name="Submit_B" style="height:80px; width:80px" />
<input type="submit" value="↘ " name="Submit_BR" style="height:80px; width:80px" />
<br/>
<br/>
Mode:</br>
<input type="submit" value="Speed" name="Submit_mode_speed" />
<input type="submit" value="Torque" name="Submit_mode_torque" />
</form>
</body>
</html>
Und das Python-Script, das auf Port 8001 horcht:
Code:
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
import logging
import cgi
import sys
from RobotLibrary import I2C as I2C
from RobotLibrary import robot_motorctrl as motor
from RobotLibrary import robot_servoctrl as servo
PORT = 8001
I = ""
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_HEAD(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
self.do_HEAD()
self.wfile.write("""Thank you for your request..""") # Text der zurueckgegeben wird
def do_POST(self):
logging.warning("======= POST STARTED =======")
logging.warning(self.headers)
form = cgi.FieldStorage(
fp=self.rfile,
headers=self.headers,
environ={'REQUEST_METHOD':'POST',
'CONTENT_TYPE':self.headers['Content-Type'],
})
logging.warning("======= POST VALUES =======")
print(form)
i2c.OPEN('/dev/i2c-0')
if "Submit_F" in form:
motor.SET_MOTORS(20,20)
elif "Submit_FL" in form:
motor.SET_MOTORS(10,20)
elif "Submit_FR" in form:
motor.SET_MOTORS(20,10)
elif "Submit_L" in form:
motor.SET_MOTORS(0,15)
elif "Submit_Stop" in form:
motor.STOP()
elif "Submit_R" in form:
motor.SET_MOTORS(15,0)
elif "Submit_B" in form:
motor.SET_MOTORS(-10,-10)
elif "Submit_BL" in form:
motor.SET_MOTORS(-18,-10)
elif "Submit_BR" in form:
motor.SET_MOTORS(-10,-18)
elif "Submit_mode_speed" in form:
motor.MOVEMODE(motor.MoveMode_Speed)
elif "Submit_mode_torque" in form:
motor.MOVEMODE(motor.MoveMode_Torque)
i2c.CLOSE()
logging.warning("\n")
#SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
self.do_GET()
httpd = SocketServer.TCPServer(("", 8001), ServerHandler)
print("RoboServer, Port = 8001")
httpd.serve_forever()
Wohl noch einige Fehler drin, denn das ganze ist mehr oder weniger zusammen gecopy- & pasted ( von hier https://snipt.net/raw/f8ef141069c3e7...b58c25bf/?nice und hier https://www.assembla.com/spaces/onio...python/history )
Aber: Jetzt ist die Reaktionsgeschwindigkeit VIEL VIEL höher, so um die 200ms grob geschätzt
Supergeile Sache, jetz muss ich das nur noch ordentlich Programmieren. Und jetzt kann man evtl. auch mit z.B. Javascript alle 500ms oder so pollen, so dass der Robo nach spätestens 1sec ohne Poller stehenbleibt
Lesezeichen